diff options
| author | mitchell <unknown> | 2020-04-25 16:26:31 -0400 |
|---|---|---|
| committer | mitchell <unknown> | 2020-04-25 16:26:31 -0400 |
| commit | fad15f79b1230b3076be515d6894c8919562809b (patch) | |
| tree | 72c848ef02c3331de5ca54eff7adaea3a9a6fb88 /lexlua/django.lua | |
| parent | 1fd02a367dec125c0b49dd9246a0928433866b96 (diff) | |
| download | scintilla-mirror-fad15f79b1230b3076be515d6894c8919562809b.tar.gz | |
Reformatted Lua LPeg lexers and added new convenience functions and pattern.
`lexer.range()` replaces `lexer.delimited_range()` and `lexer.nested_pair()`.
`lexer.to_eol()` replaces `patt * lexer.nonnewline^0` constructs.
`lexer.number` replaces `lexer.float + lexer.integer`.
Also added unit tests for lexer functions.
Diffstat (limited to 'lexlua/django.lua')
| -rw-r--r-- | lexlua/django.lua | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lexlua/django.lua b/lexlua/django.lua index 74a6a7da2..96a9b454b 100644 --- a/lexlua/django.lua +++ b/lexlua/django.lua @@ -32,16 +32,15 @@ lex:add_rule('function', token(lexer.FUNCTION, word_match[[ lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) -- Strings. -lex:add_rule('string', token(lexer.STRING, - lexer.delimited_range('"', false, true))) +lex:add_rule('string', token(lexer.STRING, lexer.range('"', false, false))) -- Operators. lex:add_rule('operator', token(lexer.OPERATOR, S(':,.|'))) -- Embed Django in HTML. local html = lexer.load('html') -local html_comment = '<!--' * (lexer.any - '-->')^0 * P('-->')^-1 -local django_comment = '{#' * (lexer.any - lexer.newline - '#}')^0 * P('#}')^-1 +local html_comment = lexer.range('<!--', '-->') +local django_comment = lexer.range('{#', '#}', true) html:modify_rule('comment', token(lexer.COMMENT, html_comment + django_comment)) local django_start_rule = token('django_tag', '{' * S('{%')) local django_end_rule = token('django_tag', S('%}') * '}') |
