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/ini.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/ini.lua')
| -rw-r--r-- | lexlua/ini.lua | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lexlua/ini.lua b/lexlua/ini.lua index d5445ba12..d56539d42 100644 --- a/lexlua/ini.lua +++ b/lexlua/ini.lua @@ -17,19 +17,19 @@ lex:add_rule('keyword', token(lexer.KEYWORD, 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("'") + - lexer.delimited_range('"'))) +local sq_str = lexer.range("'") +local dq_str = lexer.range('"') +lex:add_rule('string', token(lexer.STRING, sq_str + dq_str)) -- Labels. -lex:add_rule('label', token(lexer.LABEL, - lexer.delimited_range('[]', true, true))) +lex:add_rule('label', token(lexer.LABEL, lexer.range('[', ']', true))) -- Comments. -lex:add_rule('comment', token(lexer.COMMENT, lexer.starts_line(S(';#')) * - lexer.nonnewline^0)) +lex:add_rule('comment', token(lexer.COMMENT, + lexer.to_eol(lexer.starts_line(S(';#'))))) -- Numbers. local dec = lexer.digit^1 * ('_' * lexer.digit^1)^0 |
