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/autoit.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/autoit.lua')
| -rw-r--r-- | lexlua/autoit.lua | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lexlua/autoit.lua b/lexlua/autoit.lua index 5bb5752f9..3b6d3ae6a 100644 --- a/lexlua/autoit.lua +++ b/lexlua/autoit.lua @@ -97,12 +97,10 @@ lex:add_rule('function', token(lexer.FUNCTION, word_match([[ lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) -- Comments. -local line_comment = ';' * lexer.nonnewline_esc^0 -local block_comment1 = '#comments-start' * (lexer.any - '#comments-end')^0 * - P('#comments-end')^-1 -local block_comment2 = '#cs' * (lexer.any - '#ce')^0 * P('#ce')^-1 -lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment1 + - block_comment2)) +local line_comment = lexer.to_eol(';') +local block_comment = lexer.range('#comments-start', '#comments-end') + + lexer.range('#cs', '#ce') +lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) -- Preprocessor. lex:add_rule('preprocessor', token(lexer.PREPROCESSOR, '#' * word_match([[ @@ -111,9 +109,9 @@ lex:add_rule('preprocessor', token(lexer.PREPROCESSOR, '#' * word_match([[ ]], true))) -- Strings. -local dq_str = lexer.delimited_range('"', true, true) -local sq_str = lexer.delimited_range("'", true, true) -local inc = lexer.delimited_range('<>', true, true, true) +local dq_str = lexer.range('"', true, false) +local sq_str = lexer.range("'", true, false) +local inc = lexer.range('<', '>', true, false, true) lex:add_rule('string', token(lexer.STRING, dq_str + sq_str + inc)) -- Macros. @@ -124,7 +122,7 @@ lex:add_style('macro', lexer.STYLE_PREPROCESSOR) lex:add_rule('variable', token(lexer.VARIABLE, '$' * (lexer.alnum + '_')^1)) -- Numbers. -lex:add_rule('number', token(lexer.NUMBER, lexer.float + lexer.integer)) +lex:add_rule('number', token(lexer.NUMBER, lexer.number)) -- Operators. lex:add_rule('operator', token(lexer.OPERATOR, S('+-^*/&<>=?:()[]'))) |
