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/asm.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/asm.lua')
| -rw-r--r-- | lexlua/asm.lua | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lexlua/asm.lua b/lexlua/asm.lua index 42558fa05..12ebdf3cf 100644 --- a/lexlua/asm.lua +++ b/lexlua/asm.lua @@ -314,7 +314,7 @@ local constants = word_match[[ __float80e__ __float80m__ __Infinity__ __NaN__ __QNaN__ __SNaN__ ]] lex:add_rule('constant', token(lexer.CONSTANT, constants + - '$' * P('$')^-1 * -word)) + '$' * P('$')^-1 * -word)) -- Labels. lex:add_rule('label', token(lexer.LABEL, word * ':')) @@ -323,18 +323,18 @@ lex:add_rule('label', token(lexer.LABEL, word * ':')) lex:add_rule('identifier', token(lexer.IDENTIFIER, word)) -- Strings. -lex:add_rule('string', token(lexer.STRING, lexer.delimited_range("'", true) + - lexer.delimited_range('"', true))) +local sq_str = lexer.range("'", true) +local dq_str = lexer.range('"', true) +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) -- Comments. -lex:add_rule('comment', token(lexer.COMMENT, ';' * lexer.nonnewline^0)) +lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol(';'))) -- Numbers. -lex:add_rule('number', token(lexer.NUMBER, lexer.float + - lexer.integer * S('hqb')^-1)) +lex:add_rule('number', token(lexer.NUMBER, lexer.number * S('hqb')^-1)) -- Preprocessor. -local preproc_word = word_match[[ +local pp_word = word_match[[ arg assign clear define defstr deftok depend elif elifctx elifdef elifempty elifenv elifid elifidn elifidni elifmacro elifn elifnctx elifndef elifnempty elifnenv elifnid elifnidn elifnidni elifnmacro elifnnum elifnstr elifntoken @@ -345,9 +345,8 @@ local preproc_word = word_match[[ ixdefine line local macro pathsearch pop push rep repl rmacro rotate stacksize strcat strlen substr undef unmacro use warning while xdefine ]] -local preproc_symbol = '??' + S('!$+?') + '%' * -lexer.space + R('09')^1 -lex:add_rule('preproc', token(lexer.PREPROCESSOR, '%' * (preproc_word + - preproc_symbol))) +local pp_symbol = '??' + S('!$+?') + '%' * -lexer.space + R('09')^1 +lex:add_rule('preproc', token(lexer.PREPROCESSOR, '%' * (pp_word + pp_symbol))) -- Operators. lex:add_rule('operator', token(lexer.OPERATOR, S('+-/*%<>!=^&|~:,()[]'))) |
