aboutsummaryrefslogtreecommitdiffhomepage
path: root/lexlua/rebol.lua
diff options
context:
space:
mode:
authormitchell <unknown>2020-04-25 16:26:31 -0400
committermitchell <unknown>2020-04-25 16:26:31 -0400
commitfad15f79b1230b3076be515d6894c8919562809b (patch)
tree72c848ef02c3331de5ca54eff7adaea3a9a6fb88 /lexlua/rebol.lua
parent1fd02a367dec125c0b49dd9246a0928433866b96 (diff)
downloadscintilla-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/rebol.lua')
-rw-r--r--lexlua/rebol.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/lexlua/rebol.lua b/lexlua/rebol.lua
index 7cc8a2186..5994a4cd5 100644
--- a/lexlua/rebol.lua
+++ b/lexlua/rebol.lua
@@ -11,9 +11,8 @@ local lex = lexer.new('rebol')
lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
-- Comments.
-local line_comment = ';' * lexer.nonnewline^0;
-local block_comment = 'comment' * P(' ')^-1 *
- lexer.delimited_range('{}', false, true)
+local line_comment = lexer.to_eol(';')
+local block_comment = 'comment' * P(' ')^-1 * lexer.range('{', '}')
lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment))
-- Keywords.
@@ -80,12 +79,13 @@ lex:add_rule('keyword', token(lexer.KEYWORD, word_match[[
-- Identifiers.
lex:add_rule('identifier', token(lexer.IDENTIFIER, (lexer.alpha + '-') *
- (lexer.alnum + '-')^0))
+ (lexer.alnum + '-')^0))
-- Strings.
-lex:add_rule('string', token(lexer.STRING, lexer.delimited_range('"', true) +
- lexer.delimited_range('{}') +
- "'" * lexer.word))
+local dq_str = lexer.range('"', true)
+local br_str = lexer.range('{', '}', false, false, true)
+local word_str = "'" * lexer.word
+lex:add_rule('string', token(lexer.STRING, dq_str + br_str + word_str))
-- Operators.
lex:add_rule('operator', token(lexer.OPERATOR, S('=<>+/*:()[]')))