diff options
Diffstat (limited to 'lexlua/myrddin.lua')
| -rw-r--r-- | lexlua/myrddin.lua | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/lexlua/myrddin.lua b/lexlua/myrddin.lua index e836a0b24..1277468c4 100644 --- a/lexlua/myrddin.lua +++ b/lexlua/myrddin.lua @@ -26,17 +26,14 @@ lex:add_rule('type', token(lexer.TYPE, word_match[[ lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) -- Comments. -local line_comment = '//' * lexer.nonnewline_esc^0 -local block_comment = P{ - V'part' * P'*/'^-1, - part = '/*' * (V'full' + (lexer.any - '/*' - '*/'))^0, - full = V'part' * '*/', -} +local line_comment = lexer.to_eol('//', true) +local block_comment = lexer.range('/*', '*/', false, false, true) lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment)) -- 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)) -- Numbers. local digit = lexer.digit + '_' @@ -44,8 +41,9 @@ local bdigit = R'01' + '_' local xdigit = lexer.xdigit + '_' local odigit = R'07' + '_' local integer = '0x' * xdigit^1 + '0o' * odigit^1 + '0b' * bdigit^1 + digit^1 -local float = digit^1 * (('.' * digit^1) * (S'eE' * S'+-'^-1 * digit^1)^-1 + - ('.' * digit^1)^-1 * S'eE' * S'+-'^-1 * digit^1) +local float = digit^1 * ( + ('.' * digit^1) * (S'eE' * S'+-'^-1 * digit^1)^-1 + + ('.' * digit^1)^-1 * S'eE' * S'+-'^-1 * digit^1) lex:add_rule('number', token(lexer.NUMBER, float + integer)) -- Operators. |
