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/ps.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/ps.lua')
| -rw-r--r-- | lexlua/ps.lua | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lexlua/ps.lua b/lexlua/ps.lua index 255a92339..8ebde45fd 100644 --- a/lexlua/ps.lua +++ b/lexlua/ps.lua @@ -28,15 +28,15 @@ local word = (lexer.alpha + '-') * (lexer.alnum + '-')^0 lex:add_rule('identifier', token(lexer.IDENTIFIER, word)) -- Strings. -local arrow_string = lexer.delimited_range('<>') -local nested_string = lexer.delimited_range('()', false, false, true) +local arrow_string = lexer.range('<', '>') +local nested_string = lexer.range('(', ')', false, false, true) lex:add_rule('string', token(lexer.STRING, arrow_string + nested_string)) -- 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)) +lex:add_rule('number', token(lexer.NUMBER, lexer.number)) -- Labels. lex:add_rule('label', token(lexer.LABEL, '/' * word)) |
