diff options
author | Adrian Thurston <thurston@colm.net> | 2021-12-03 14:12:32 -0800 |
---|---|---|
committer | Adrian Thurston <thurston@colm.net> | 2021-12-03 17:17:29 -0800 |
commit | 69c077bc5cb649293c198593f6ac20cb922cfab4 (patch) | |
tree | 99b917bbf2b0e3cd97e8c2168b7f98da80ef6a23 | |
parent | 7ef8bfa08af561abd65bd9a43ba5188884890686 (diff) | |
download | ragel-69c077bc5cb649293c198593f6ac20cb922cfab4.tar.gz |
improvements to rust frontend scanner
Improved lexing of char lits and identifiers (including lifetimes).
-rw-r--r-- | src/host-rust/rlparse.lm | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/src/host-rust/rlparse.lm b/src/host-rust/rlparse.lm index f872fd61..a988169e 100644 --- a/src/host-rust/rlparse.lm +++ b/src/host-rust/rlparse.lm @@ -2,7 +2,7 @@ include 'ragel.lm' include 'rlreduce.lm' rl ident - /( alpha | '_' ) ( alpha | digit | '_' )*/ + /"'"? ( alpha | '_' ) ( alpha | digit | '_' )*/ rl number / digit+ / @@ -10,29 +10,20 @@ rl number rl hex_number / '0x' [0-9a-fA-F]+ / -rl hex_char - / '0x' [0-9a-fA-F]{2} / - rl NL / '\n' / -rl c_comment +rl block_comment / '/*' ( any | NL )* :>> '*/' / -rl cpp_comment +rl line_comment / '//' [^\n]* NL / -rl ruby_comment - / '#' [^\n]* NL / - -rl s_literal - / "'" ([^'\\\n] | '\\' (any | NL))* "'" / +rl char_literal + / "'" ([^\\\n] | '\\' (any | NL)) "'" / -rl d_literal +rl string_literal / '"' ([^"\\] | NL | '\\' (any | NL))* '"' / -rl host_re_literal - / '/' ([^/\\] | NL | '\\' (any | NL))* '/' / - namespace inline lex literal `fpc `fc `fcurs `ftargs @@ -41,14 +32,13 @@ namespace inline token ident /ident/ token number /digit+/ - token hex_number /'0x' [0-9a-fA-F]+/ - token dec_number /'0x' [0-9a-fA-F]+/ + token hex_number /hex_number/ token comment - / c_comment | cpp_comment / + / block_comment | line_comment / token string - / s_literal | d_literal / + / char_literal | string_literal / token whitespace / ( [ \t] | NL )+ / @@ -107,23 +97,17 @@ namespace host rl NL / '\n' / - rl s_literal - / "'" ([^'\\\n] | '\\' (any | NL))* "'" / - - rl d_literal - / '"' ([^"\\] | NL | '\\' (any | NL))* '"' / - literal `define `= - token ident /ident "'"?/ + token ident /ident/ token number /digit+/ - token hex_number /'0x' [0-9a-fA-F]+/ + token hex_number /hex_number/ token comment - / c_comment | cpp_comment / + / block_comment | line_comment / token string - / s_literal | d_literal / + / char_literal | string_literal / token whitespace / ( [ \t] | NL )+ / |