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/gtkrc.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/gtkrc.lua')
| -rw-r--r-- | lexlua/gtkrc.lua | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lexlua/gtkrc.lua b/lexlua/gtkrc.lua index c500c033c..fbeaa86ba 100644 --- a/lexlua/gtkrc.lua +++ b/lexlua/gtkrc.lua @@ -35,18 +35,19 @@ lex:add_rule('function', token(lexer.FUNCTION, word_match[[ -- Identifiers. lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.alpha * - (lexer.alnum + S('_-'))^0)) + (lexer.alnum + S('_-'))^0)) -- 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.digit^1 * - ('.' * lexer.digit^1)^-1)) + ('.' * lexer.digit^1)^-1)) -- Operators. lex:add_rule('operator', token(lexer.OPERATOR, S(':=,*()[]{}'))) |
