diff options
author | Adrian Thurston <thurston@complang.org> | 2014-01-14 20:22:15 -0500 |
---|---|---|
committer | Adrian Thurston <thurston@complang.org> | 2014-01-14 20:22:15 -0500 |
commit | cacdac00b74cb4e84eb6f1cc302cae5393564f6e (patch) | |
tree | bd6bcdb3a3ca5a8d2f6b129e0414088fc70e9f24 /test | |
parent | 719bedbccdf190d173c2078415c29553c6beecb3 (diff) | |
download | colm-cacdac00b74cb4e84eb6f1cc302cae5393564f6e.tar.gz |
updated test cases for syntax changes in parent commit
Diffstat (limited to 'test')
71 files changed, 1326 insertions, 1308 deletions
diff --git a/test/accum1.lm b/test/accum1.lm index ba262e7b..f4aa963a 100644 --- a/test/accum1.lm +++ b/test/accum1.lm @@ -1,13 +1,13 @@ ##### LM ##### lex ignore /space+/ - literal '*', '(', ')' + literal `* `( `) token id /[a-zA-Z_]+/ end def item [id] -| ['(' item* ')'] +| [`( item* `)] def start [item*] diff --git a/test/accum2.lm b/test/accum2.lm index a9da90fb..05e377b1 100644 --- a/test/accum2.lm +++ b/test/accum2.lm @@ -7,7 +7,7 @@ k: int lex ignore /space+/ - literal '*', '(', ')' + literal `* `( `) token id /[a-zA-Z_]+/ end @@ -16,7 +16,7 @@ def foo [id] def item [id] | [foo] -| ['(' item* ')'] +| [`( item* `)] { i = 0 } diff --git a/test/accum3.lm b/test/accum3.lm index 3c2c83c9..956bb3f4 100644 --- a/test/accum3.lm +++ b/test/accum3.lm @@ -1,6 +1,6 @@ ##### LM ##### lex - literal '-' + literal `- token file /^('-'|0)(^0)*/ end @@ -14,8 +14,8 @@ end def item [file zero] -| ['-' single* zero] -| ['-' with_opt zero? word zero] +| [`- single* zero] +| [`- with_opt zero? word zero] def args [word zero item*] diff --git a/test/accumbt2.lm b/test/accumbt2.lm index b32569a0..6d21c30b 100644 --- a/test/accumbt2.lm +++ b/test/accumbt2.lm @@ -13,7 +13,8 @@ OneParser: accum<one> lex ignore /[ \t]+/ token id2 /[a-zA-Z_][a-zA-Z_0-9]*/ - literal '!', ';', '\n' + literal `! `; + token NL /'\n'/ def A1 [] { print( "A1\n" ) } @@ -29,8 +30,8 @@ lex } def two - [A1 item2* '!' '\n'] - | [A2 item2* ';' '\n'] + [A1 item2* `! NL] + | [A2 item2* `; NL] end end # accum_bt diff --git a/test/accumbt3.lm b/test/accumbt3.lm index e6cb25fa..37532829 100644 --- a/test/accumbt3.lm +++ b/test/accumbt3.lm @@ -24,7 +24,7 @@ end # lex - literal '(', ')' + literal `( `) token nc_data /[^()]+/ end @@ -33,7 +33,7 @@ def nc_item | [nested_comment] def nested_comment - ['(' nc_item* ')'] + [`( nc_item* `)] def nested [id*] @@ -48,7 +48,8 @@ lex ignore /[ \t]+/ token word /[a-zA-Z0-9/*+_\-]+/ token stuff /[a-zA-Z0-9()/*+_\- ]+/ - literal '!', ';', '\n' + literal `! `; + token NL /'\n'/ end @@ -74,8 +75,8 @@ def item } def two - [A1 item* '!' '\n'] -| [A2 item* ';' '\n'] + [A1 item* `! NL] +| [A2 item* `; NL] end # accum_bt diff --git a/test/argv2.lm b/test/argv2.lm index eb1ba790..5c84564f 100644 --- a/test/argv2.lm +++ b/test/argv2.lm @@ -1,6 +1,6 @@ ##### LM ##### lex - literal '-' + literal `- token file /^('-'|0)(^0)*/ end @@ -8,28 +8,29 @@ lex token single /[qvh]/ token with_opt /[oi]/ token dash /'-'/ - literal 'help', 'verbose', 'input', '=' + + literal `help `verbose `input `= end def long - ['help'] -| ['verbose'] + [`help] +| [`verbose] def long_with_opt - ['input'] + [`input] def long_eqals - ['='] + [`=] | [zero] token word /(^0)+/ token zero /0/ def item - ['-' single* zero] -| ['-' with_opt zero? word zero] -| ['-' dash long zero] -| ['-' dash long_with_opt long_eqals word zero] + [`- single* zero] +| [`- with_opt zero? word zero] +| [`- dash long zero] +| [`- dash long_with_opt long_eqals word zero] | [file zero] def args @@ -48,23 +49,23 @@ Args: args = ArgParser() # Process the args. for Item: item in Args { if match Item - ['-' SL: single* zero] + [`- SL: single* zero] { for S: single in SL print( "single: [$S]\n" ) } elsif match Item - ['-' W: with_opt zero? Opt: word zero] + [`- W: with_opt zero? Opt: word zero] { print( "with opt: [$W] -> [$Opt]\n" ) } elsif match Item - ['-' dash L: long zero] + [`- dash L: long zero] { print("long: [$L]\n" ) } elsif match Item - ['-' dash LO: long_with_opt long_eqals LongOpt: word zero] + [`- dash LO: long_with_opt long_eqals LongOpt: word zero] { print("long: [$LO] -> [$LongOpt]\n" ) } diff --git a/test/backtrack1.lm b/test/backtrack1.lm index acf54674..76f37053 100644 --- a/test/backtrack1.lm +++ b/test/backtrack1.lm @@ -2,18 +2,18 @@ # Token names. lex - literal '+', '*' + literal `+ `* token number /[0-9]+/ ignore ws / [ \t\n]+ / end def F - [number '+'] + [number `+] | [number] -| [F '*' number] +| [F `* number] def E - [E '+' F] + [E `+ F] | [F] def start diff --git a/test/btscan1.lm b/test/btscan1.lm index a67da43d..558b8906 100644 --- a/test/btscan1.lm +++ b/test/btscan1.lm @@ -5,11 +5,11 @@ namespace r1 lex - literal '!', 'a', 'b' + literal `! `a `b ignore /[ \n\t]+/ end - def line [ '!' 'a' 'b' 'b' 'a'] + def line [ `! `a `b `b `a] end # r1 @@ -19,12 +19,12 @@ end # r1 namespace r2 lex - literal '!' + literal `! token id /[a-zA-Z_]+/ ignore /[ \n\t]+/ end - def line [ '!' id ] + def line [ `! id ] end # r2 diff --git a/test/btscan2.lm b/test/btscan2.lm index 04a023a6..bfc77dbc 100644 --- a/test/btscan2.lm +++ b/test/btscan2.lm @@ -2,23 +2,23 @@ namespace r1 lex - literal '!', 'a', 'b' + literal `! `a `b ignore /[ \n\t]+/ end - def line [ '!' 'a' 'b' 'b' 'a'] + def line [ `! `a `b `b `a] end # r1 namespace r2 lex - literal '!' + literal `! token id /[a-zA-Z_]+/ ignore /[ \n\t]+/ end - def line [ '!' id ] + def line [ `! id ] end # r2 diff --git a/test/commitbt.lm b/test/commitbt.lm index fcbb22ab..da788070 100644 --- a/test/commitbt.lm +++ b/test/commitbt.lm @@ -20,10 +20,10 @@ lex ignore /[\t\n ]+/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** token word /[a-zA-Z_][a-zA-Z0-9_]*/ token uint /[0-9]+/ @@ -33,10 +33,10 @@ end def expression [term expression_op*] def expression_op - ['|' term] -| ['&' term] -| ['-' term] -| ['--' term] + [`| term] +| [`& term] +| [`- term] +| [`-- term] def term [factor_rep term_rest] @@ -47,35 +47,35 @@ def term_rest def term_op [factor_rep] -| ['.' factor_rep] -| [':>' factor_rep] -| [':>>' factor_rep] -| ['<:' factor_rep] +| [`. factor_rep] +| [`:> factor_rep] +| [`:>> factor_rep] +| [`<: factor_rep] def factor_rep [factor_neg factor_rep_op*] def factor_rep_op - ['*'] -| ['**'] -| ['?'] -| ['+'] -| ['{' factor_rep_num '}'] -| ['{' ',' factor_rep_num '}'] -| ['{' factor_rep_num ',' '}'] -| ['{' factor_rep_num ',' factor_rep_num '}'] + [`*] +| [`**] +| [`?] +| [`+] +| [`{ factor_rep_num `}] +| [`{ `, factor_rep_num `}] +| [`{ factor_rep_num `, `}] +| [`{ factor_rep_num `, factor_rep_num `}] def factor_rep_num [uint] def factor_neg - ['!' factor_neg] -| ['^' factor_neg] + [`! factor_neg] +| [`^ factor_neg] | [factor] def factor [alphabet_num] | [word] -| ['(' expression ')'] +| [`( expression `)] def alphabet_num [uint] @@ -85,7 +85,7 @@ def suint [uint] def sub - [suint* '*'] + [suint* `*] token item S: sub @@ -97,7 +97,7 @@ token item } def stuff - [item* '!'] + [item* `!] | [sub] parse S: stuff[ stdin ] diff --git a/test/concat1.lm b/test/concat1.lm index cb64312b..ee924092 100644 --- a/test/concat1.lm +++ b/test/concat1.lm @@ -1,7 +1,7 @@ ##### LM ##### lex - literal 'type', 'include' + literal `type `include token id /[A-Za-z_][A-Za-z_0-9]*/ ignore /'#' [^\n]* '\n'/ ignore /[ \t\r\n]+/ @@ -21,7 +21,7 @@ def ifn_path | [ifn_path_part] -literal '%%' +literal `%% lex token em_ws /( any - 33..126 )+/ @@ -31,11 +31,11 @@ def em_item [em_ws] def prelude - [em_item* '%%'] + [em_item* `%%] def item - ['include' ifn_path] -| ['type' id] + [`include ifn_path] +| [`type id] def start [prelude item*] @@ -67,7 +67,7 @@ item* expandIncludes( ItemList: ref<item*> ) { for IL: item* in ItemList { if match IL - ['include' FN: ifn_path Rest: item*] + [`include FN: ifn_path Rest: item*] { S: start = parseTxt( " @@ -75,7 +75,7 @@ item* expandIncludes( ItemList: ref<item*> ) " ) - match S [em_item* '%%' IncludedItems: item*] + match S [em_item* `%% IncludedItems: item*] IL = concatItems( IncludedItems Rest ) } @@ -85,7 +85,7 @@ item* expandIncludes( ItemList: ref<item*> ) int main() { S: start = parseStart(stdin) - match S [em_item* '%%' ItemList: item*] + match S [em_item* `%% ItemList: item*] expandIncludes( ItemList ) } diff --git a/test/concat2.lm b/test/concat2.lm index cb1a2f00..781c2f2b 100644 --- a/test/concat2.lm +++ b/test/concat2.lm @@ -1,8 +1,7 @@ ##### LM ##### lex - - literal 'type', 'include' + literal `type `include token id /[A-Za-z_][A-Za-z_0-9]*/ ignore /'#' [^\n]* '\n'/ ignore /[ \t\r\n]+/ @@ -22,7 +21,7 @@ def ifn_path | [ifn_path_part] -literal '%%' +literal `%% lex token em_ws /( any - 33..126 )+/ @@ -32,11 +31,11 @@ def em_item [em_ws] def prelude - [em_item* '%%'] + [em_item* `%%] def item - ['include' ifn_path] -| ['type' id] + [`include ifn_path] +| [`type id] def start [prelude item*] @@ -68,7 +67,7 @@ item* expandIncludes( ItemList: ref<item*> ) { for IL: item* in ItemList { if match IL - ['include' FN: ifn_path Rest: item*] + [`include FN: ifn_path Rest: item*] { S: start = parseTxt( " @@ -76,7 +75,7 @@ item* expandIncludes( ItemList: ref<item*> ) " ) - match S [em_item* '%%' IncludedItems: item*] + match S [em_item* `%% IncludedItems: item*] IL = concatItems( IncludedItems Rest ) } @@ -86,7 +85,7 @@ item* expandIncludes( ItemList: ref<item*> ) int main() { S: start = parseStart(stdin) - match S [em_item* '%%' ItemList: item*] + match S [em_item* `%% ItemList: item*] expandIncludes( ItemList ) } diff --git a/test/construct2.lm b/test/construct2.lm index a2549b34..fd60e9d4 100644 --- a/test/construct2.lm +++ b/test/construct2.lm @@ -3,11 +3,12 @@ lex ignore /[ \t\n]+/ token id /[a-z]+/ - literal ',', '.', '*', '(', ')' + literal `, `. `* `( `) end def lang [id*] print( construct lang "a b c" '\n' ) + ##### EXP ##### a b c diff --git a/test/construct3.lm b/test/construct3.lm index bccda0de..8edb0380 100644 --- a/test/construct3.lm +++ b/test/construct3.lm @@ -3,10 +3,10 @@ lex ignore /[ \t\n]+/ token id /[a-z0-9]+/ - literal ',', '.', '*', '(', ')' + literal `, `. `* `( `) end -def bigger ['(' item* ')'] +def bigger [`( item* `)] def item [id] | [bigger] @@ -14,5 +14,6 @@ def lang [item*] B: bigger = construct bigger "( b1 b2 )" print( construct lang "a [B] c" '\n' ) + ##### EXP ##### a ( b1 b2 ) c diff --git a/test/construct4.lm b/test/construct4.lm index 7fac783c..fc675cdb 100644 --- a/test/construct4.lm +++ b/test/construct4.lm @@ -1,32 +1,30 @@ ##### LM ##### lex - literal '-', '=', ';', '{', '}', '<', '>', '*', '->' - literal 'struct', 'string', 'bytes', - 'unsigned', 'long', 'int', - 'list', 'message', 'option' + literal `- `= `; `{ `} `< `> `* `-> + literal `struct `string `bytes + `unsigned `long `int + `list `message `option token id /[A-Za-z_][A-Za-z_0-9]*/ token number /[0-9]+/ ignore /[ \t\r\n]+/ - - literal '' end def type [id] -| ['int'] -| [id '*'] +| [`int] +| [id `*] def decl - [type id ';'] + [type id `;] def struct_def - ['struct' Id: id '{' decl* '}' ';'] + [`struct Id: id `{ decl* `} `;] def message_def ID: int - ['message' id ';'] + [`message id `;] def definition [struct_def] @@ -52,6 +50,7 @@ cons SQ: shared_queue [ ] print( SQ ) + ##### EXP ##### struct Signal diff --git a/test/constructex.lm b/test/constructex.lm index b372e473..3596363c 100644 --- a/test/constructex.lm +++ b/test/constructex.lm @@ -1,18 +1,18 @@ ##### LM ##### lex token id /[a-zA-Z_][a-zA-Z0-9_]*/ - literal '=', '<', '>', '/' + literal `= `< `> `/ ignore /[ \t\n\r\v]+/ end def attr - [id '=' id] + [id `= id] def open_tag - ['<' id attr* '>'] + [`< id attr* `>] def close_tag - ['<' '/' id '>'] + [`< `/ id `>] def tag [open_tag item* close_tag] diff --git a/test/context1.lm b/test/context1.lm index c65525e7..28320450 100644 --- a/test/context1.lm +++ b/test/context1.lm @@ -1,4 +1,5 @@ ##### LM ##### + context ctx i: int j: int @@ -6,7 +7,7 @@ context ctx lex ignore /space+/ - literal '*', '(', ')' + literal `* `( `) token id /[a-zA-Z_]+/ end @@ -15,7 +16,7 @@ context ctx def item [id] | [foo] - | ['(' item* ')'] + | [`( item* `)] { i = 0 j = i + 1 diff --git a/test/context2.lm b/test/context2.lm index e0c59efa..e04354a8 100644 --- a/test/context2.lm +++ b/test/context2.lm @@ -8,7 +8,7 @@ context ruby_here ignore /[ \t\n]+/ token id /ident_pattern/ token number /number_pattern/ - literal '<<', '*', ',', '(', ')', '!' + literal `<< `* `, `( `) `! end HereId: str @@ -59,7 +59,7 @@ context ruby_here [here_line* here_close_id] def heredoc - ['<<' here_id] + [`<< here_id] def primary [id] @@ -70,10 +70,10 @@ context ruby_here [primary arglist_more*] def arglist_more - [',' primary] + [`, primary] def call - [id '(' arglist? ')'] + [id `( arglist? `)] def statement [primary] @@ -82,7 +82,7 @@ context ruby_here token foobar /any+/ def item - [statement '!'] + [statement `!] | [foobar] def start diff --git a/test/context3.lm b/test/context3.lm index b703e138..f9908378 100644 --- a/test/context3.lm +++ b/test/context3.lm @@ -7,7 +7,7 @@ context ctx lex ignore /space+/ - literal '*', '(', ')' + literal `* `( `) token id /[a-zA-Z_]+/ end @@ -21,7 +21,7 @@ context ctx def item [id] | [foo] - | ['(' item* ')'] + | [`( item* `)] { i = 0 f() diff --git a/test/counting3.lm b/test/counting3.lm index 64c26042..027f4565 100644 --- a/test/counting3.lm +++ b/test/counting3.lm @@ -16,7 +16,7 @@ context counting # Ignore whitespace. ignore /rl_ws/ - literal ';' + literal `; # Tokens. token id /rl_id/ diff --git a/test/counting4.lm b/test/counting4.lm index 2fc863f1..ef9f87fe 100644 --- a/test/counting4.lm +++ b/test/counting4.lm @@ -16,7 +16,7 @@ context counting # Ignore whitespace. ignore /rl_ws/ - literal ';' + literal `; # Tokens. token id /rl_id/ diff --git a/test/exit4.lm b/test/exit4.lm index f5306853..bed57922 100644 --- a/test/exit4.lm +++ b/test/exit4.lm @@ -25,16 +25,16 @@ rl d_literal namespace srlex lex ignore /[\t\n ]+/ - literal '::', ';', ')' + literal `:: `; `) token word /[a-zA-Z_][a-zA-Z0-9_]*/ end end namespace c_inline lex - literal 'fpc', 'fc', 'fcurs', 'ftargs', - 'fentry', 'fhold', 'fexec', 'fgoto', 'fnext', - 'fcall', 'fret', 'fbreak' + literal `fpc `fc `fcurs `ftargs + `fentry `fhold `fexec `fgoto `fnext + `fcall `fret `fbreak token ident /ident/ token number /digit+/ @@ -49,7 +49,7 @@ namespace c_inline token whitespace / ( [ \t] | NL )+ / - literal '{', '}', '::', '*', ',', '(', ')', ';' + literal `{ `} `:: `* `, `( `) `; token c_any / any / end @@ -72,25 +72,25 @@ namespace c_inline | [c_any] def expr_symbol - [','] | ['('] | [')'] | ['*'] | ['::'] + [`,] | [`(] | [`)] | [`*] | [`::] def expr_interpret - ['fpc'] :Fpc - | ['fc'] :Fc - | ['fcurs'] :Fcurs - | ['ftargs'] :Ftargs - | ['fentry' '(' state_ref srlex::')'] :Fentry + [`fpc] :Fpc + | [`fc] :Fc + | [`fcurs] :Fcurs + | [`ftargs] :Ftargs + | [`fentry `( state_ref srlex::`)] :Fentry def state_ref [opt_name_sep state_ref_names] def opt_name_sep - [srlex::'::'] :ColonColon + [srlex::`::] :ColonColon | [] :Empty # List of names separated by :: def state_ref_names - [state_ref_names srlex::'::' srlex::word] :Rec + [state_ref_names srlex::`:: srlex::word] :Rec | [srlex::word] :Base def inline_block @@ -100,23 +100,23 @@ namespace c_inline [expr_any] :ExprAny | [block_symbol] :BlockSymbol | [block_interpret] :BlockInterpret - | ['{' inline_block '}'] :RecBlock + | [`{ inline_block `}] :RecBlock def block_symbol - [','] | [';'] | ['('] | [')'] | ['*'] | ['::'] + [`,] | [`;] | [`(] | [`)] | [`*] | [`::] def block_interpret [expr_interpret] :ExprInterpret - | ['fhold' whitespace? ';'] :Fhold - | ['fgoto' whitespace? '*' inline_expr ';'] :FgotoExpr - | ['fnext' whitespace? '*' inline_expr ';'] :FnextExpr - | ['fcall' whitespace? '*' inline_expr ';'] :FcallExpr - | ['fexec' inline_expr ';'] :Fexec - | ['fgoto' state_ref srlex::';'] :FgotoSr - | ['fnext' state_ref srlex::';'] :FnextSr - | ['fcall' state_ref srlex::';'] :FcallSr - | ['fret' ';'] :Fret - | ['fbreak' ';'] :Fbreak + | [`fhold whitespace? `;] :Fhold + | [`fgoto whitespace? `* inline_expr `;] :FgotoExpr + | [`fnext whitespace? `* inline_expr `;] :FnextExpr + | [`fcall whitespace? `* inline_expr `;] :FcallExpr + | [`fexec inline_expr `;] :Fexec + | [`fgoto state_ref srlex::`;] :FgotoSr + | [`fnext state_ref srlex::`;] :FnextSr + | [`fcall state_ref srlex::`;] :FcallSr + | [`fret `;] :Fret + | [`fbreak `;] :Fbreak end namespace ragel @@ -124,29 +124,29 @@ namespace ragel ignore /[\t\n ]+/ ignore /'#' any* :> '\n'/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** - literal '|*', '*|', '=>' + literal `|* `*| `=> - literal '@', '>', '<', '%', '$' - literal 'from', 'to', 'eof', 'lerr', 'err' - literal 'when', 'inwhen', 'outwhen', '>?', '$?', '%?' + literal `@ `> `< `% `$ + literal `from `to `eof `lerr `err + literal `when `inwhen `outwhen `>? `$? `%? - literal ':=', '=', ';', '..', '::' + literal `:= `= `; `.. `:: - literal '>~', '$~', '%~', '<~', '@~', '<>~' - literal '>*', '$*', '%*', '<*', '@*', '<>*' - literal '>/', '$/', '%/', '</', '@/', '<>/' - literal '>!', '$!', '%!', '<!', '@!', '<>!' - literal '>^', '$^', '%^', '<^', '@^', '<>^' - literal '<>' + literal `>~ `$~ `%~ `<~ `@~ `<>~ + literal `>* `$* `%* `<* `@* `<>* + literal `>/ `$/ `%/ `</ `@/ `<>/ + literal `>! `$! `%! `<! `@! `<>! + literal `>^ `$^ `%^ `<^ `@^ `<>^ + literal `<> - literal 'machine', 'action', 'variable', 'alphtype', - 'access', 'write', 'getkey', 'export', 'import', - 'include', 'prepush', 'postpop' + literal `machine `action `variable `alphtype `import + `access `write `getkey `export `include + `prepush `postpop token string / '"' ( [^"\\] | '\\' any )* '"' 'i'? | @@ -194,17 +194,17 @@ namespace ragel | [action_expr] def join - [join ',' expression] :Rec + [join `, expression] :Rec | [expression] :Base def expression [term expression_op*] def expression_op - ['|' term] :Or - | ['&' term] :And - | ['-' term] :Sub - | ['--' term] :Ssub + [`| term] :Or + | [`& term] :And + | [`- term] :Sub + | [`-- term] :Ssub def term [factor_label term_op_list_short] @@ -216,110 +216,110 @@ namespace ragel def term_op [factor_label] :None - | ['.' factor_label] :Dot - | [':>' factor_label] :ColonLt - | [':>>' factor_label] :ColonLtLt - | ['<:' factor_label] :GtColon + | [`. factor_label] :Dot + | [`:> factor_label] :ColonLt + | [`:>> factor_label] :ColonLtLt + | [`<: factor_label] :GtColon def factor_label - [word ':' factor_label] :Label + [word `: factor_label] :Label | [factor_ep] :Ep def factor_ep - [factor_aug '->' epsilon_target] :Epsilon + [factor_aug `-> epsilon_target] :Epsilon | [factor_aug] :Base def epsilon_target - [epsilon_target '::' word] :Rec + [epsilon_target `:: word] :Rec | [word] :Base def action_expr - ['{' c_inline::inline_expr '}'] + [`{ c_inline::inline_expr `}] def action_block - ['{' c_inline::inline_block '}'] + [`{ c_inline::inline_block `}] def action_ref [word] :Word - | ['(' word ')'] :ParenWord + | [`( word `)] :ParenWord | [action_block] :Block def priority_aug [uint] - | ['+' uint] - | ['-' uint] + | [`+ uint] + | [`- uint] def aug_base - ['@'] :Finish | ['>'] :Enter | ['%'] :Leave | ['$'] :All + [`@] :Finish | [`>] :Enter | [`%] :Leave | [`$] :All def aug_cond - ['>?'] :Start1 | ['$?'] :All1 | ['%?'] :Leave1 - | ['>' 'when'] :Start2 | ['$' 'when'] :All2 | ['%' 'when'] :Leave2 - | ['inwhen'] :Start3 | ['when'] :All3 | ['outwhen'] :Leave3 + [`>?] :Start1 | [`$?] :All1 | [`%?] :Leave1 + | [`> `when] :Start2 | [`$ `when] :All2 | [`% `when] :Leave2 + | [`inwhen] :Start3 | [`when] :All3 | [`outwhen] :Leave3 def aug_to_state - ['>~'] :Start1 | ['<~'] :NotStart1 | ['$~'] :All1 - | ['%~'] :Final1 | ['@~'] :NotFinal1 | ['<>~'] :Middle1 - | ['>' 'to'] :Start2 | ['<' 'to'] :NotStart2 | ['$' 'to'] :All2 - | ['%' 'to'] :Final2 | ['@' 'to'] :NotFinal2 | ['<>' 'to'] :Middle2 + [`>~] :Start1 | [`<~] :NotStart1 | [`$~] :All1 + | [`%~] :Final1 | [`@~] :NotFinal1 | [`<>~] :Middle1 + | [`> `to] :Start2 | [`< `to] :NotStart2 | [`$ `to] :All2 + | [`% `to] :Final2 | [`@ `to] :NotFinal2 | [`<> `to] :Middle2 def aug_from_state - ['>*'] :Start1 | ['<*'] :NotStart1 | ['$*'] :All1 - | ['%*'] :Final1 | ['@*'] :NotFinal1 | ['<>*'] :Middle1 - | ['>' 'from'] :Start2 | ['<' 'from'] :NotStart2 | ['$' 'from'] :All2 - | ['%' 'from'] :Final2 | ['@' 'from'] :NotFinal2 | ['<>' 'from'] :Middle2 + [`>*] :Start1 | [`<*] :NotStart1 | [`$*] :All1 + | [`%*] :Final1 | [`@*] :NotFinal1 | [`<>*] :Middle1 + | [`> `from] :Start2 | [`< `from] :NotStart2 | [`$ `from] :All2 + | [`% `from] :Final2 | [`@ `from] :NotFinal2 | [`<> `from] :Middle2 def aug_eof - ['>/'] :Start1 | ['</'] :NotStart1 | ['$/'] :All1 - | ['%/'] :Final1 | ['@/'] :NotFinal1 | ['<>/'] :Middle1 - | ['>' 'eof'] :Start2 | ['<' 'eof'] :NotStart2 | ['$' 'eof'] :All2 - | ['%' 'eof'] :Final2 | ['@' 'eof'] :NotFinal2 | ['<>' 'eof'] :Middle2 + [`>/] :Start1 | [`</] :NotStart1 | [`$/] :All1 + | [`%/] :Final1 | [`@/] :NotFinal1 | [`<>/] :Middle1 + | [`> `eof] :Start2 | [`< `eof] :NotStart2 | [`$ `eof] :All2 + | [`% `eof] :Final2 | [`@ `eof] :NotFinal2 | [`<> `eof] :Middle2 def aug_gbl_error - ['>!'] :Start1 | ['<!'] :NotStart1 | ['$!'] :All1 - | ['%!'] :Final1 | ['@!'] :NotFinal1 | ['<>!'] :Middle1 - | ['>' 'err'] :Start2 | ['<' 'err'] :NotStart2 | ['$' 'err'] :All2 - | ['%' 'err'] :Final2 | ['@' 'err'] :NotFinal2 | ['<>' 'err'] :Middle2 + [`>!] :Start1 | [`<!] :NotStart1 | [`$!] :All1 + | [`%!] :Final1 | [`@!] :NotFinal1 | [`<>!] :Middle1 + | [`> `err] :Start2 | [`< `err] :NotStart2 | [`$ `err] :All2 + | [`% `err] :Final2 | [`@ `err] :NotFinal2 | [`<> `err] :Middle2 def aug_local_error - ['>^'] :Start1 | ['<^'] :NotStart1 | ['$^'] :All1 - | ['%^'] :Final1 | ['@^'] :NotFinal1 | ['<>^'] :Middle1 - | ['>' 'lerr'] :Start2 | ['<' 'lerr'] :NotStart2 | ['$' 'lerr'] :All2 - | ['%' 'lerr'] :Final2 | ['@' 'lerr'] :NotFinal2 | ['<>' 'lerr'] :Middle2 + [`>^] :Start1 | [`<^] :NotStart1 | [`$^] :All1 + | [`%^] :Final1 | [`@^] :NotFinal1 | [`<>^] :Middle1 + | [`> `lerr] :Start2 | [`< `lerr] :NotStart2 | [`$ `lerr] :All2 + | [`% `lerr] :Final2 | [`@ `lerr] :NotFinal2 | [`<> `lerr] :Middle2 def factor_aug [factor_aug aug_base action_ref] :ActionRef | [factor_aug aug_base priority_aug] :PriorEmbed - | [factor_aug aug_base '(' word ',' priority_aug ')'] :NamedPriorEmbed + | [factor_aug aug_base `( word `, priority_aug `)] :NamedPriorEmbed | [factor_aug aug_cond action_ref] :CondEmbed - | [factor_aug aug_cond '!' action_ref] :NegCondEmbed + | [factor_aug aug_cond `! action_ref] :NegCondEmbed | [factor_aug aug_to_state action_ref] :ToStateAction | [factor_aug aug_from_state action_ref] :FromStateAction | [factor_aug aug_eof action_ref] :EofAction | [factor_aug aug_gbl_error action_ref] :GblErrorAction | [factor_aug aug_local_error action_ref] :LocalErrorDef - | [factor_aug aug_local_error '(' word ',' action_ref ')'] :LocalErrorName + | [factor_aug aug_local_error `( word `, action_ref `)] :LocalErrorName | [factor_rep] :Base def factor_rep [factor_neg factor_rep_op*] def factor_rep_op - ['*'] :Star - | ['**'] :StarStar - | ['?'] :Optional - | ['+'] :Plus - | ['{' factor_rep_num '}'] :ExactRep - | ['{' ',' factor_rep_num '}'] :MaxRep - | ['{' factor_rep_num ',' '}'] :MinRep - | ['{' LowRep: factor_rep_num ',' HighRep: factor_rep_num '}'] :RangeRep + [`*] :Star + | [`**] :StarStar + | [`?] :Optional + | [`+] :Plus + | [`{ factor_rep_num `}] :ExactRep + | [`{ `, factor_rep_num `}] :MaxRep + | [`{ factor_rep_num `, `}] :MinRep + | [`{ LowRep: factor_rep_num `, HighRep: factor_rep_num `}] :RangeRep def factor_rep_num [uint] def factor_neg - ['!' factor_neg] :Bang - | ['^' factor_neg] :Caret + [`! factor_neg] :Bang + | [`^ factor_neg] :Caret | [factor] :Base def factor @@ -329,8 +329,8 @@ namespace ragel | [lex_sqopen_pos reg_or_data re_or_sqclose] :PosOrBlock | [lex_sqopen_neg reg_or_data re_or_sqclose] :NegOrBlock | [lex_regex_open regex re_close] :Regex - | [RL1: range_lit '..' RL2: range_lit] :Range - | ['(' join ')'] :Join + | [RL1: range_lit `.. RL2: range_lit] :Range + | [`( join `)] :Join def regex [reg_item_rep*] @@ -359,11 +359,11 @@ namespace ragel def alphabet_num [uint] - | ['-' uint] + | [`- uint] | [hex] def lm_act - ['=>' action_ref] :ActionRef + [`=> action_ref] :ActionRef | [action_block] :ActionBlock def opt_lm_act @@ -371,7 +371,7 @@ namespace ragel | [] def lm_stmt - [join opt_lm_act ';'] :LmStmt commit + [join opt_lm_act `;] :LmStmt commit | [assignment] :Assignment | [action_spec] :ActionSpec @@ -381,16 +381,16 @@ namespace ragel def lm [join] :Join - | ['|*' lm_stmt_list '*|'] :Lm + | [`|* lm_stmt_list `*|] :Lm def action_spec - ['action' word action_block] commit + [`action word action_block] commit def assignment - [opt_export word '=' join ';'] commit + [opt_export word `= join `;] commit def instantiation - [opt_export word ':=' lm ';'] commit + [opt_export word `:= lm `;] commit def alphtype_type [W1: word] :One @@ -402,26 +402,26 @@ namespace ragel | [word string] def opt_export - ['export'] :Export + [`export] :Export | [] :Base def machine_name - ['machine' word ';'] + [`machine word `;] def statement [machine_name] :MachineName commit | [assignment] :Assignment | [instantiation] :Instantiation | [action_spec] :ActionSpec - | ['prepush' action_block] :PrePushSpec commit - | ['postpop' action_block] :PostPopSpec commit - | ['variable' variable_name inline_expr_reparse] :Variable commit - | ['alphtype' alphtype_type ';'] :AlphType commit - | ['access' inline_expr_reparse] :Access commit - | ['write' Cmd: word ArgList: word* ';'] :Write commit - | ['getkey' inline_expr_reparse] :GetKey commit - | ['import' string ';'] :Import commit - | ['include' include_spec ';'] :Include commit + | [`prepush action_block] :PrePushSpec commit + | [`postpop action_block] :PostPopSpec commit + | [`variable variable_name inline_expr_reparse] :Variable commit + | [`alphtype alphtype_type `;] :AlphType commit + | [`access inline_expr_reparse] :Access commit + | [`write Cmd: word ArgList: word* `;] :Write commit + | [`getkey inline_expr_reparse] :GetKey commit + | [`import string `;] :Import commit + | [`include include_spec `;] :Include commit def ragel_start [statement*] @@ -429,7 +429,7 @@ end namespace c_host lex - literal '%%{', '}%%' + literal `%%{, `}%% token slr /'%%' [^{] [^\n]* '\n'/ { @@ -479,19 +479,19 @@ namespace c_host | [c_any] def section - ['%%{' ragel::ragel_start '}%%'] :MultiLine + [`%%{ ragel::ragel_start `}%%] :MultiLine | [tok] :Tok end lex - literal '%%{', '}%%' + literal `%%{ `}%% - literal 'int', 'bool', 'const', 'char', 'ptr', 'printi', - 'printb', 'prints', 'print_token', - 'fwrite', 'first_token_char', 'var', 'byte' + literal `int `bool `const `char `ptr `printi + `printb `prints `print_token + `fwrite `first_token_char `var `byte - literal ';', '<', '>', '(', ')', '[', ']', '=', '*', '!' + literal `; `< `> `( `) `[ `] `= `* `! ignore / ( [ \t] | NL )+ / @@ -557,7 +557,7 @@ def output def tok [tk_ident] -| [tk_ident '[' tok ']'] +| [tk_ident `[ tok `]] | [tk_number] | [tk_hex_number] | [input] @@ -565,46 +565,46 @@ def tok | [tk_cpp_comment] | [c_comment] | [string] -| ['<' type '>' '(' tok* ')'] -| ['(' type ')' '(' tok* ')'] -| ['(' tok* ')'] -| ['printi' tok ';'] -| ['printb' tok ';'] -| ['prints' tok ';'] -| ['print_token' ';'] -| ['first_token_char'] -| [';'] -| ['<'] -| ['>'] -| ['['] -| [']'] -| ['='] -| ['!'] -| ['*'] +| [`< type `> `( tok* `)] +| [`( type `) `( tok* `)] +| [`( tok* `)] +| [`printi tok `;] +| [`printb tok `;] +| [`prints tok `;] +| [`print_token `;] +| [`first_token_char] +| [`;] +| [`<] +| [`>] +| [`[] +| [`]] +| [`=] +| [`!] +| [`*] | [indep_any] def section_multiline - ['%%{' ragel::ragel_start '}%%'] + [`%%{ ragel::ragel_start `}%%] def type - ['int'] -| ['bool'] -| ['char'] -| ['char' '*'] -| ['const' '(' 'char' ')' '*'] -| ['ptr'] -| ['byte'] + [`int] +| [`bool] +| [`char] +| [`char `*] +| [`const `( `char `) `*] +| [`ptr] +| [`byte] def opt_arr - ['[' tok ']'] + [`[ tok `]] | [] def var_decl - [type tk_ident opt_arr ';'] -| ['var' tk_ident opt_arr type] + [type tk_ident opt_arr `;] +| [`var tk_ident opt_arr type] def expr_stmt - [tk_ident '=' tok* ';'] + [tk_ident `= tok* `;] def stmt [var_decl] @@ -620,12 +620,12 @@ def start namespace c lex - literal '%%{', '}%%' + literal `%%{, `}%% - literal 'int', 'bool', 'const', 'char', 'ptr', - 'printf', 'fwrite', 'var', 'byte' + literal `int `bool `const `char `ptr + `printf `fwrite `var `byte - literal ';', '<', '>', '(', ')', '[', ']', '=', '*', '!' + literal `; `< `> `( `) `[ `] `= `* `! ignore / ( [ \t] | NL )+ / @@ -641,23 +641,23 @@ namespace c def tok [tk_ident] - | [tk_ident '[' tok ']'] + | [tk_ident `[ tok `]] | [tk_number] | [tk_hex_number] | [string] - | ['<' type '>' '(' tok* ')'] - | ['(' type ')' '(' tok* ')'] - | ['(' tok* ')'] - | ['printf' '(' tok* ')' ';'] - | ['fwrite' '(' tok* ')' ';'] - | [';'] - | ['<'] - | ['>'] - | ['['] - | [']'] - | ['='] - | ['!'] - | ['*'] + | [`< type `> `( tok* `)] + | [`( type `) `( tok* `)] + | [`( tok* `)] + | [`printf `( tok* `) `;] + | [`fwrite `( tok* `) `;] + | [`;] + | [`<] + | [`>] + | [`[] + | [`]] + | [`=] + | [`!] + | [`*] | [indep_any] end diff --git a/test/exit5.lm b/test/exit5.lm index cd43f71d..f80971f6 100644 --- a/test/exit5.lm +++ b/test/exit5.lm @@ -25,16 +25,16 @@ rl d_literal namespace srlex lex ignore /[\t\n ]+/ - literal '::', ';', ')' + literal `:: `; `) token word /[a-zA-Z_][a-zA-Z0-9_]*/ end end namespace c_inline lex - literal 'fpc', 'fc', 'fcurs', 'ftargs', - 'fentry', 'fhold', 'fexec', 'fgoto', 'fnext', - 'fcall', 'fret', 'fbreak' + literal `fpc `fc `fcurs `ftargs + `fentry `fhold `fexec `fgoto `fnext + `fcall `fret `fbreak token ident /ident/ token number /digit+/ @@ -49,7 +49,7 @@ namespace c_inline token whitespace / ( [ \t] | NL )+ / - literal '{', '}', '::', '*', ',', '(', ')', ';' + literal `{ `} `:: `* `, `( `) `; token c_any / any / end @@ -72,25 +72,25 @@ namespace c_inline | [c_any] def expr_symbol - [','] | ['('] | [')'] | ['*'] | ['::'] + [`,] | [`(] | [`)] | [`*] | [`::] def expr_interpret - ['fpc'] :Fpc - | ['fc'] :Fc - | ['fcurs'] :Fcurs - | ['ftargs'] :Ftargs - | ['fentry' '(' state_ref srlex::')'] :Fentry + [`fpc] :Fpc + | [`fc] :Fc + | [`fcurs] :Fcurs + | [`ftargs] :Ftargs + | [`fentry `( state_ref srlex::`)] :Fentry def state_ref [opt_name_sep state_ref_names] def opt_name_sep - [srlex::'::'] :ColonColon + [srlex::`::] :ColonColon | [] :Empty # List of names separated by :: def state_ref_names - [state_ref_names srlex::'::' srlex::word] :Rec + [state_ref_names srlex::`:: srlex::word] :Rec | [srlex::word] :Base def inline_block @@ -100,23 +100,23 @@ namespace c_inline [expr_any] :ExprAny | [block_symbol] :BlockSymbol | [block_interpret] :BlockInterpret - | ['{' inline_block '}'] :RecBlock + | [`{ inline_block `}] :RecBlock def block_symbol - [','] | [';'] | ['('] | [')'] | ['*'] | ['::'] + [`,] | [`;] | [`(] | [`)] | [`*] | [`::] def block_interpret [expr_interpret] :ExprInterpret - | ['fhold' whitespace? ';'] :Fhold - | ['fgoto' whitespace? '*' inline_expr ';'] :FgotoExpr - | ['fnext' whitespace? '*' inline_expr ';'] :FnextExpr - | ['fcall' whitespace? '*' inline_expr ';'] :FcallExpr - | ['fexec' inline_expr ';'] :Fexec - | ['fgoto' state_ref srlex::';'] :FgotoSr - | ['fnext' state_ref srlex::';'] :FnextSr - | ['fcall' state_ref srlex::';'] :FcallSr - | ['fret' ';'] :Fret - | ['fbreak' ';'] :Fbreak + | [`fhold whitespace? `;] :Fhold + | [`fgoto whitespace? `* inline_expr `;] :FgotoExpr + | [`fnext whitespace? `* inline_expr `;] :FnextExpr + | [`fcall whitespace? `* inline_expr `;] :FcallExpr + | [`fexec inline_expr `;] :Fexec + | [`fgoto state_ref srlex::`;] :FgotoSr + | [`fnext state_ref srlex::`;] :FnextSr + | [`fcall state_ref srlex::`;] :FcallSr + | [`fret `;] :Fret + | [`fbreak `;] :Fbreak end namespace ragel @@ -124,29 +124,29 @@ namespace ragel ignore /[\t\n ]+/ ignore /'#' any* :> '\n'/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** - literal '|*', '*|', '=>' + literal `|* `*| `=> - literal '@', '>', '<', '%', '$' - literal 'from', 'to', 'eof', 'lerr', 'err' - literal 'when', 'inwhen', 'outwhen', '>?', '$?', '%?' + literal `@ `> `< `% `$ + literal `from `to `eof `lerr `err + literal `when `inwhen `outwhen `>? `$? `%? - literal ':=', '=', ';', '..', '::' + literal `:= `= `; `.. `:: - literal '>~', '$~', '%~', '<~', '@~', '<>~' - literal '>*', '$*', '%*', '<*', '@*', '<>*' - literal '>/', '$/', '%/', '</', '@/', '<>/' - literal '>!', '$!', '%!', '<!', '@!', '<>!' - literal '>^', '$^', '%^', '<^', '@^', '<>^' - literal '<>' + literal `>~ `$~ `%~ `<~ `@~ `<>~ + literal `>* `$* `%* `<* `@* `<>* + literal `>/ `$/ `%/ `</ `@/ `<>/ + literal `>! `$! `%! `<! `@! `<>! + literal `>^ `$^ `%^ `<^ `@^ `<>^ + literal `<> - literal 'machine', 'action', 'variable', 'alphtype', - 'access', 'write', 'getkey', 'export', 'import', - 'include', 'prepush', 'postpop' + literal `machine `action `variable `alphtype `import + `access `write `getkey `export `include + `prepush `postpop token string / '"' ( [^"\\] | '\\' any )* '"' 'i'? | @@ -194,17 +194,17 @@ namespace ragel | [action_expr] def join - [join ',' expression] :Rec + [join `, expression] :Rec | [expression] :Base def expression [term expression_op*] def expression_op - ['|' term] :Or - | ['&' term] :And - | ['-' term] :Sub - | ['--' term] :Ssub + [`| term] :Or + | [`& term] :And + | [`- term] :Sub + | [`-- term] :Ssub def term [factor_label term_op_list_short] @@ -216,110 +216,110 @@ namespace ragel def term_op [factor_label] :None - | ['.' factor_label] :Dot - | [':>' factor_label] :ColonLt - | [':>>' factor_label] :ColonLtLt - | ['<:' factor_label] :GtColon + | [`. factor_label] :Dot + | [`:> factor_label] :ColonLt + | [`:>> factor_label] :ColonLtLt + | [`<: factor_label] :GtColon def factor_label - [word ':' factor_label] :Label + [word `: factor_label] :Label | [factor_ep] :Ep def factor_ep - [factor_aug '->' epsilon_target] :Epsilon + [factor_aug `-> epsilon_target] :Epsilon | [factor_aug] :Base def epsilon_target - [epsilon_target '::' word] :Rec + [epsilon_target `:: word] :Rec | [word] :Base def action_expr - ['{' c_inline::inline_expr '}'] + [`{ c_inline::inline_expr `}] def action_block - ['{' c_inline::inline_block '}'] + [`{ c_inline::inline_block `}] def action_ref [word] :Word - | ['(' word ')'] :ParenWord + | [`( word `)] :ParenWord | [action_block] :Block def priority_aug [uint] - | ['+' uint] - | ['-' uint] + | [`+ uint] + | [`- uint] def aug_base - ['@'] :Finish | ['>'] :Enter | ['%'] :Leave | ['$'] :All + [`@] :Finish | [`>] :Enter | [`%] :Leave | [`$] :All def aug_cond - ['>?'] :Start1 | ['$?'] :All1 | ['%?'] :Leave1 - | ['>' 'when'] :Start2 | ['$' 'when'] :All2 | ['%' 'when'] :Leave2 - | ['inwhen'] :Start3 | ['when'] :All3 | ['outwhen'] :Leave3 + [`>?] :Start1 | [`$?] :All1 | [`%?] :Leave1 + | [`> `when] :Start2 | [`$ `when] :All2 | [`% `when] :Leave2 + | [`inwhen] :Start3 | [`when] :All3 | [`outwhen] :Leave3 def aug_to_state - ['>~'] :Start1 | ['<~'] :NotStart1 | ['$~'] :All1 - | ['%~'] :Final1 | ['@~'] :NotFinal1 | ['<>~'] :Middle1 - | ['>' 'to'] :Start2 | ['<' 'to'] :NotStart2 | ['$' 'to'] :All2 - | ['%' 'to'] :Final2 | ['@' 'to'] :NotFinal2 | ['<>' 'to'] :Middle2 + [`>~] :Start1 | [`<~] :NotStart1 | [`$~] :All1 + | [`%~] :Final1 | [`@~] :NotFinal1 | [`<>~] :Middle1 + | [`> `to] :Start2 | [`< `to] :NotStart2 | [`$ `to] :All2 + | [`% `to] :Final2 | [`@ `to] :NotFinal2 | [`<> `to] :Middle2 def aug_from_state - ['>*'] :Start1 | ['<*'] :NotStart1 | ['$*'] :All1 - | ['%*'] :Final1 | ['@*'] :NotFinal1 | ['<>*'] :Middle1 - | ['>' 'from'] :Start2 | ['<' 'from'] :NotStart2 | ['$' 'from'] :All2 - | ['%' 'from'] :Final2 | ['@' 'from'] :NotFinal2 | ['<>' 'from'] :Middle2 + [`>*] :Start1 | [`<*] :NotStart1 | [`$*] :All1 + | [`%*] :Final1 | [`@*] :NotFinal1 | [`<>*] :Middle1 + | [`> `from] :Start2 | [`< `from] :NotStart2 | [`$ `from] :All2 + | [`% `from] :Final2 | [`@ `from] :NotFinal2 | [`<> `from] :Middle2 def aug_eof - ['>/'] :Start1 | ['</'] :NotStart1 | ['$/'] :All1 - | ['%/'] :Final1 | ['@/'] :NotFinal1 | ['<>/'] :Middle1 - | ['>' 'eof'] :Start2 | ['<' 'eof'] :NotStart2 | ['$' 'eof'] :All2 - | ['%' 'eof'] :Final2 | ['@' 'eof'] :NotFinal2 | ['<>' 'eof'] :Middle2 + [`>/] :Start1 | [`</] :NotStart1 | [`$/] :All1 + | [`%/] :Final1 | [`@/] :NotFinal1 | [`<>/] :Middle1 + | [`> `eof] :Start2 | [`< `eof] :NotStart2 | [`$ `eof] :All2 + | [`% `eof] :Final2 | [`@ `eof] :NotFinal2 | [`<> `eof] :Middle2 def aug_gbl_error - ['>!'] :Start1 | ['<!'] :NotStart1 | ['$!'] :All1 - | ['%!'] :Final1 | ['@!'] :NotFinal1 | ['<>!'] :Middle1 - | ['>' 'err'] :Start2 | ['<' 'err'] :NotStart2 | ['$' 'err'] :All2 - | ['%' 'err'] :Final2 | ['@' 'err'] :NotFinal2 | ['<>' 'err'] :Middle2 + [`>!] :Start1 | [`<!] :NotStart1 | [`$!] :All1 + | [`%!] :Final1 | [`@!] :NotFinal1 | [`<>!] :Middle1 + | [`> `err] :Start2 | [`< `err] :NotStart2 | [`$ `err] :All2 + | [`% `err] :Final2 | [`@ `err] :NotFinal2 | [`<> `err] :Middle2 def aug_local_error - ['>^'] :Start1 | ['<^'] :NotStart1 | ['$^'] :All1 - | ['%^'] :Final1 | ['@^'] :NotFinal1 | ['<>^'] :Middle1 - | ['>' 'lerr'] :Start2 | ['<' 'lerr'] :NotStart2 | ['$' 'lerr'] :All2 - | ['%' 'lerr'] :Final2 | ['@' 'lerr'] :NotFinal2 | ['<>' 'lerr'] :Middle2 + [`>^] :Start1 | [`<^] :NotStart1 | [`$^] :All1 + | [`%^] :Final1 | [`@^] :NotFinal1 | [`<>^] :Middle1 + | [`> `lerr] :Start2 | [`< `lerr] :NotStart2 | [`$ `lerr] :All2 + | [`% `lerr] :Final2 | [`@ `lerr] :NotFinal2 | [`<> `lerr] :Middle2 def factor_aug [factor_aug aug_base action_ref] :ActionRef | [factor_aug aug_base priority_aug] :PriorEmbed - | [factor_aug aug_base '(' word ',' priority_aug ')'] :NamedPriorEmbed + | [factor_aug aug_base `( word `, priority_aug `)] :NamedPriorEmbed | [factor_aug aug_cond action_ref] :CondEmbed - | [factor_aug aug_cond '!' action_ref] :NegCondEmbed + | [factor_aug aug_cond `! action_ref] :NegCondEmbed | [factor_aug aug_to_state action_ref] :ToStateAction | [factor_aug aug_from_state action_ref] :FromStateAction | [factor_aug aug_eof action_ref] :EofAction | [factor_aug aug_gbl_error action_ref] :GblErrorAction | [factor_aug aug_local_error action_ref] :LocalErrorDef - | [factor_aug aug_local_error '(' word ',' action_ref ')'] :LocalErrorName + | [factor_aug aug_local_error `( word `, action_ref `)] :LocalErrorName | [factor_rep] :Base def factor_rep [factor_neg factor_rep_op*] def factor_rep_op - ['*'] :Star - | ['**'] :StarStar - | ['?'] :Optional - | ['+'] :Plus - | ['{' factor_rep_num '}'] :ExactRep - | ['{' ',' factor_rep_num '}'] :MaxRep - | ['{' factor_rep_num ',' '}'] :MinRep - | ['{' LowRep: factor_rep_num ',' HighRep: factor_rep_num '}'] :RangeRep + [`*] :Star + | [`**] :StarStar + | [`?] :Optional + | [`+] :Plus + | [`{ factor_rep_num `}] :ExactRep + | [`{ `, factor_rep_num `}] :MaxRep + | [`{ factor_rep_num `, `}] :MinRep + | [`{ LowRep: factor_rep_num `, HighRep: factor_rep_num `}] :RangeRep def factor_rep_num [uint] def factor_neg - ['!' factor_neg] :Bang - | ['^' factor_neg] :Caret + [`! factor_neg] :Bang + | [`^ factor_neg] :Caret | [factor] :Base def factor @@ -329,8 +329,8 @@ namespace ragel | [lex_sqopen_pos reg_or_data re_or_sqclose] :PosOrBlock | [lex_sqopen_neg reg_or_data re_or_sqclose] :NegOrBlock | [lex_regex_open regex re_close] :Regex - | [RL1: range_lit '..' RL2: range_lit] :Range - | ['(' join ')'] :Join + | [RL1: range_lit `.. RL2: range_lit] :Range + | [`( join `)] :Join def regex [reg_item_rep*] @@ -359,11 +359,11 @@ namespace ragel def alphabet_num [uint] - | ['-' uint] + | [`- uint] | [hex] def lm_act - ['=>' action_ref] :ActionRef + [`=> action_ref] :ActionRef | [action_block] :ActionBlock def opt_lm_act @@ -371,7 +371,7 @@ namespace ragel | [] def lm_stmt - [join opt_lm_act ';'] :LmStmt commit + [join opt_lm_act `;] :LmStmt commit | [assignment] :Assignment | [action_spec] :ActionSpec @@ -381,16 +381,16 @@ namespace ragel def lm [join] :Join - | ['|*' lm_stmt_list '*|'] :Lm + | [`|* lm_stmt_list `*|] :Lm def action_spec - ['action' word action_block] commit + [`action word action_block] commit def assignment - [opt_export word '=' join ';'] commit + [opt_export word `= join `;] commit def instantiation - [opt_export word ':=' lm ';'] commit + [opt_export word `:= lm `;] commit def alphtype_type [W1: word] :One @@ -402,26 +402,26 @@ namespace ragel | [word string] def opt_export - ['export'] :Export + [`export] :Export | [] :Base def machine_name - ['machine' word ';'] + [`machine word `;] def statement [machine_name] :MachineName commit | [assignment] :Assignment | [instantiation] :Instantiation | [action_spec] :ActionSpec - | ['prepush' action_block] :PrePushSpec commit - | ['postpop' action_block] :PostPopSpec commit - | ['variable' variable_name inline_expr_reparse] :Variable commit - | ['alphtype' alphtype_type ';'] :AlphType commit - | ['access' inline_expr_reparse] :Access commit - | ['write' Cmd: word ArgList: word* ';'] :Write commit - | ['getkey' inline_expr_reparse] :GetKey commit - | ['import' string ';'] :Import commit - | ['include' include_spec ';'] :Include commit + | [`prepush action_block] :PrePushSpec commit + | [`postpop action_block] :PostPopSpec commit + | [`variable variable_name inline_expr_reparse] :Variable commit + | [`alphtype alphtype_type `;] :AlphType commit + | [`access inline_expr_reparse] :Access commit + | [`write Cmd: word ArgList: word* `;] :Write commit + | [`getkey inline_expr_reparse] :GetKey commit + | [`import string `;] :Import commit + | [`include include_spec `;] :Include commit def ragel_start [statement*] @@ -429,7 +429,7 @@ end namespace c_host lex - literal '%%{', '}%%' + literal `%%{, `}%% token slr /'%%' [^{] [^\n]* '\n'/ { @@ -479,19 +479,19 @@ namespace c_host | [c_any] def section - ['%%{' ragel::ragel_start '}%%'] :MultiLine + [`%%{ ragel::ragel_start `}%%] :MultiLine | [tok] :Tok end lex - literal '%%{', '}%%' + literal `%%{ `}%% - literal 'int', 'bool', 'const', 'char', 'ptr', 'printi', - 'printb', 'prints', 'print_token', - 'fwrite', 'first_token_char', 'var', 'byte' + literal `int `bool `const `char `ptr `printi + `printb `prints `print_token + `fwrite `first_token_char `var `byte - literal ';', '<', '>', '(', ')', '[', ']', '=', '*', '!' + literal `; `< `> `( `) `[ `] `= `* `! ignore / ( [ \t] | NL )+ / @@ -557,7 +557,7 @@ def output def tok [tk_ident] -| [tk_ident '[' tok ']'] +| [tk_ident `[ tok `]] | [tk_number] | [tk_hex_number] | [input] @@ -565,46 +565,46 @@ def tok | [tk_cpp_comment] | [c_comment] | [string] -| ['<' type '>' '(' tok* ')'] -| ['(' type ')' '(' tok* ')'] -| ['(' tok* ')'] -| ['printi' tok ';'] -| ['printb' tok ';'] -| ['prints' tok ';'] -| ['print_token' ';'] -| ['first_token_char'] -| [';'] -| ['<'] -| ['>'] -| ['['] -| [']'] -| ['='] -| ['!'] -| ['*'] +| [`< type `> `( tok* `)] +| [`( type `) `( tok* `)] +| [`( tok* `)] +| [`printi tok `;] +| [`printb tok `;] +| [`prints tok `;] +| [`print_token `;] +| [`first_token_char] +| [`;] +| [`<] +| [`>] +| [`[] +| [`]] +| [`=] +| [`!] +| [`*] | [indep_any] def section_multiline - ['%%{' ragel::ragel_start '}%%'] + [`%%{ ragel::ragel_start `}%%] def type - ['int'] -| ['bool'] -| ['char'] -| ['char' '*'] -| ['const' '(' 'char' ')' '*'] -| ['ptr'] -| ['byte'] + [`int] +| [`bool] +| [`char] +| [`char `*] +| [`const `( `char `) `*] +| [`ptr] +| [`byte] def opt_arr - ['[' tok ']'] + [`[ tok `]] | [] def var_decl - [type tk_ident opt_arr ';'] -| ['var' tk_ident opt_arr type] + [type tk_ident opt_arr `;] +| [`var tk_ident opt_arr type] def expr_stmt - [tk_ident '=' tok* ';'] + [tk_ident `= tok* `;] def stmt [var_decl] @@ -620,12 +620,12 @@ def start namespace c lex - literal '%%{', '}%%' + literal `%%{, `}%% - literal 'int', 'bool', 'const', 'char', 'ptr', - 'printf', 'fwrite', 'var', 'byte' + literal `int `bool `const `char `ptr + `printf `fwrite `var `byte - literal ';', '<', '>', '(', ')', '[', ']', '=', '*', '!' + literal `; `< `> `( `) `[ `] `= `* `! ignore / ( [ \t] | NL )+ / @@ -641,23 +641,23 @@ namespace c def tok [tk_ident] - | [tk_ident '[' tok ']'] + | [tk_ident `[ tok `]] | [tk_number] | [tk_hex_number] | [string] - | ['<' type '>' '(' tok* ')'] - | ['(' type ')' '(' tok* ')'] - | ['(' tok* ')'] - | ['printf' '(' tok* ')' ';'] - | ['fwrite' '(' tok* ')' ';'] - | [';'] - | ['<'] - | ['>'] - | ['['] - | [']'] - | ['='] - | ['!'] - | ['*'] + | [`< type `> `( tok* `)] + | [`( type `) `( tok* `)] + | [`( tok* `)] + | [`printf `( tok* `) `;] + | [`fwrite `( tok* `) `;] + | [`;] + | [`<] + | [`>] + | [`[] + | [`]] + | [`=] + | [`!] + | [`*] | [indep_any] end diff --git a/test/exit6.lm b/test/exit6.lm index 427fd842..20e26421 100644 --- a/test/exit6.lm +++ b/test/exit6.lm @@ -25,16 +25,16 @@ rl d_literal namespace srlex lex ignore /[\t\n ]+/ - literal '::', ';', ')' + literal `:: `; `) token word /[a-zA-Z_][a-zA-Z0-9_]*/ end end namespace c_inline lex - literal 'fpc', 'fc', 'fcurs', 'ftargs', - 'fentry', 'fhold', 'fexec', 'fgoto', 'fnext', - 'fcall', 'fret', 'fbreak' + literal `fpc `fc `fcurs `ftargs + `fentry `fhold `fexec `fgoto `fnext + `fcall `fret `fbreak token ident /ident/ token number /digit+/ @@ -49,7 +49,7 @@ namespace c_inline token whitespace / ( [ \t] | NL )+ / - literal '{', '}', '::', '*', ',', '(', ')', ';' + literal `{ `} `:: `* `, `( `) `; token c_any / any / end @@ -72,25 +72,25 @@ namespace c_inline | [c_any] def expr_symbol - [','] | ['('] | [')'] | ['*'] | ['::'] + [`,] | [`(] | [`)] | [`*] | [`::] def expr_interpret - ['fpc'] :Fpc - | ['fc'] :Fc - | ['fcurs'] :Fcurs - | ['ftargs'] :Ftargs - | ['fentry' '(' state_ref srlex::')'] :Fentry + [`fpc] :Fpc + | [`fc] :Fc + | [`fcurs] :Fcurs + | [`ftargs] :Ftargs + | [`fentry `( state_ref srlex::`)] :Fentry def state_ref [opt_name_sep state_ref_names] def opt_name_sep - [srlex::'::'] :ColonColon + [srlex::`::] :ColonColon | [] :Empty # List of names separated by :: def state_ref_names - [state_ref_names srlex::'::' srlex::word] :Rec + [state_ref_names srlex::`:: srlex::word] :Rec | [srlex::word] :Base def inline_block @@ -100,23 +100,23 @@ namespace c_inline [expr_any] :ExprAny | [block_symbol] :BlockSymbol | [block_interpret] :BlockInterpret - | ['{' inline_block '}'] :RecBlock + | [`{ inline_block `}] :RecBlock def block_symbol - [','] | [';'] | ['('] | [')'] | ['*'] | ['::'] + [`,] | [`;] | [`(] | [`)] | [`*] | [`::] def block_interpret [expr_interpret] :ExprInterpret - | ['fhold' whitespace? ';'] :Fhold - | ['fgoto' whitespace? '*' inline_expr ';'] :FgotoExpr - | ['fnext' whitespace? '*' inline_expr ';'] :FnextExpr - | ['fcall' whitespace? '*' inline_expr ';'] :FcallExpr - | ['fexec' inline_expr ';'] :Fexec - | ['fgoto' state_ref srlex::';'] :FgotoSr - | ['fnext' state_ref srlex::';'] :FnextSr - | ['fcall' state_ref srlex::';'] :FcallSr - | ['fret' ';'] :Fret - | ['fbreak' ';'] :Fbreak + | [`fhold whitespace? `;] :Fhold + | [`fgoto whitespace? `* inline_expr `;] :FgotoExpr + | [`fnext whitespace? `* inline_expr `;] :FnextExpr + | [`fcall whitespace? `* inline_expr `;] :FcallExpr + | [`fexec inline_expr `;] :Fexec + | [`fgoto state_ref srlex::`;] :FgotoSr + | [`fnext state_ref srlex::`;] :FnextSr + | [`fcall state_ref srlex::`;] :FcallSr + | [`fret `;] :Fret + | [`fbreak `;] :Fbreak end namespace ragel @@ -124,29 +124,29 @@ namespace ragel ignore /[\t\n ]+/ ignore /'#' any* :> '\n'/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** - literal '|*', '*|', '=>' + literal `|* `*| `=> - literal '@', '>', '<', '%', '$' - literal 'from', 'to', 'eof', 'lerr', 'err' - literal 'when', 'inwhen', 'outwhen', '>?', '$?', '%?' + literal `@ `> `< `% `$ + literal `from `to `eof `lerr `err + literal `when `inwhen `outwhen `>? `$? `%? - literal ':=', '=', ';', '..', '::' + literal `:= `= `; `.. `:: - literal '>~', '$~', '%~', '<~', '@~', '<>~' - literal '>*', '$*', '%*', '<*', '@*', '<>*' - literal '>/', '$/', '%/', '</', '@/', '<>/' - literal '>!', '$!', '%!', '<!', '@!', '<>!' - literal '>^', '$^', '%^', '<^', '@^', '<>^' - literal '<>' + literal `>~ `$~ `%~ `<~ `@~ `<>~ + literal `>* `$* `%* `<* `@* `<>* + literal `>/ `$/ `%/ `</ `@/ `<>/ + literal `>! `$! `%! `<! `@! `<>! + literal `>^ `$^ `%^ `<^ `@^ `<>^ + literal `<> - literal 'machine', 'action', 'variable', 'alphtype', - 'access', 'write', 'getkey', 'export', 'import', - 'include', 'prepush', 'postpop' + literal `machine `action `variable `alphtype `import + `access `write `getkey `export `include + `prepush `postpop token string / '"' ( [^"\\] | '\\' any )* '"' 'i'? | @@ -194,17 +194,17 @@ namespace ragel | [action_expr] def join - [join ',' expression] :Rec + [join `, expression] :Rec | [expression] :Base def expression [term expression_op*] def expression_op - ['|' term] :Or - | ['&' term] :And - | ['-' term] :Sub - | ['--' term] :Ssub + [`| term] :Or + | [`& term] :And + | [`- term] :Sub + | [`-- term] :Ssub def term [factor_label term_op_list_short] @@ -216,110 +216,110 @@ namespace ragel def term_op [factor_label] :None - | ['.' factor_label] :Dot - | [':>' factor_label] :ColonLt - | [':>>' factor_label] :ColonLtLt - | ['<:' factor_label] :GtColon + | [`. factor_label] :Dot + | [`:> factor_label] :ColonLt + | [`:>> factor_label] :ColonLtLt + | [`<: factor_label] :GtColon def factor_label - [word ':' factor_label] :Label + [word `: factor_label] :Label | [factor_ep] :Ep def factor_ep - [factor_aug '->' epsilon_target] :Epsilon + [factor_aug `-> epsilon_target] :Epsilon | [factor_aug] :Base def epsilon_target - [epsilon_target '::' word] :Rec + [epsilon_target `:: word] :Rec | [word] :Base def action_expr - ['{' c_inline::inline_expr '}'] + [`{ c_inline::inline_expr `}] def action_block - ['{' c_inline::inline_block '}'] + [`{ c_inline::inline_block `}] def action_ref [word] :Word - | ['(' word ')'] :ParenWord + | [`( word `)] :ParenWord | [action_block] :Block def priority_aug [uint] - | ['+' uint] - | ['-' uint] + | [`+ uint] + | [`- uint] def aug_base - ['@'] :Finish | ['>'] :Enter | ['%'] :Leave | ['$'] :All + [`@] :Finish | [`>] :Enter | [`%] :Leave | [`$] :All def aug_cond - ['>?'] :Start1 | ['$?'] :All1 | ['%?'] :Leave1 - | ['>' 'when'] :Start2 | ['$' 'when'] :All2 | ['%' 'when'] :Leave2 - | ['inwhen'] :Start3 | ['when'] :All3 | ['outwhen'] :Leave3 + [`>?] :Start1 | [`$?] :All1 | [`%?] :Leave1 + | [`> `when] :Start2 | [`$ `when] :All2 | [`% `when] :Leave2 + | [`inwhen] :Start3 | [`when] :All3 | [`outwhen] :Leave3 def aug_to_state - ['>~'] :Start1 | ['<~'] :NotStart1 | ['$~'] :All1 - | ['%~'] :Final1 | ['@~'] :NotFinal1 | ['<>~'] :Middle1 - | ['>' 'to'] :Start2 | ['<' 'to'] :NotStart2 | ['$' 'to'] :All2 - | ['%' 'to'] :Final2 | ['@' 'to'] :NotFinal2 | ['<>' 'to'] :Middle2 + [`>~] :Start1 | [`<~] :NotStart1 | [`$~] :All1 + | [`%~] :Final1 | [`@~] :NotFinal1 | [`<>~] :Middle1 + | [`> `to] :Start2 | [`< `to] :NotStart2 | [`$ `to] :All2 + | [`% `to] :Final2 | [`@ `to] :NotFinal2 | [`<> `to] :Middle2 def aug_from_state - ['>*'] :Start1 | ['<*'] :NotStart1 | ['$*'] :All1 - | ['%*'] :Final1 | ['@*'] :NotFinal1 | ['<>*'] :Middle1 - | ['>' 'from'] :Start2 | ['<' 'from'] :NotStart2 | ['$' 'from'] :All2 - | ['%' 'from'] :Final2 | ['@' 'from'] :NotFinal2 | ['<>' 'from'] :Middle2 + [`>*] :Start1 | [`<*] :NotStart1 | [`$*] :All1 + | [`%*] :Final1 | [`@*] :NotFinal1 | [`<>*] :Middle1 + | [`> `from] :Start2 | [`< `from] :NotStart2 | [`$ `from] :All2 + | [`% `from] :Final2 | [`@ `from] :NotFinal2 | [`<> `from] :Middle2 def aug_eof - ['>/'] :Start1 | ['</'] :NotStart1 | ['$/'] :All1 - | ['%/'] :Final1 | ['@/'] :NotFinal1 | ['<>/'] :Middle1 - | ['>' 'eof'] :Start2 | ['<' 'eof'] :NotStart2 | ['$' 'eof'] :All2 - | ['%' 'eof'] :Final2 | ['@' 'eof'] :NotFinal2 | ['<>' 'eof'] :Middle2 + [`>/] :Start1 | [`</] :NotStart1 | [`$/] :All1 + | [`%/] :Final1 | [`@/] :NotFinal1 | [`<>/] :Middle1 + | [`> `eof] :Start2 | [`< `eof] :NotStart2 | [`$ `eof] :All2 + | [`% `eof] :Final2 | [`@ `eof] :NotFinal2 | [`<> `eof] :Middle2 def aug_gbl_error - ['>!'] :Start1 | ['<!'] :NotStart1 | ['$!'] :All1 - | ['%!'] :Final1 | ['@!'] :NotFinal1 | ['<>!'] :Middle1 - | ['>' 'err'] :Start2 | ['<' 'err'] :NotStart2 | ['$' 'err'] :All2 - | ['%' 'err'] :Final2 | ['@' 'err'] :NotFinal2 | ['<>' 'err'] :Middle2 + [`>!] :Start1 | [`<!] :NotStart1 | [`$!] :All1 + | [`%!] :Final1 | [`@!] :NotFinal1 | [`<>!] :Middle1 + | [`> `err] :Start2 | [`< `err] :NotStart2 | [`$ `err] :All2 + | [`% `err] :Final2 | [`@ `err] :NotFinal2 | [`<> `err] :Middle2 def aug_local_error - ['>^'] :Start1 | ['<^'] :NotStart1 | ['$^'] :All1 - | ['%^'] :Final1 | ['@^'] :NotFinal1 | ['<>^'] :Middle1 - | ['>' 'lerr'] :Start2 | ['<' 'lerr'] :NotStart2 | ['$' 'lerr'] :All2 - | ['%' 'lerr'] :Final2 | ['@' 'lerr'] :NotFinal2 | ['<>' 'lerr'] :Middle2 + [`>^] :Start1 | [`<^] :NotStart1 | [`$^] :All1 + | [`%^] :Final1 | [`@^] :NotFinal1 | [`<>^] :Middle1 + | [`> `lerr] :Start2 | [`< `lerr] :NotStart2 | [`$ `lerr] :All2 + | [`% `lerr] :Final2 | [`@ `lerr] :NotFinal2 | [`<> `lerr] :Middle2 def factor_aug [factor_aug aug_base action_ref] :ActionRef | [factor_aug aug_base priority_aug] :PriorEmbed - | [factor_aug aug_base '(' word ',' priority_aug ')'] :NamedPriorEmbed + | [factor_aug aug_base `( word `, priority_aug `)] :NamedPriorEmbed | [factor_aug aug_cond action_ref] :CondEmbed - | [factor_aug aug_cond '!' action_ref] :NegCondEmbed + | [factor_aug aug_cond `! action_ref] :NegCondEmbed | [factor_aug aug_to_state action_ref] :ToStateAction | [factor_aug aug_from_state action_ref] :FromStateAction | [factor_aug aug_eof action_ref] :EofAction | [factor_aug aug_gbl_error action_ref] :GblErrorAction | [factor_aug aug_local_error action_ref] :LocalErrorDef - | [factor_aug aug_local_error '(' word ',' action_ref ')'] :LocalErrorName + | [factor_aug aug_local_error `( word `, action_ref `)] :LocalErrorName | [factor_rep] :Base def factor_rep [factor_neg factor_rep_op*] def factor_rep_op - ['*'] :Star - | ['**'] :StarStar - | ['?'] :Optional - | ['+'] :Plus - | ['{' factor_rep_num '}'] :ExactRep - | ['{' ',' factor_rep_num '}'] :MaxRep - | ['{' factor_rep_num ',' '}'] :MinRep - | ['{' LowRep: factor_rep_num ',' HighRep: factor_rep_num '}'] :RangeRep + [`*] :Star + | [`**] :StarStar + | [`?] :Optional + | [`+] :Plus + | [`{ factor_rep_num `}] :ExactRep + | [`{ `, factor_rep_num `}] :MaxRep + | [`{ factor_rep_num `, `}] :MinRep + | [`{ LowRep: factor_rep_num `, HighRep: factor_rep_num `}] :RangeRep def factor_rep_num [uint] def factor_neg - ['!' factor_neg] :Bang - | ['^' factor_neg] :Caret + [`! factor_neg] :Bang + | [`^ factor_neg] :Caret | [factor] :Base def factor @@ -329,8 +329,8 @@ namespace ragel | [lex_sqopen_pos reg_or_data re_or_sqclose] :PosOrBlock | [lex_sqopen_neg reg_or_data re_or_sqclose] :NegOrBlock | [lex_regex_open regex re_close] :Regex - | [RL1: range_lit '..' RL2: range_lit] :Range - | ['(' join ')'] :Join + | [RL1: range_lit `.. RL2: range_lit] :Range + | [`( join `)] :Join def regex [reg_item_rep*] @@ -359,11 +359,11 @@ namespace ragel def alphabet_num [uint] - | ['-' uint] + | [`- uint] | [hex] def lm_act - ['=>' action_ref] :ActionRef + [`=> action_ref] :ActionRef | [action_block] :ActionBlock def opt_lm_act @@ -371,7 +371,7 @@ namespace ragel | [] def lm_stmt - [join opt_lm_act ';'] :LmStmt commit + [join opt_lm_act `;] :LmStmt commit | [assignment] :Assignment | [action_spec] :ActionSpec @@ -381,16 +381,16 @@ namespace ragel def lm [join] :Join - | ['|*' lm_stmt_list '*|'] :Lm + | [`|* lm_stmt_list `*|] :Lm def action_spec - ['action' word action_block] commit + [`action word action_block] commit def assignment - [opt_export word '=' join ';'] commit + [opt_export word `= join `;] commit def instantiation - [opt_export word ':=' lm ';'] commit + [opt_export word `:= lm `;] commit def alphtype_type [W1: word] :One @@ -402,26 +402,26 @@ namespace ragel | [word string] def opt_export - ['export'] :Export + [`export] :Export | [] :Base def machine_name - ['machine' word ';'] + [`machine word `;] def statement [machine_name] :MachineName commit | [assignment] :Assignment | [instantiation] :Instantiation | [action_spec] :ActionSpec - | ['prepush' action_block] :PrePushSpec commit - | ['postpop' action_block] :PostPopSpec commit - | ['variable' variable_name inline_expr_reparse] :Variable commit - | ['alphtype' alphtype_type ';'] :AlphType commit - | ['access' inline_expr_reparse] :Access commit - | ['write' Cmd: word ArgList: word* ';'] :Write commit - | ['getkey' inline_expr_reparse] :GetKey commit - | ['import' string ';'] :Import commit - | ['include' include_spec ';'] :Include commit + | [`prepush action_block] :PrePushSpec commit + | [`postpop action_block] :PostPopSpec commit + | [`variable variable_name inline_expr_reparse] :Variable commit + | [`alphtype alphtype_type `;] :AlphType commit + | [`access inline_expr_reparse] :Access commit + | [`write Cmd: word ArgList: word* `;] :Write commit + | [`getkey inline_expr_reparse] :GetKey commit + | [`import string `;] :Import commit + | [`include include_spec `;] :Include commit def ragel_start [statement*] @@ -429,7 +429,7 @@ end namespace c_host lex - literal '%%{', '}%%' + literal `%%{, `}%% token slr /'%%' [^{] [^\n]* '\n'/ { @@ -479,19 +479,19 @@ namespace c_host | [c_any] def section - ['%%{' ragel::ragel_start '}%%'] :MultiLine + [`%%{ ragel::ragel_start `}%%] :MultiLine | [tok] :Tok end lex - literal '%%{', '}%%' + literal `%%{ `}%% - literal 'int', 'bool', 'const', 'char', 'ptr', 'printi', - 'printb', 'prints', 'print_token', - 'fwrite', 'first_token_char', 'var', 'byte' + literal `int `bool `const `char `ptr `printi + `printb `prints `print_token + `fwrite `first_token_char `var `byte - literal ';', '<', '>', '(', ')', '[', ']', '=', '*', '!' + literal `; `< `> `( `) `[ `] `= `* `! ignore / ( [ \t] | NL )+ / @@ -557,7 +557,7 @@ def output def tok [tk_ident] -| [tk_ident '[' tok ']'] +| [tk_ident `[ tok `]] | [tk_number] | [tk_hex_number] | [input] @@ -565,46 +565,46 @@ def tok | [tk_cpp_comment] | [c_comment] | [string] -| ['<' type '>' '(' tok* ')'] -| ['(' type ')' '(' tok* ')'] -| ['(' tok* ')'] -| ['printi' tok ';'] -| ['printb' tok ';'] -| ['prints' tok ';'] -| ['print_token' ';'] -| ['first_token_char'] -| [';'] -| ['<'] -| ['>'] -| ['['] -| [']'] -| ['='] -| ['!'] -| ['*'] +| [`< type `> `( tok* `)] +| [`( type `) `( tok* `)] +| [`( tok* `)] +| [`printi tok `;] +| [`printb tok `;] +| [`prints tok `;] +| [`print_token `;] +| [`first_token_char] +| [`;] +| [`<] +| [`>] +| [`[] +| [`]] +| [`=] +| [`!] +| [`*] | [indep_any] def section_multiline - ['%%{' ragel::ragel_start '}%%'] + [`%%{ ragel::ragel_start `}%%] def type - ['int'] -| ['bool'] -| ['char'] -| ['char' '*'] -| ['const' '(' 'char' ')' '*'] -| ['ptr'] -| ['byte'] + [`int] +| [`bool] +| [`char] +| [`char `*] +| [`const `( `char `) `*] +| [`ptr] +| [`byte] def opt_arr - ['[' tok ']'] + [`[ tok `]] | [] def var_decl - [type tk_ident opt_arr ';'] -| ['var' tk_ident opt_arr type] + [type tk_ident opt_arr `;] +| [`var tk_ident opt_arr type] def expr_stmt - [tk_ident '=' tok* ';'] + [tk_ident `= tok* `;] def stmt [var_decl] @@ -620,12 +620,12 @@ def start namespace c lex - literal '%%{', '}%%' + literal `%%{, `}%% - literal 'int', 'bool', 'const', 'char', 'ptr', - 'printf', 'fwrite', 'var', 'byte' + literal `int `bool `const `char `ptr + `printf `fwrite `var `byte - literal ';', '<', '>', '(', ')', '[', ']', '=', '*', '!' + literal `; `< `> `( `) `[ `] `= `* `! ignore / ( [ \t] | NL )+ / @@ -641,23 +641,23 @@ namespace c def tok [tk_ident] - | [tk_ident '[' tok ']'] + | [tk_ident `[ tok `]] | [tk_number] | [tk_hex_number] | [string] - | ['<' type '>' '(' tok* ')'] - | ['(' type ')' '(' tok* ')'] - | ['(' tok* ')'] - | ['printf' '(' tok* ')' ';'] - | ['fwrite' '(' tok* ')' ';'] - | [';'] - | ['<'] - | ['>'] - | ['['] - | [']'] - | ['='] - | ['!'] - | ['*'] + | [`< type `> `( tok* `)] + | [`( type `) `( tok* `)] + | [`( tok* `)] + | [`printf `( tok* `) `;] + | [`fwrite `( tok* `) `;] + | [`;] + | [`<] + | [`>] + | [`[] + | [`]] + | [`=] + | [`!] + | [`*] | [indep_any] end diff --git a/test/factor3.lm b/test/factor3.lm index da1f290b..8d535880 100644 --- a/test/factor3.lm +++ b/test/factor3.lm @@ -1,3 +1,3 @@ ##### LM ##### -open( 'x' 'r' ) +open( 'x', 'r' ) ##### EXP ##### diff --git a/test/func3.lm b/test/func3.lm index f79b21a4..cdfcbc39 100644 --- a/test/func3.lm +++ b/test/func3.lm @@ -1,16 +1,16 @@ ##### LM ##### lex - literal '{', '}' - literal 'struct', 'type' + literal `{ `} + literal `struct `type token id /[A-Za-z_][A-Za-z_0-9]*/ ignore /[ \t\r\n]+/ end def attribute - ['type' id] + [`type id] def struct - ['struct' id '{' attribute* '}'] + [`struct id `{ attribute* `}] def program [struct*] diff --git a/test/generate1.lm b/test/generate1.lm index 7bb3775c..ef76f8db 100644 --- a/test/generate1.lm +++ b/test/generate1.lm @@ -12,10 +12,10 @@ context generate # Tokens. lex # Python keywords. - literal 'and', 'del', 'from', 'not', 'while', 'as', 'elif', 'global', 'or', - 'with', 'assert', 'else', 'if', 'pass', 'yield', 'break', 'except', - 'import', 'print', 'class', 'exec', 'in', 'raise', 'continue', - 'finally', 'is', 'return', 'def', 'for', 'lambda', 'try' + literal `and `del `from `not `while `as `elif `global `or + `with `assert `else `if `pass `yield `break `except + `import `print `class `exec `in `raise `continue + `finally `is `return `def `for `lambda `try # Identifiers rl lowercase /'a'..'z'/ @@ -58,15 +58,15 @@ context generate token imagnumber /(floatnumber | intpart) ("j" | "J")/ # Operators. - literal '+', '-', '*', '**', '/', '//', '%', '<<', '>>', '&', '|', '^', - '~', '<', '>', '<=', '>=', '==', '!=', '<>' + literal `+ `- `* `** `/ `// `% `<< `>> `& `| `^ + `~ `< `> `<= `>= `== `!= `<> # Delimiters - literal '(', ')', '[', ']', '{', '}', '@', ',', ':', '.', '`', '=', ';', - '+=', '-=', '*=', '/=', '//=', '%=', '&=', '|=', '^=', '>>=', '<<=', - '**=' + literal `( `) `[ `] `{ `} `@ `, `: `. `` `= `; + `+= `-= `*= `/= `//= `%= `&= `|= `^= `>>= `<<= + `**= - literal '...' + literal `... # In general whitespace is ignored. ignore WS /' '+/ @@ -152,10 +152,10 @@ context generate [simple_stmt another_stmt* opt_semi] def another_stmt - [';' simple_stmt] + [`; simple_stmt] def opt_semi - [';'] + [`;] | [] def suite @@ -173,29 +173,29 @@ context generate | [funcdef] def if_stmt - ['if' expression ':' suite elif_part* opt_else_part] + [`if expression `: suite elif_part* opt_else_part] def elif_part - ['elif' expression ':' suite] + [`elif expression `: suite] def opt_else_part - ['else' ':' suite] + [`else `: suite] | [] def while_stmt - ['while' expression ':' suite opt_else_part] + [`while expression `: suite opt_else_part] def for_stmt - ['for' target_list 'in' expression_list ':' suite opt_else_part] + [`for target_list `in expression_list `: suite opt_else_part] def funcdef - ['def' funcname '(' opt_parameter_list ')' ':' suite] + [`def funcname `( opt_parameter_list `) `: suite] def funcname [identifier] def dotted_name - [dotted_name '.' identifier] + [dotted_name `. identifier] | [identifier] def opt_parameter_list @@ -206,23 +206,23 @@ context generate [defparameter_list defparameter opt_comma] def defparameter_list - [defparameter_list defparameter ','] + [defparameter_list defparameter `,] | [] def defparameter [parameter] - | [parameter '=' expression] + | [parameter `= expression] def sublist [sublist_pl opt_comma] def sublist_pl - [sublist_pl ',' parameter] + [sublist_pl `, parameter] | [parameter] def parameter [identifier] - | ['(' sublist ')'] + | [`( sublist `)] def classname [identifier] @@ -243,13 +243,13 @@ context generate | [target_equals] def target_equals - [target_list '='] + [target_list `=] def target_list [target_list_core opt_comma] def target_list_core - [target_list_core ',' target] + [target_list_core `, target] | [target] def target @@ -257,8 +257,8 @@ context generate def target_atom [identifier] - | ['(' target_list ')'] - | ['[' target_list ']'] + | [`( target_list `)] + | [`[ target_list `]] def target_ext_rep [target_ext target_ext_rep] @@ -270,7 +270,7 @@ context generate | [slicing] def print_stmt - ['print' opt_expression_list] + [`print opt_expression_list] def opt_expression_list [expression_list] @@ -280,32 +280,32 @@ context generate [expression_list_core opt_comma] def expression_list_core - [expression_list_core ',' expression] + [expression_list_core `, expression] | [expression] def opt_comma - [','] + [`,] | [] def expression - [or_test 'if' or_test 'else' test] + [or_test `if or_test `else test] | [or_test] | [lambda_form] def or_test - [or_test 'or' and_test] + [or_test `or and_test] | [and_test] def and_test - [and_test 'and' not_test] + [and_test `and not_test] | [not_test] def not_test [comparison] - | ['not' not_test] + | [`not not_test] def lambda_form - ['lambda' opt_parameter_list ':' expression] + [`lambda opt_parameter_list `: expression] def test [or_test] @@ -318,8 +318,8 @@ context generate [comp_operator or_expr] def comp_operator - ['<'] | ['>'] | ['=='] | ['>='] | ['<='] | ['<>'] | ['!='] | ['is'] | - ['is' 'not'] | ['in'] | ['not' 'in'] + [`<] | [`>] | [`==] | [`>=] | [`<=] | [`<>] | [`!=] | [`is] | + [`is `not] | [`in] | [`not `in] def or_expr [primary] @@ -357,10 +357,10 @@ context generate | [string_conversion] def parenth_form - ['(' opt_expression_list ')'] + [`( opt_expression_list `)] def list_display - ['[' opt_listmaker ']'] + [`[ opt_listmaker `]] def opt_listmaker [listmaker] @@ -371,7 +371,7 @@ context generate | [expression listmaker_ext* opt_comma] def listmaker_ext - [',' expression] + [`, expression] def opt_list_iter [list_iter] @@ -382,22 +382,22 @@ context generate | [list_if] def list_if - ['if' test opt_list_iter] + [`if test opt_list_iter] def list_for - ['for' expression_list 'in' testlist opt_list_iter] + [`for expression_list `in testlist opt_list_iter] def testlist [test testlist_ext* opt_comma] def testlist_ext - [',' test ] + [`, test ] def generator_expression - ['(' test genexpr_for ')'] + [`( test genexpr_for `)] def genexpr_for - ['for' expression_list 'in' test opt_genexpr_iter] + [`for expression_list `in test opt_genexpr_iter] def opt_genexpr_iter [genexpr_iter] @@ -408,10 +408,10 @@ context generate | [genexpr_if] def genexpr_if - ['if' test opt_genexpr_iter] + [`if test opt_genexpr_iter] def dict_display - ['\{' opt_key_datum_list '\}'] + [`{ opt_key_datum_list `}] def opt_key_datum_list [key_datum_list] @@ -421,19 +421,19 @@ context generate [key_datum key_datum_list_ext* opt_comma] def key_datum_list_ext - [',' key_datum] + [`, key_datum] def key_datum - [expression ':' expression] + [expression `: expression] def string_conversion - ['`' expression_list '`'] + [`` expression_list ``] def attributeref - ['.' identifier] + [`. identifier] def subscription - ['[' expression_list ']'] + [`[ expression_list `]] # The natural ordered choice does not suffice here. Must force it. @@ -442,16 +442,16 @@ context generate | [extended_slicing] def simple_slicing - ['[' short_slice ']'] + [`[ short_slice `]] def extended_slicing - ['[' slice_list ']'] + [`[ slice_list `]] def slice_list [slice_item slice_list_ext* opt_comma] def slice_list_ext - [',' slice_item] + [`, slice_item] def slice_item [expression] @@ -463,14 +463,14 @@ context generate | [long_slice] def short_slice - [':'] - | [':' upper_bound] - | [lower_bound ':'] - | [lower_bound ':' upper_bound] + [`:] + | [`: upper_bound] + | [lower_bound `:] + | [lower_bound `: upper_bound] def long_slice - [short_slice ':' stride] - | [short_slice ':'] + [short_slice `: stride] + | [short_slice `:] def lower_bound [expression] @@ -482,10 +482,10 @@ context generate [expression] def ellipsis - ['...'] + [`...] def call - ['(' opt_argument_list ')'] + [`( opt_argument_list `)] def opt_argument_list [argument_list opt_comma] @@ -496,19 +496,19 @@ context generate | [keyword_arguments] def positional_arguments - [positional_arguments ',' expression] + [positional_arguments `, expression] | [expression] def opt_comma_keyword_arguments - [',' keyword_arguments] + [`, keyword_arguments] | [] def keyword_arguments - [keyword_arguments ',' keyword_item] + [keyword_arguments `, keyword_item] | [keyword_item] def keyword_item - [identifier '=' expression] + [identifier `= expression] end # generate diff --git a/test/generate2.lm b/test/generate2.lm index 6c7f3e12..946c4787 100644 --- a/test/generate2.lm +++ b/test/generate2.lm @@ -98,7 +98,7 @@ context generate } } - literal '|' + literal `| token char /any/ preeof { @@ -129,15 +129,15 @@ context generate lex - literal 'http:' - literal 'ftp:' - literal 'mailto:' + literal `http: + literal `ftp: + literal `mailto: end def el_prefix - ['http:'] - | ['ftp:'] - | ['mailto:'] + [`http:] + | [`ftp:] + | [`mailto:] def external_link [osquare item* csquare1] @@ -183,7 +183,7 @@ context generate | [unclosed_curly] | [stray_close] | [osquare] - | ['|'] + | [`|] | [char] def start diff --git a/test/ignore1.lm b/test/ignore1.lm index cbdafbd5..47f631c9 100644 --- a/test/ignore1.lm +++ b/test/ignore1.lm @@ -11,7 +11,7 @@ rl rl_id /[a-zA-Z_][a-zA-Z0-9_]*/ # lex - literal '=', '<', '>', '/' + literal `= `< `> `/ # Ignore whitespace. ignore /rl_ws/ @@ -24,17 +24,17 @@ end # Productions # -def attr [id '=' id] +def attr [id `= id] def attr_list [attr_list attr] | [] def open_tag - ['<' id attr_list '>'] + [`< id attr_list `>] def close_tag - ['<' '/' id '>'] + [`< `/ id `>] def tag [open_tag item_list close_tag] diff --git a/test/ignore2.lm b/test/ignore2.lm index ba262e7b..f4aa963a 100644 --- a/test/ignore2.lm +++ b/test/ignore2.lm @@ -1,13 +1,13 @@ ##### LM ##### lex ignore /space+/ - literal '*', '(', ')' + literal `* `( `) token id /[a-zA-Z_]+/ end def item [id] -| ['(' item* ')'] +| [`( item* `)] def start [item*] diff --git a/test/ignore3.lm b/test/ignore3.lm index 8b511252..71aeb133 100644 --- a/test/ignore3.lm +++ b/test/ignore3.lm @@ -1,7 +1,10 @@ ##### LM ##### lex ignore /space+/ - literal '*', '(' ni, ni ')', '!', ';' + literal `* + literal `( ni + literal ni `) + literal `! `; token id /[a-zA-Z_0-9]+/ end @@ -9,18 +12,18 @@ lex ignore /space+/ token inner_t /[a-zA-Z_0-9]+/ - literal '' + literal ` end def inner - ['' inner_t*] + [` inner_t*] def item [id] -| ['(' inner ')'] +| [`( inner `)] def start - [item* ';'] + [item* `;] parse Start: start[ stdin ] @@ -30,8 +33,8 @@ if ( ! Start ) { } for I: item in Start { - print( 'item: .' I '.\n' ) - if match I [ O: '(' Inner: inner C: ')' ] + print( 'item: .' , I, '.\n' ) + if match I [ O: `( Inner: inner C: `) ] print( 'innr: .' O '.' Inner '.' C '.\n' ) } diff --git a/test/ignore4.lm b/test/ignore4.lm index 014dc560..9333bd59 100644 --- a/test/ignore4.lm +++ b/test/ignore4.lm @@ -2,8 +2,8 @@ namespace hash lex - literal 'define', 'include' - literal '\n' ni + literal `define `include + token NL /'\n'/ ni token id /[a-zA-Z_][a-zA-Z_0-9]*/ token number /[0-9]+/ @@ -14,8 +14,8 @@ namespace hash end def hash - ['define' id number '\n'] - | ['include' string '\n'] + [`define id number NL] + | [`include string NL] end # hash @@ -23,18 +23,18 @@ namespace lang lex ignore /space+/ - literal '*', '(', ')', ';', '#' + literal `* `( `) `; `# token id /[a-zA-Z_][a-zA-Z_0-9]*/ token number /[0-9]+/ end def item [id] - | ['(' item* ')'] + | [`( item* `)] def statement - [item* ';'] - | ['#' hash::hash] + [item* `;] + | [`# hash::hash] def start [statement*] @@ -48,7 +48,7 @@ if ! Input else { #print( Input.tree '\n' ) for H: lang::statement in Input { - require H [ lang::'#' hash::hash ] + require H [ lang::`# hash::hash ] print( '--' H '==\n' ) } } diff --git a/test/ignore5.lm b/test/ignore5.lm index d36ea811..23604c56 100644 --- a/test/ignore5.lm +++ b/test/ignore5.lm @@ -1,7 +1,7 @@ ##### LM ##### lex ignore /space+/ - literal '*', '!', ';' + literal `* `! `; token POPEN /'('/ ni token PCLOSE ni /')'/ token id /[a-zA-Z_0-9]+/ @@ -11,18 +11,18 @@ lex ignore /space+/ token inner_t /[a-zA-Z_0-9]+/ - literal '' + literal ` end def inner - ['' inner_t*] + [` inner_t*] def item [id] | [POPEN inner PCLOSE] def start - [item* ';'] + [item* `;] parse Start: start[ stdin ] diff --git a/test/inpush1.lm b/test/inpush1.lm index 45f04655..362cd1a7 100644 --- a/test/inpush1.lm +++ b/test/inpush1.lm @@ -1,7 +1,7 @@ ##### LM ##### namespace string lex - literal '"' + literal `" token data /[^"\\]+/ token escape /'\\' any/ end @@ -11,11 +11,11 @@ namespace string | [escape] def string - ['"' string_data* '"'] + [`" string_data* `"] str unquote( S: string ) { - match S ['"' DL: string_data* '"'] + match S [`" DL: string_data* `"] for E: escape in DL E.data = 'x' return $DL @@ -26,8 +26,9 @@ end # string namespace hash lex - literal 'define', 'include' - literal '#', '\n' ni + literal `define `include + literal `# + token NL /'\n'/ ni token id /[a-zA-Z_][a-zA-Z_0-9]*/ token number /[0-9]+/ @@ -36,8 +37,8 @@ namespace hash end def hash - ['#' 'define' Id: id number '\n'] - | ['#' 'include' Inc: string::string '\n'] + [`# `define Id: id number NL] + | [`# `include Inc: string::string NL] end # hash @@ -47,7 +48,7 @@ namespace lang lex ignore /space/ - literal '*', '(', ')', ';' + literal `* `( `) `; token id /[a-zA-Z_][a-zA-Z_0-9]*/ token number /[0-9]+/ @@ -78,10 +79,10 @@ namespace lang def item [id] - | ['(' item* ')'] + | [`( item* `)] def statement - [item* ';'] + [item* `;] def start [statement*] diff --git a/test/island.lm b/test/island.lm index 2f5f8dd8..8515eb42 100644 --- a/test/island.lm +++ b/test/island.lm @@ -14,7 +14,7 @@ def func_body [func_item*] def func - [ident '(' ')' '{' func_body func_close ] + [ident `( `) `{ func_body func_close ] lex token ident /[a-zA-Z_]+/ @@ -24,7 +24,7 @@ lex rl d_string / '"' ([^"\\\n] | '\\' any )* '"' / token string /s_string | d_string/ - literal '+', '*', ';', '(', ')', '{', '}' + literal `+ `* `; `( `) `{ `} ignore wp / [ \t\n]+ / end @@ -32,15 +32,15 @@ end def class_item [func] | [class] -| [ident ';'] -| [number ';'] -| [string ';'] +| [ident `;] +| [number `;] +| [string `;] def class_body [class_item*] def class - [ident '{' class_body '}' ] + [ident `{ class_body `} ] def top_item [func] diff --git a/test/lhs1.lm b/test/lhs1.lm index 99499abe..f40297f9 100644 --- a/test/lhs1.lm +++ b/test/lhs1.lm @@ -2,7 +2,8 @@ lex ignore /space+/ - literal '*', '(', ')', '!', ';\n' + literal `* `( `) `! + token SEMI_NL /';\n'/ token id /[a-zA-Z_0-9]+/ end @@ -11,7 +12,7 @@ def item { lhs = cons item ["( " ^r1 " )"] } -| ['(' item* ')'] +| [`( item* `)] { lhs = cons item ["( " ^r2 " )"] } @@ -27,8 +28,8 @@ def B } def start - [A item* '!'] -| [B item* ';\n'] + [A item* `!] +| [B item* SEMI_NL] parse Start: start[ stdin ] print( Start "\n" ) diff --git a/test/liftattrs.lm b/test/liftattrs.lm index 8931e045..574ea353 100644 --- a/test/liftattrs.lm +++ b/test/liftattrs.lm @@ -11,7 +11,7 @@ rl rl_id /[a-zA-Z_][a-zA-Z0-9_]*/ # lex - literal '=', '<', '>', '/' + literal `= `< `> `/ # Ignore whitespace. ignore /rl_ws/ @@ -24,17 +24,17 @@ end # Productions # -def attr [id '=' id] +def attr [id `= id] def attr_list [attr_list attr] | [] def open_tag - ['<' id attr_list '>'] + [`< id attr_list `>] def close_tag - ['<' '/' id '>'] + [`< `/ id `>] def tag [open_tag item_list close_tag] diff --git a/test/lookup1.lm b/test/lookup1.lm index 64e0b7c9..7eaf58f7 100644 --- a/test/lookup1.lm +++ b/test/lookup1.lm @@ -147,26 +147,26 @@ context lookup token TK_SingleLit /( 'L'? "'" ( [^'\\\n] | '\\' any )* "'" )/ token TK_DoubleLit /( 'L'? '"' ( [^"\\\n] | '\\' any )* '"' )/ - literal 'extern', 'namespace', 'friend', 'typedef', 'auto', 'register', - 'static', 'mutable', 'inline', 'virtual', 'explicit', 'const', - 'volatile', 'restrict', 'class', 'struct', 'union', 'template', - 'private', 'protected', 'public', 'using', 'void', 'char', - 'wchar_t', 'bool', 'int', 'float', 'double', 'short', 'long', - 'signed', 'unsigned', 'enum', 'new', 'delete', 'operator', - 'typename', 'export', 'throw', 'try', 'catch', 'sizeof', - 'dynamic_cast', 'static_cast', 'reinterpret_cast', 'const_cast', - 'typeid', 'this', 'true', 'false', 'switch', 'case', 'default', - 'if', 'else', 'while', 'do', 'for', 'break', 'continue', - 'return', 'goto' + literal `extern `namespace `friend `typedef `auto `register + `static `mutable `inline `virtual `explicit `const + `volatile `restrict `class `struct `union `template + `private `protected `public `using `void `char + `wchar_t `bool `int `float `double `short `long + `signed `unsigned `enum `new `delete `operator + `typename `export `throw `try `catch `sizeof + `dynamic_cast `static_cast `reinterpret_cast `const_cast + `typeid `this `true `false `switch `case `default + `if `else `while `do `for `break `continue + `return `goto # Extensions - literal '__typeof', '__is_pod', '__is_empty' + literal `__typeof `__is_pod `__is_empty - literal '{', '}', ';', ',', '=', '(', ')', ':', '&', '*', '[', ']', '~', '+', '-', - '/', '<', '>', '|', '^', '%', '!', '?', '.' + literal `{ `} `; `, `= `( `) `: `& `* `[ `] `~ `+ `- + `/ `< `> `| `^ `% `! `? `. - literal '::', '==', '!=', '&&', '||', '*=', '/=', '%=', '+=', '-=', '&=', - '^=', '|=', '++', '--', '->', '->*', '.*', '...', '<<=', '>>=' + literal `:: `== `!= `&& `|| `*= `/= `%= `+= `-= `&= + `^= `|= `++ `-- `-> `->* `.* `... `<<= `>>= # Token translation targets. def unknown_id [lookup_id] @@ -305,17 +305,17 @@ context lookup def root_qual_opt [] - | ['::'] + | [`::] def nested_name_specifier_opt - [nested_name_specifier_opt qualifying_name '::' designated_qualifying_name '::'] - | [nested_name_specifier_opt qualifying_name '::'] + [nested_name_specifier_opt qualifying_name `:: designated_qualifying_name `::] + | [nested_name_specifier_opt qualifying_name `::] | [] def nested_name_specifier - [nested_name_specifier designated_qualifying_name '::'] - | [nested_name_specifier qualifying_name '::'] - | [qualifying_name '::'] + [nested_name_specifier designated_qualifying_name `::] + | [nested_name_specifier qualifying_name `::] + | [qualifying_name `::] def qualifying_name [class_name] @@ -336,13 +336,13 @@ context lookup } def designated_qualifying_name - ['template' any_id] + [`template any_id] { # FIXME: nulling qualNs is not the right thing to do here. qualNs.top = nil } - | ['template' any_id + | [`template any_id templ_arg_open template_argument_list_opt templ_arg_close] { # FIXME: nulling qualNs is not the right thing to do here. @@ -391,7 +391,7 @@ context lookup lhs.lookupId.qualObj = qualObj } - | [root_qual_opt nested_name_specifier_opt '~' class_name] + | [root_qual_opt nested_name_specifier_opt `~ class_name] { lhs.lookupId = r4.lookupId } @@ -439,13 +439,13 @@ context lookup } def templ_arg_open - ['<'] + [`<] { qualNs.push( nil ) } def templ_arg_close - ['>'] + [`>] { qualNs.pop() } @@ -469,7 +469,7 @@ context lookup | [using_directive] def simple_declaration - [declaration_start simple_declaration_forms declaration_end ';'] + [declaration_start simple_declaration_forms declaration_end `;] # Ordering is important for optimization. The form with the optional # decl_specifier_sing should go second. @@ -571,23 +571,23 @@ context lookup lhs.lookupId.data = '<simple_type_specifier_kw_seq>' } - | ['typename' root_qual_opt nested_name_specifier type_name] + | [`typename root_qual_opt nested_name_specifier type_name] { lhs.lookupId = r4.lookupId } - | ['typename' root_qual_opt nested_name_specifier identifier] + | [`typename root_qual_opt nested_name_specifier identifier] { lhs.lookupId = lookup_id in r4 } - | ['typename' root_qual_opt nested_name_specifier unknown_id] + | [`typename root_qual_opt nested_name_specifier unknown_id] { lhs.lookupId = lookup_id in r4 } # Extension. - | ['__typeof' '(' expression ')'] + | [`__typeof `( expression `)] { lhs.lookupId = construct lookup_id ["x"] lhs.lookupId.data = '<simple_type_specifier_kw_seq>' @@ -606,17 +606,17 @@ context lookup | [simple_type_specifier_kw] def simple_type_specifier_kw - ['void'] - | ['char'] - | ['wchar_t'] - | ['bool'] - | ['int'] - | ['float'] - | ['double'] - | ['short'] - | ['long'] - | ['signed'] - | ['unsigned'] + [`void] + | [`char] + | [`wchar_t] + | [`bool] + | [`int] + | [`float] + | [`double] + | [`short] + | [`long] + | [`signed] + | [`unsigned] def qual_type_name lookupId: lookup_id @@ -682,7 +682,7 @@ context lookup | [class_key nested_name_specifier_opt templ_class_id templ_arg_open template_argument_list_opt templ_arg_close] - | ['enum' nested_name_specifier_opt enum_head_name] + | [`enum nested_name_specifier_opt enum_head_name] { # TODO: should look for existing enums of the same name. Id: lookup_id = lookup_id in r3 @@ -704,35 +704,35 @@ context lookup | [storage_class_specifier] | [function_specifier] - | ['friend'] + | [`friend] { declarationData.top.isFriend = 1 } - | ['typedef'] + | [`typedef] { declarationData.top.isTypedef = 1 } def storage_class_specifier - ['auto'] - | ['register'] - | ['static'] - | ['extern'] - | ['mutable'] + [`auto] + | [`register] + | [`static] + | [`extern] + | [`mutable] def function_specifier - ['inline'] - | ['virtual'] - | ['explicit'] + [`inline] + | [`virtual] + | [`explicit] def type_specifier_mult [cv_qualifier] def cv_qualifier - ['const'] - | ['volatile'] - | ['restrict'] + [`const] + | [`volatile] + | [`restrict] def cv_qualifier_rep [cv_qualifier_rep cv_qualifier] @@ -751,8 +751,8 @@ context lookup # def enum_specifier - ['enum' nested_name_specifier_opt - enum_head_name '{' enumerator_list_opt '}'] + [`enum nested_name_specifier_opt + enum_head_name `{ enumerator_list_opt `}] { # TODO: should look for existing enums of the same name. Id: lookup_id = lookup_id in r3 @@ -761,7 +761,7 @@ context lookup insertObject( declNs.top Id.data enum ) } - | ['enum' '{' enumerator_list_opt '}'] + | [`enum `{ enumerator_list_opt `}] def enum_head_name [class_id] @@ -775,11 +775,11 @@ context lookup def enumerator_list_opt [enumerator_list] - | [enumerator_list ','] + | [enumerator_list `,] | [] def enumerator_list - [enumerator_list ',' enumerator_definition] + [enumerator_list `, enumerator_definition] | [enumerator_definition] def enumerator_definition @@ -790,7 +790,7 @@ context lookup insertObject( declNs.top Id.data enumId ) } - | [enumerator_id '=' constant_expression] + | [enumerator_id `= constant_expression] { Id: lookup_id = lookup_id in r1 enumId: ptr<lang_object> = createLangObject( IdType Id.data lookupNs.top ) @@ -816,25 +816,25 @@ context lookup | [] def init_declarator_list - [init_declarator_list ',' init_declarator] + [init_declarator_list `, init_declarator] | [init_declarator] def init_declarator [declarator initializer_opt] def initializer_opt - ['=' initializer_clause] - | ['(' expression ')'] + [`= initializer_clause] + | [`( expression `)] | [] def initializer_clause [assignment_expression] - | ['{' initializer_list '}'] - | ['{' initializer_list ',' '}'] - | ['{' '}'] + | [`{ initializer_list `}] + | [`{ initializer_list `, `}] + | [`{ `}] def initializer_list - [initializer_list ',' initializer_clause] + [initializer_list `, initializer_clause] | [initializer_clause] # @@ -842,7 +842,7 @@ context lookup # def expression - [expression ',' assignment_expression] + [expression `, assignment_expression] | [assignment_expression] def expression_opt @@ -862,50 +862,50 @@ context lookup | [throw_expression] def assignment_op - ['='] - | ['*='] - | ['/='] - | ['%='] - | ['+='] - | ['-='] - | ['>>='] - | ['<<='] - | ['&='] - | ['^='] - | ['|='] + [`=] + | [`*=] + | [`/=] + | [`%=] + | [`+=] + | [`-=] + | [`>>=] + | [`<<=] + | [`&=] + | [`^=] + | [`|=] def conditional_expression [logical_or_expression] - | [logical_or_expression '?' expression ':' assignment_expression] + | [logical_or_expression `? expression `: assignment_expression] def logical_or_expression - [logical_or_expression '||' logical_and_expression] + [logical_or_expression `|| logical_and_expression] | [logical_and_expression] def logical_and_expression - [logical_and_expression '&&' inclusive_or_expression] + [logical_and_expression `&& inclusive_or_expression] | [inclusive_or_expression] def inclusive_or_expression - [inclusive_or_expression '|' exclusive_or_expression] + [inclusive_or_expression `| exclusive_or_expression] | [exclusive_or_expression] def exclusive_or_expression - [exclusive_or_expression '^' and_expression] + [exclusive_or_expression `^ and_expression] | [and_expression] def and_expression - [and_expression '&' equality_expression] + [and_expression `& equality_expression] | [equality_expression] def equality_expression - [equality_expression '==' relational_expression] - | [equality_expression '!=' relational_expression] + [equality_expression `== relational_expression] + | [equality_expression `!= relational_expression] | [relational_expression] def relational_expression - [relational_expression '<' shift_expression] - | [relational_expression '>' shift_expression] + [relational_expression `< shift_expression] + | [relational_expression `> shift_expression] | [relational_expression lt_eq shift_expression] | [relational_expression gt_eq shift_expression] | [shift_expression] @@ -916,39 +916,39 @@ context lookup | [additive_expression] def additive_expression - [additive_expression '+' multiplicative_expression] - | [additive_expression '-' multiplicative_expression] + [additive_expression `+ multiplicative_expression] + | [additive_expression `- multiplicative_expression] | [multiplicative_expression] def multiplicative_expression - [multiplicative_expression '*' pm_expression] - | [multiplicative_expression '/' pm_expression] - | [multiplicative_expression '%' pm_expression] + [multiplicative_expression `* pm_expression] + | [multiplicative_expression `/ pm_expression] + | [multiplicative_expression `% pm_expression] | [pm_expression] def pm_expression - [pm_expression '->*' cast_expression] - | [pm_expression '.*' cast_expression] + [pm_expression `->* cast_expression] + | [pm_expression `.* cast_expression] | [cast_expression] def cast_expression [unary_expression] - | ['(' type_id ')' cast_expression] + | [`( type_id `) cast_expression] def delete_expression - [root_qual_opt 'delete' cast_expression] - | [root_qual_opt 'delete' '[' ']' cast_expression] + [root_qual_opt `delete cast_expression] + | [root_qual_opt `delete `[ `] cast_expression] def new_initializer_opt [new_initializer] | [] def new_initializer - ['(' expression_opt ')'] + [`( expression_opt `)] def direct_new_declarator - ['[' expression ']'] - | [direct_new_declarator '[' constant_expression ']'] + [`[ expression `]] + | [direct_new_declarator `[ constant_expression `]] def new_declarator_opt [new_declarator] @@ -963,29 +963,29 @@ context lookup [necs_type_specifier_seq new_declarator_opt] def new_placement - ['(' expression ')'] + [`( expression `)] def new_expression - [root_qual_opt 'new' new_type_id new_initializer_opt] - | [root_qual_opt 'new' new_placement new_type_id new_initializer_opt] - | [root_qual_opt 'new' '(' type_id ')' new_initializer_opt] - | [root_qual_opt 'new' new_placement '(' type_id ')' new_initializer_opt] + [root_qual_opt `new new_type_id new_initializer_opt] + | [root_qual_opt `new new_placement new_type_id new_initializer_opt] + | [root_qual_opt `new `( type_id `) new_initializer_opt] + | [root_qual_opt `new new_placement `( type_id `) new_initializer_opt] def unary_operator - ['*'] - | ['&'] - | ['+'] - | ['-'] - | ['!'] - | ['~'] + [`*] + | [`&] + | [`+] + | [`-] + | [`!] + | [`~] def unary_expression [postfix_expression] - | ['++' cast_expression] - | ['--' cast_expression] + | [`++ cast_expression] + | [`-- cast_expression] | [unary_operator cast_expression] - | ['sizeof' '(' type_id ')'] - | ['sizeof' unary_expression] + | [`sizeof `( type_id `)] + | [`sizeof unary_expression] | [new_expression] | [delete_expression] @@ -995,32 +995,32 @@ context lookup def postfix_expression [primary_expression] - | [postfix_expression '[' expression ']'] - | [postfix_expression '(' expression_opt ')'] - | [function_style_type_conv '(' expression_opt ')'] + | [postfix_expression `[ expression `]] + | [postfix_expression `( expression_opt `)] + | [function_style_type_conv `( expression_opt `)] | [member_request_expr dot_arrow id_expression] | [member_request_expr dot_arrow pseudo_destructor_call] - | [postfix_expression '++'] - | [postfix_expression '--'] - | ['dynamic_cast' templ_arg_open type_id templ_arg_close '(' expression ')'] - | ['static_cast' templ_arg_open type_id templ_arg_close '(' expression ')'] - | ['reinterpret_cast' templ_arg_open type_id templ_arg_close '(' expression ')'] - | ['const_cast' templ_arg_open type_id templ_arg_close '(' expression ')'] - | ['typeid' '(' expression ')'] - | ['typeid' '(' type_id ')'] + | [postfix_expression `++] + | [postfix_expression `--] + | [`dynamic_cast templ_arg_open type_id templ_arg_close `( expression `)] + | [`static_cast templ_arg_open type_id templ_arg_close `( expression `)] + | [`reinterpret_cast templ_arg_open type_id templ_arg_close `( expression `)] + | [`const_cast templ_arg_open type_id templ_arg_close `( expression `)] + | [`typeid `( expression `)] + | [`typeid `( type_id `)] def pseudo_destructor_call - [root_qual_opt nested_name_specifier_opt '~' pdc_type_name] + [root_qual_opt nested_name_specifier_opt `~ pdc_type_name] def primary_expression [expr_lit] - | ['this'] - | ['(' expression ')'] + | [`this] + | [`( expression `)] | [id_expression] # GNU extensions - | ['(' '{' statement_rep '}' ')'] - | ['__is_pod' '(' type_id ')'] - | ['__is_empty' '(' type_id ')'] + | [`( `{ statement_rep `} `)] + | [`__is_pod `( type_id `)] + | [`__is_empty `( type_id `)] def expr_lit [TK_IntegerDecimal] @@ -1029,8 +1029,8 @@ context lookup | [TK_SingleLit] | [TK_Float] | [double_lit_list] - | ['true'] - | ['false'] + | [`true] + | [`false] def double_lit_list [TK_DoubleLit double_lit_list] @@ -1045,8 +1045,8 @@ context lookup # } def dot_arrow - ['->'] - | ['.'] + [`->] + | [`.] def pdc_type_name [enum_id] @@ -1071,9 +1071,9 @@ context lookup | [try_block] def labeled_statement - [label_id ':' statement] - | ['case' constant_expression ':' statement] - | ['default' ':' statement] + [label_id `: statement] + | [`case constant_expression `: statement] + | [`default `: statement] def label_id [unknown_id] @@ -1086,7 +1086,7 @@ context lookup | [template_id] def compound_statement - ['{' compound_begin statement_rep compound_end '}'] + [`{ compound_begin statement_rep compound_end `}] def compound_begin [] @@ -1106,27 +1106,27 @@ context lookup } def selection_statement - ['if' '(' condition ')' statement elseif_clauses else_clause] - | ['switch' '(' condition ')' statement] + [`if `( condition `) statement elseif_clauses else_clause] + | [`switch `( condition `) statement] def elseif_clauses - [elseif_clauses 'else' 'if' '(' condition ')' statement] + [elseif_clauses `else `if `( condition `) statement] | [] def else_clause - ['else' statement] + [`else statement] | [] def iteration_statement - ['while' '(' condition ')' statement] - | ['do' statement 'while' '(' expression ')' ';'] - | ['for' '(' for_init_statement condition_opt ';' expression_opt ')' statement] + [`while `( condition `) statement] + | [`do statement `while `( expression `) `;] + | [`for `( for_init_statement condition_opt `; expression_opt `) statement] def jump_statement - ['break' ';'] - | ['continue' ';'] - | ['return' expression_opt ';'] - | ['goto' any_id ';'] + [`break `;] + | [`continue `;] + | [`return expression_opt `;] + | [`goto any_id `;] def any_id [unknown_id] @@ -1141,25 +1141,25 @@ context lookup def for_init_statement [expression_statement] - | [stmt_block_declaration_forms ';'] + | [stmt_block_declaration_forms `;] def condition [expression] - | [type_specifier_seq declarator '=' assignment_expression] + | [type_specifier_seq declarator `= assignment_expression] def condition_opt [condition] | [] def expression_statement - [expression ';'] - | [';'] + [expression `;] + | [`;] def declaration_statement [stmt_block_declaration] def stmt_block_declaration - [declaration_start stmt_block_declaration_forms declaration_end ';'] + [declaration_start stmt_block_declaration_forms declaration_end `;] | [using_declaration] | [using_directive] @@ -1180,15 +1180,15 @@ context lookup lhs.lookupObj = r4.lookupObj } - | [ptr_operator_seq_opt '(' sub_declarator ')' decl_array_or_param_rep declarator_end] + | [ptr_operator_seq_opt `( sub_declarator `) decl_array_or_param_rep declarator_end] { lhs.lookupObj = r6.lookupObj } def sub_declarator [ptr_operator_seq declarator_id decl_array_or_param_rep] - | [ptr_operator_seq '(' sub_declarator ')' decl_array_or_param_rep] - | ['(' sub_declarator ')' decl_array_or_param_rep] + | [ptr_operator_seq `( sub_declarator `) decl_array_or_param_rep] + | [`( sub_declarator `) decl_array_or_param_rep] | [declarator_id decl_array_or_param_rep] def decl_array_or_param_rep @@ -1196,8 +1196,8 @@ context lookup | [] def decl_array_or_param - ['[' constant_expression_opt ']'] - | ['(' parameter_declaration_clause ')' cv_qualifier_rep exception_specification_opt] + [`[ constant_expression_opt `]] + | [`( parameter_declaration_clause `) cv_qualifier_rep exception_specification_opt] def declarator_id [declarator_id_forms] @@ -1309,16 +1309,16 @@ context lookup lhs.lookupId = r3.lookupId } - | [root_qual_opt nested_name_specifier_opt '~' class_id] + | [root_qual_opt nested_name_specifier_opt `~ class_id] { lhs.lookupId = lookup_id in r4 } - | [root_qual_opt nested_name_specifier_opt '~' templ_class_id] + | [root_qual_opt nested_name_specifier_opt `~ templ_class_id] { lhs.lookupId = lookup_id in r4 } - | [root_qual_opt nested_name_specifier_opt '~' unknown_id] + | [root_qual_opt nested_name_specifier_opt `~ unknown_id] { lhs.lookupId = lookup_id in r4 } @@ -1337,18 +1337,18 @@ context lookup def abstract_declarator [ptr_operator_seq abstract_noid abstract_decl_array_or_param_seq_opt declarator_end] - | [ptr_operator_seq '(' sub_abstract_declarator ')' + | [ptr_operator_seq `( sub_abstract_declarator `) abstract_decl_array_or_param_seq_opt declarator_end] | [abstract_noid abstract_decl_array_or_param_seq declarator_end] - | ['(' sub_abstract_declarator ')' abstract_decl_array_or_param_seq_opt declarator_end] + | [`( sub_abstract_declarator `) abstract_decl_array_or_param_seq_opt declarator_end] def sub_abstract_declarator [ptr_operator_seq abstract_noid abstract_decl_array_or_param_seq_opt] - | [ptr_operator_seq '(' sub_abstract_declarator ')' + | [ptr_operator_seq `( sub_abstract_declarator `) abstract_decl_array_or_param_seq_opt] - | ['(' sub_abstract_declarator ')' abstract_decl_array_or_param_seq_opt] + | [`( sub_abstract_declarator `) abstract_decl_array_or_param_seq_opt] def abstract_noid [] @@ -1366,15 +1366,15 @@ context lookup | [abstract_decl_array_or_param] def abstract_decl_array_or_param - ['[' constant_expression_opt ']'] - | ['(' parameter_declaration_clause ')' cv_qualifier_rep + [`[ constant_expression_opt `]] + | [`( parameter_declaration_clause `) cv_qualifier_rep exception_specification_opt] def parameter_declaration_clause [pdc_start parameter_declaration_list] - | [pdc_start parameter_declaration_list '...'] - | [pdc_start parameter_declaration_list ',' '...'] - | [pdc_start '...'] + | [pdc_start parameter_declaration_list `...] + | [pdc_start parameter_declaration_list `, `...] + | [pdc_start `...] | [pdc_start] def pdc_start @@ -1393,7 +1393,7 @@ context lookup } def parameter_declaration_list - [parameter_declaration_list ',' parameter_declaration] + [parameter_declaration_list `, parameter_declaration] | [parameter_declaration] def parameter_declaration @@ -1413,12 +1413,12 @@ context lookup | [] def maybe_parameter_init - ['=' constant_expression] + [`= constant_expression] | [] def ptr_operator - ['&'] - | [root_qual_opt nested_name_specifier_opt '*' cv_qualifier_rep] + [`&] + | [root_qual_opt nested_name_specifier_opt `* cv_qualifier_rep] def ptr_operator_seq [ptr_operator_seq ptr_operator] @@ -1461,7 +1461,7 @@ context lookup } def function_body - [function_body_begin '{' statement_rep function_body_end '}'] + [function_body_begin `{ statement_rep function_body_end `}] def function_body_begin [] @@ -1501,7 +1501,7 @@ context lookup } def class_specifier - [class_head base_clause_opt '{' class_member_rep class_body_end '}'] + [class_head base_clause_opt `{ class_member_rep class_body_end `}] { # FIXME: reparse not implemented yet # FIXME FIXME: reparse is actually implemented now implemented @@ -1612,9 +1612,9 @@ context lookup | [template_id] def class_key - ['class'] - | ['struct'] - | ['union'] + [`class] + | [`struct] + | [`union] def class_member_rep [class_member_rep class_member] @@ -1622,10 +1622,10 @@ context lookup def class_member [member_declaration] - | [access_specifier ':'] + | [access_specifier `:] def member_declaration - [declaration_start member_declaration_forms declaration_end ';'] + [declaration_start member_declaration_forms declaration_end `;] | [class_function_definition] | [using_declaration] | [template_declaration] @@ -1672,33 +1672,33 @@ context lookup | [] def member_declarator_list - [member_declarator_list ',' member_declarator] + [member_declarator_list `, member_declarator] | [member_declarator] def member_declarator [declarator] - | [declarator '=' constant_expression] - | [declarator ':' constant_expression] - | [':' constant_expression] + | [declarator `= constant_expression] + | [declarator `: constant_expression] + | [`: constant_expression] def access_specifier - ['private'] - | ['protected'] - | ['public'] + [`private] + | [`protected] + | [`public] def access_specifier_opt [access_specifier] | [] def using_declaration - ['using' id_expression ';'] + [`using id_expression `;] { obj: ptr<lang_object> = r2.lookupId.obj if obj insertObject( declNs.top obj->name obj ) } - | ['using' type_id ';'] + | [`using type_id `;] { obj: ptr<lang_object> = r2.lookupId.obj if obj @@ -1706,8 +1706,8 @@ context lookup } def using_directive - ['using' 'namespace' root_qual_opt nested_name_specifier_opt - namespace_id ';'] + [`using `namespace root_qual_opt nested_name_specifier_opt + namespace_id `;] { # This uses a simple, incomplete guard against cycles in the graph of # using namespaces. A more sophisticated and complete guard would look @@ -1729,10 +1729,10 @@ context lookup | [] def base_clause - [':' base_specifier_list] + [`: base_specifier_list] def base_specifier_list - [base_specifier_list ',' base_specifier] + [base_specifier_list `, base_specifier] | [base_specifier] int addBaseSpecifier( inObject: ptr<lang_object> inheritedObject: ptr<lang_object> ) @@ -1750,7 +1750,7 @@ context lookup addBaseSpecifier( declNs.top r3.lookupId.obj ) } - | ['virtual' access_specifier_opt root_qual_opt nested_name_specifier_opt type_name] + | [`virtual access_specifier_opt root_qual_opt nested_name_specifier_opt type_name] { addBaseSpecifier( declNs.top r5.lookupId.obj ) } @@ -1761,7 +1761,7 @@ context lookup } def virtual_opt - ['virtual'] + [`virtual] | [] # @@ -1769,7 +1769,7 @@ context lookup # def conversion_function_id - ['operator' conversion_type_id] + [`operator conversion_type_id] def conversion_type_id [necs_type_specifier_seq ptr_operator_seq_opt] @@ -1779,14 +1779,14 @@ context lookup | [] def ctor_initializer - [':' mem_initializer_list] + [`: mem_initializer_list] def mem_initializer_list - [mem_initializer_list ',' mem_initializer] + [mem_initializer_list `, mem_initializer] | [mem_initializer] def mem_initializer - [mem_initializer_id '(' expression_opt ')'] + [mem_initializer_id `( expression_opt `)] def mem_initializer_id [root_qual_opt nested_name_specifier_opt unknown_id] @@ -1799,17 +1799,17 @@ context lookup # Overloading # def operator_function_id - ['operator' operator] + [`operator operator] def operator - ['+'] | ['-'] | ['*'] | ['/'] | ['='] | ['<'] | ['>'] | ['&'] | ['|'] | - ['^'] | ['%'] | ['~'] | ['!'] | ['(' ')'] | ['[' ']'] | ['new'] | - ['delete'] | ['->'] | ['++'] | ['--'] | ['*='] | ['/='] | ['%='] | - ['+='] | ['-='] | ['>>='] | ['<<='] | ['&='] | ['^='] | ['|='] | ['=='] | - ['!='] | ['&&'] | ['||'] | [lt_eq] | [gt_eq] | [shift_left] | [shift_right] + [`+] | [`-] | [`*] | [`/] | [`=] | [`<] | [`>] | [`&] | [`|] | + [`^] | [`%] | [`~] | [`!] | [`( `)] | [`[ `]] | [`new] | + [`delete] | [`->] | [`++] | [`--] | [`*=] | [`/=] | [`%=] | + [`+=] | [`-=] | [`>>=] | [`<<=] | [`&=] | [`^=] | [`|=] | [`==] | + [`!=] | [`&&] | [`||] | [lt_eq] | [gt_eq] | [shift_left] | [shift_right] def lt_eq - ['<' '='] + [`< `=] # try { # if ( $2->leader != 0 ) { # #ifdef LOG_REDUCE @@ -1820,7 +1820,7 @@ context lookup # }; def gt_eq - ['>' '='] + [`> `=] # try { # if ( $2->leader != 0 ) { # #ifdef LOG_REDUCE @@ -1831,7 +1831,7 @@ context lookup # }; def shift_left - ['<' '<'] + [`< `<] # try { # if ( $2->leader != 0 ) { # #ifdef LOG_REDUCE @@ -1842,7 +1842,7 @@ context lookup # }; def shift_right - ['>' '>'] + [`> `>] # try { # if ( $2->leader != 0 ) { # #ifdef LOG_REDUCE @@ -1864,12 +1864,12 @@ context lookup } def template_declaration_params - ['template' '<' tpl_start template_parameter_list '>'] + [`template `< tpl_start template_parameter_list `>] { templDecl.push( 1 ) } - | ['export' 'template' '<' tpl_start template_parameter_list '>'] + | [`export `template `< tpl_start template_parameter_list `>] { templDecl.push( 1 ) } @@ -1884,7 +1884,7 @@ context lookup } def template_parameter_list - [template_parameter_list ',' template_parameter] + [template_parameter_list `, template_parameter] | [template_parameter] def template_parameter @@ -1916,7 +1916,7 @@ context lookup | [simple_type_specifier_kw_seq] def type_parameter - ['class' type_param_id type_param_init_opt] + [`class type_param_id type_param_init_opt] { Id: lookup_id = lookup_id in r2 if Id { @@ -1927,7 +1927,7 @@ context lookup } } - | ['typename' type_param_id type_param_init_opt] + | [`typename type_param_id type_param_init_opt] { Id: lookup_id = lookup_id in r2 if Id { @@ -1938,8 +1938,8 @@ context lookup } } - | ['template' '<' tpl_start template_parameter_list '>' - 'class' type_param_id templ_type_param_init_opt] + | [`template `< tpl_start template_parameter_list `> + `class type_param_id templ_type_param_init_opt] { Id: lookup_id = lookup_id in r7 if Id { @@ -1950,11 +1950,11 @@ context lookup } def templ_type_param_init_opt - ['=' id_expression] + [`= id_expression] | [] def type_param_init_opt - ['=' type_id] + [`= type_id] | [] def type_param_id @@ -1973,7 +1973,7 @@ context lookup | [] def template_argument_list - [template_argument_list ',' template_argument] + [template_argument_list `, template_argument] | [template_argument] def template_argument @@ -1981,11 +1981,11 @@ context lookup | [assignment_expression] def explicit_instantiation - ['template' declaration] - | [declaration_start decl_specifier_mult_seq 'template' declaration declaration_end] + [`template declaration] + | [declaration_start decl_specifier_mult_seq `template declaration declaration_end] def explicit_specialization - ['template' '<' '>' declaration] + [`template `< `> declaration] ## Not sure what this one is about? #explicit_specialization: @@ -1998,9 +1998,9 @@ context lookup # def original_namespace_definition - [orig_namespace_def_name '{' declaration* namespace_end '}'] + [orig_namespace_def_name `{ declaration* namespace_end `}] - def orig_namespace_def_name ['namespace' unknown_id] + def orig_namespace_def_name [`namespace unknown_id] { match r2 [Id: lookup_id] nspace: ptr<lang_object> = createLangObject( @@ -2032,9 +2032,9 @@ context lookup # def extension_namespace_definition - [ext_namespace_def_name '{' declaration* namespace_end '}'] + [ext_namespace_def_name `{ declaration* namespace_end `}] - def ext_namespace_def_name ['namespace' namespace_id] + def ext_namespace_def_name [`namespace namespace_id] { match r2 [Id: lookup_id] nspace: ptr<lang_object> = Id.obj @@ -2051,9 +2051,9 @@ context lookup # Unnamed namespace definition # def unnamed_namespace_definition - [unnamed_namespace_def_name '{' declaration* namespace_end '}'] + [unnamed_namespace_def_name `{ declaration* namespace_end `}] - def unnamed_namespace_def_name ['namespace'] + def unnamed_namespace_def_name [`namespace] { nspace: ptr<lang_object> = createLangObject( NamespaceType '<unnamed_namespace>' @@ -2071,46 +2071,46 @@ context lookup # linkage_specification # def linkage_specification - ['extern' TK_DoubleLit '{' declaration* '}'] - | ['extern' TK_DoubleLit declaration] + [`extern TK_DoubleLit `{ declaration* `}] + | [`extern TK_DoubleLit declaration] # # Exception Handling. # def try_block - ['try' compound_statement handler_seq] + [`try compound_statement handler_seq] def handler_seq [handler_seq handler] | [handler] def handler - ['catch' '(' exception_declaration ')' compound_statement] + [`catch `( exception_declaration `) compound_statement] def exception_declaration [type_specifier_seq declarator] | [type_specifier_seq abstract_declarator] | [type_specifier_seq] - | ['...'] + | [`...] def throw_expression - ['throw' assignment_expression] - | ['throw'] + [`throw assignment_expression] + | [`throw] def exception_specification_opt [exception_specification] | [] def exception_specification - ['throw' '(' type_id_list_opt ')'] + [`throw `( type_id_list_opt `)] def type_id_list_opt [type_id_list] | [] def type_id_list - [type_id_list ',' type_id] + [type_id_list `, type_id] | [type_id] def start @@ -2196,7 +2196,7 @@ printObject( '' Lookup.rootNamespace ) print( '***** UNKNOWN DECLARATORS *****\n' ) for DI: lookup::declarator_id in S { if match DI - [lookup::root_qual_opt lookup::nested_name_specifier_opt lookup::'~' UID: lookup::unknown_id] + [lookup::root_qual_opt lookup::nested_name_specifier_opt lookup::`~ UID: lookup::unknown_id] { print( UID '\n' ) } diff --git a/test/matchex.lm b/test/matchex.lm index 7bdacd30..9dd24c4d 100644 --- a/test/matchex.lm +++ b/test/matchex.lm @@ -1,18 +1,18 @@ ##### LM ##### lex token id /[a-zA-Z_][a-zA-Z0-9_]*/ - literal '=', '<', '>', '/' + literal `= `< `> `/ ignore /[ \t\n\r\v]+/ end def attr - [id '=' id] + [id `= id] def open_tag - ['<' id attr* '>'] + [`< id attr* `>] def close_tag - ['<' '/' id '>'] + [`< `/ id `>] def tag [open_tag item* close_tag] diff --git a/test/multiregion2.lm b/test/multiregion2.lm index 2d5a99b7..d69b8d4c 100644 --- a/test/multiregion2.lm +++ b/test/multiregion2.lm @@ -20,7 +20,8 @@ rl token_char /CHAR - CTL - separators/ # Literal tokens # -literal 'HTTP/', ' ', ':' +literal `HTTP/ `: +token SPT /' '/ token CRLF /CR LF/ # @@ -34,11 +35,11 @@ token request_uri /(^SP)+/ token http_number /digit+ '.' digit+/ def http_version - [ 'HTTP/' http_number ] + [ `HTTP/ http_number ] def request_line - [method ' ' request_uri - ' ' http_version CRLF] + [method SPT request_uri + SPT http_version CRLF] # # Header @@ -60,7 +61,7 @@ def field_value [fv* fv_term] def header - [field_name ':' field_value] + [field_name `: field_value] # # Request diff --git a/test/nestedcomm.lm b/test/nestedcomm.lm index 405a5198..1b1b6a48 100644 --- a/test/nestedcomm.lm +++ b/test/nestedcomm.lm @@ -24,7 +24,7 @@ end # lex - literal '(', ')' + literal `( `) token nc_data /[^()]+/ end @@ -33,7 +33,7 @@ def nc_item | [nested_comment] def nested_comment - ['(' nc_item* ')'] + [`( nc_item* `)] def nested [id*] diff --git a/test/order1.lm b/test/order1.lm index fa1843be..e510bbbd 100644 --- a/test/order1.lm +++ b/test/order1.lm @@ -34,11 +34,11 @@ def c_token_list def c [c_token*] -literal '%%' +literal `%% lex - literal '{', '}' - literal 'protocol', 'client', 'server', 'port', 'by', 'tcp', 'udp' + literal `{ `} + literal `protocol `client `server `port `by `tcp `udp token id /[A-Za-z_][A-Za-z_0-9]*/ token number /[0-9]+/ @@ -47,31 +47,31 @@ lex end def tcp_by_port - ['tcp' 'by' 'port'] + [`tcp `by `port] def udp_by_port - ['udp' 'by' 'port'] + [`udp `by `port] def attribute - ['client' id] -| ['server' id] -| ['port' number] -| ['udp' id] + [`client id] +| [`server id] +| [`port number] +| [`udp id] | [tcp_by_port] | [udp_by_port] def tcp_protocol - ['tcp' 'protocol' id '{' attribute* '}'] + [`tcp `protocol id `{ attribute* `}] def udp_protocol - ['udp' 'protocol' id '{' attribute* '}'] + [`udp `protocol id `{ attribute* `}] def protocol [tcp_protocol] | [udp_protocol] def program - [c '%%' protocol*] + [c `%% protocol*] alias output accum<c> @@ -86,7 +86,7 @@ parse P: program[ stdin ] Output: output Output = construct output [] # Take off the leading C from the input file and send it out. -match P [C: c '%%' protocol*] +match P [C: c `%% protocol*] send Output [$C] send Output diff --git a/test/order2.lm b/test/order2.lm index 5217c740..d91dd428 100644 --- a/test/order2.lm +++ b/test/order2.lm @@ -38,9 +38,9 @@ def c [c_token_list] lex - literal '%%' - literal '{', '}' - literal 'protocol', 'client', 'server', 'port', 'by', 'tcp', 'udp' + literal `%% + literal `{ `} + literal `protocol `client `server `port `by `tcp `udp token id /[A-Za-z_][A-Za-z_0-9]*/ token number /[0-9]+/ @@ -49,31 +49,31 @@ lex end def tcp_by_port - ['tcp' 'by' 'port'] + [`tcp `by `port] def udp_by_port - ['udp' 'by' 'port'] + [`udp `by `port] def attribute - ['client' id] -| ['server' id] -| ['port' number] -| ['udp' id] + [`client id] +| [`server id] +| [`port number] +| [`udp id] | [tcp_by_port] | [udp_by_port] def tcp_protocol - ['tcp' 'protocol' id '{' attribute* '}'] + [`tcp `protocol id `{ attribute* `}] def udp_protocol - ['udp' 'protocol' id '{' attribute* '}'] + [`udp `protocol id `{ attribute* `}] def protocol [tcp_protocol] | [udp_protocol] def program - [c '%%' protocol*] + [c `%% protocol*] alias output parser<c> diff --git a/test/pull2.lm b/test/pull2.lm index 9adb42f2..2ab3c9b4 100644 --- a/test/pull2.lm +++ b/test/pull2.lm @@ -1,5 +1,5 @@ ##### LM ##### -Stream: stream = open( 'working/pull2.in' 'r' ) +Stream: stream = open( 'working/pull2.in', 'r' ) String: str = Stream.pull( 10 ) print( String '\n' ) ##### IN ##### diff --git a/test/ragelambig1.lm b/test/ragelambig1.lm index da263c27..845a07b5 100644 --- a/test/ragelambig1.lm +++ b/test/ragelambig1.lm @@ -1,10 +1,10 @@ ##### LM ##### lex ignore /[\t\n ]+/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** token word /[a-zA-Z_][a-zA-Z0-9_]*/ token uint /[0-9]+/ @@ -18,50 +18,50 @@ def start } def expression - [expression '|' term] -| [expression '&' term] -| [expression '-' term] -| [expression '--' term] + [expression `| term] +| [expression `& term] +| [expression `- term] +| [expression `-- term] | [term] def term [term factor_with_rep] { - if match lhs [term '-' uint] + if match lhs [term `- uint] reject } -| [term '.' factor_with_rep] -| [term ':>' factor_with_rep] -| [term ':>>' factor_with_rep] -| [term '<:' factor_with_rep] +| [term `. factor_with_rep] +| [term `:> factor_with_rep] +| [term `:>> factor_with_rep] +| [term `<: factor_with_rep] | [factor_with_rep] def factor_with_rep - [factor_with_rep '*'] -| [factor_with_rep '**'] -| [factor_with_rep '?'] -| [factor_with_rep '+'] -| [factor_with_rep '{' factor_rep_num '}'] -| [factor_with_rep '{' ',' factor_rep_num '}'] -| [factor_with_rep '{' factor_rep_num ',' '}'] -| [factor_with_rep '{' factor_rep_num ',' factor_rep_num '}'] + [factor_with_rep `*] +| [factor_with_rep `**] +| [factor_with_rep `?] +| [factor_with_rep `+] +| [factor_with_rep `{ factor_rep_num `}] +| [factor_with_rep `{ `, factor_rep_num `}] +| [factor_with_rep `{ factor_rep_num `, `}] +| [factor_with_rep `{ factor_rep_num `, factor_rep_num `}] | [factor_with_neg] def factor_rep_num [uint] def factor_with_neg - ['!' factor_with_neg] -| ['^' factor_with_neg] + [`! factor_with_neg] +| [`^ factor_with_neg] | [factor] def factor [alphabet_num] | [word] -| ['(' expression ')'] +| [`( expression `)] def alphabet_num [uint] -| ['-' uint] +| [`- uint] parse start[ stdin ] diff --git a/test/ragelambig2.lm b/test/ragelambig2.lm index 74ce32ff..39602bcf 100644 --- a/test/ragelambig2.lm +++ b/test/ragelambig2.lm @@ -1,10 +1,10 @@ ##### LM ##### lex ignore /[\t\n ]+/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** token word /[a-zA-Z_][a-zA-Z0-9_]*/ token uint /[0-9]+/ @@ -18,10 +18,10 @@ def start } def expression - [expression '|' term] -| [expression '&' term] -| [expression '-' term] -| [expression '--' term] + [expression `| term] +| [expression `& term] +| [expression `- term] +| [expression `-- term] | [term] def term @@ -31,38 +31,38 @@ def term def more_term [] | [factor_with_rep more_term] -| ['.' factor_with_rep more_term] -| [':>' factor_with_rep more_term] -| [':>>' factor_with_rep more_term] -| ['<:' factor_with_rep more_term] +| [`. factor_with_rep more_term] +| [`:> factor_with_rep more_term] +| [`:>> factor_with_rep more_term] +| [`<: factor_with_rep more_term] def factor_with_rep - [factor_with_rep '*'] -| [factor_with_rep '**'] -| [factor_with_rep '?'] -| [factor_with_rep '+'] -| [factor_with_rep '{' factor_rep_num '}'] -| [factor_with_rep '{' ',' factor_rep_num '}'] -| [factor_with_rep '{' factor_rep_num ',' '}'] -| [factor_with_rep '{' factor_rep_num ',' factor_rep_num '}'] + [factor_with_rep `*] +| [factor_with_rep `**] +| [factor_with_rep `?] +| [factor_with_rep `+] +| [factor_with_rep `{ factor_rep_num `}] +| [factor_with_rep `{ `, factor_rep_num `}] +| [factor_with_rep `{ factor_rep_num `, `}] +| [factor_with_rep `{ factor_rep_num `, factor_rep_num `}] | [factor_with_neg] def factor_rep_num [uint] def factor_with_neg - ['!' factor_with_neg] -| ['^' factor_with_neg] + [`! factor_with_neg] +| [`^ factor_with_neg] | [factor] def factor [alphabet_num] | [word] -| ['(' expression ')'] +| [`( expression `)] def alphabet_num [uint] -| ['-' uint] +| [`- uint] parse start[ stdin ] print( '\n' ) diff --git a/test/ragelambig3.lm b/test/ragelambig3.lm index a7b37d7d..74b72546 100644 --- a/test/ragelambig3.lm +++ b/test/ragelambig3.lm @@ -1,10 +1,10 @@ ##### LM ##### lex ignore /[\t\n ]+/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** token word /[a-zA-Z_][a-zA-Z0-9_]*/ token uint /[0-9]+/ @@ -18,10 +18,10 @@ def start } def expression - [expression '|' term_short] -| [expression '&' term_short] -| [expression '-' term_short] -| [expression '--' term_short] + [expression `| term_short] +| [expression `& term_short] +| [expression `- term_short] +| [expression `-- term_short] | [term_short] # Works, but is confusing. @@ -31,38 +31,38 @@ def term_short def term [term factor_with_rep] -| [term '.' factor_with_rep] -| [term ':>' factor_with_rep] -| [term ':>>' factor_with_rep] -| [term '<:' factor_with_rep] +| [term `. factor_with_rep] +| [term `:> factor_with_rep] +| [term `:>> factor_with_rep] +| [term `<: factor_with_rep] | [factor_with_rep] def factor_with_rep - [factor_with_rep '*'] -| [factor_with_rep '**'] -| [factor_with_rep '?'] -| [factor_with_rep '+'] -| [factor_with_rep '{' factor_rep_num '}'] -| [factor_with_rep '{' ',' factor_rep_num '}'] -| [factor_with_rep '{' factor_rep_num ',' '}'] -| [factor_with_rep '{' factor_rep_num ',' factor_rep_num '}'] + [factor_with_rep `*] +| [factor_with_rep `**] +| [factor_with_rep `?] +| [factor_with_rep `+] +| [factor_with_rep `{ factor_rep_num `}] +| [factor_with_rep `{ `, factor_rep_num `}] +| [factor_with_rep `{ factor_rep_num `, `}] +| [factor_with_rep `{ factor_rep_num `, factor_rep_num `}] | [factor_with_neg] def factor_rep_num [uint] def factor_with_neg - ['!' factor_with_neg] -| ['^' factor_with_neg] + [`! factor_with_neg] +| [`^ factor_with_neg] | [factor] def factor [alphabet_num] | [word] -| ['(' expression ')'] +| [`( expression `)] def alphabet_num [uint] -| ['-' uint] +| [`- uint] parse start[ stdin ] print( '\n' ) diff --git a/test/ragelambig4.lm b/test/ragelambig4.lm index 8a4b7b51..e841b806 100644 --- a/test/ragelambig4.lm +++ b/test/ragelambig4.lm @@ -1,10 +1,10 @@ ##### LM ##### lex ignore /[\t\n ]+/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** token word /[a-zA-Z_][a-zA-Z0-9_]*/ token uint /[0-9]+/ @@ -20,10 +20,10 @@ def start def expression [term expression_op*] def expression_op - ['|' term] -| ['&' term] -| ['-' term] -| ['--' term] + [`| term] +| [`& term] +| [`- term] +| [`-- term] def term [factor_rep term_op_list_short] @@ -34,39 +34,39 @@ def term_op_list_short def term_op [factor_rep] -| ['.' factor_rep] -| [':>' factor_rep] -| [':>>' factor_rep] -| ['<:' factor_rep] +| [`. factor_rep] +| [`:> factor_rep] +| [`:>> factor_rep] +| [`<: factor_rep] def factor_rep [factor_neg factor_rep_op*] def factor_rep_op - ['*'] -| ['**'] -| ['?'] -| ['+'] -| ['{' factor_rep_num '}'] -| ['{' ',' factor_rep_num '}'] -| ['{' factor_rep_num ',' '}'] -| ['{' factor_rep_num ',' factor_rep_num '}'] + [`*] +| [`**] +| [`?] +| [`+] +| [`{ factor_rep_num `}] +| [`{ `, factor_rep_num `}] +| [`{ factor_rep_num `, `}] +| [`{ factor_rep_num `, factor_rep_num `}] def factor_rep_num [uint] def factor_neg - ['!' factor_neg] -| ['^' factor_neg] + [`! factor_neg] +| [`^ factor_neg] | [factor] def factor [alphabet_num] | [word] -| ['(' expression ')'] +| [`( expression `)] def alphabet_num [uint] -| ['-' uint] +| [`- uint] parse start[ stdin ] print( '\n' ) diff --git a/test/rediv.lm b/test/rediv.lm index a4a0b88a..c5ac9553 100644 --- a/test/rediv.lm +++ b/test/rediv.lm @@ -52,7 +52,7 @@ lex token number /[0-9]+/ token string /s_string | d_string/ - literal '+', '-', '*', ';', '/' + literal `+ `- `* `; `/ token slash /'/'/ token semi /';'/ @@ -63,25 +63,24 @@ def factor [ident] | [number] | [string] -| ['/' regex_body regex_close] +| [`/ regex_body regex_close] def term - [term '*' factor] -| [term '/' factor] + [term `* factor] +| [term `/ factor] | [factor] def expr - [expr '+' term] -| [expr '-' term] + [expr `+ term] +| [expr `- term] | [term] def statement - [expr ';'] + [expr `;] def start [statement*] - parse S: start[ stdin ] for I:orlit_item in S { diff --git a/test/ref1.lm b/test/ref1.lm index 1ad8e159..558fe5d7 100644 --- a/test/ref1.lm +++ b/test/ref1.lm @@ -1,14 +1,14 @@ ### LM ### lex - literal 'application' - literal ';' + literal `application + literal `; token id /[A-Za-z_][A-Za-z_0-9]*/ ignore /[ \t\r\n]+/ end def definition - ['application' id ';'] + [`application id `;] def program [definition*] diff --git a/test/ref2.lm b/test/ref2.lm index 5abbfe2f..6bf8df9d 100644 --- a/test/ref2.lm +++ b/test/ref2.lm @@ -1,14 +1,14 @@ ### LM ### lex - literal 'application' - literal ';' + literal `application + literal `; token id /[A-Za-z_][A-Za-z_0-9]*/ ignore /[ \t\r\n]+/ end def definition - ['application' id ';'] + [`application id `;] def program [definition*] diff --git a/test/reor2.lm b/test/reor2.lm index 4b3c1207..51f0dd31 100644 --- a/test/reor2.lm +++ b/test/reor2.lm @@ -3,7 +3,8 @@ context undo lex ignore /[ ]+/ - literal ';', '\n' + literal `; + token NL /'\n'/ token id /[a-zA-Z_]+/ end @@ -11,8 +12,7 @@ context undo [id] def start - [item* ';' '\n'] - + [item* `; NL] end cons Undo: undo[] diff --git a/test/reparse.lm b/test/reparse.lm index 474dbac1..907ca6a5 100644 --- a/test/reparse.lm +++ b/test/reparse.lm @@ -1,13 +1,13 @@ ##### LM ##### lex ignore /space+/ - literal '*', '(', ')' + literal `* `( `) token id /[a-zA-Z_]+/ end def item [id] -| ['(' item* ')'] +| [`( item* `)] def start [item*] diff --git a/test/repeat1.lm b/test/repeat1.lm index 45e9750c..315a63e2 100644 --- a/test/repeat1.lm +++ b/test/repeat1.lm @@ -1,13 +1,13 @@ ##### LM ##### lex ignore /space+/ - literal '*', '(', ')' + literal `* `( `) token id /[a-zA-Z_]+/ end def item [id] -| ['(' item* ')'] +| [`( item* `)] def start [item*] diff --git a/test/rhsref1.lm b/test/rhsref1.lm index 4ea15a0d..c905d2a7 100644 --- a/test/rhsref1.lm +++ b/test/rhsref1.lm @@ -1,8 +1,8 @@ ##### LM ##### lex - literal 'var', 'if', 'then', 'else', 'while', 'do', 'for', 'read', 'write', - 'end', 'to', 'goto' - literal ':=', '!=', ';', '+', '-', '*', '/', '=', '(', ')', ':' + literal `var `if `then `else `while `do `for `read `write + `end `to `goto + literal `:= `!= `; `+ `- `* `/ `= `( `) `: ignore /'//' [^\n]* '\n'/ ignore /[\n\t ]+/ @@ -27,65 +27,65 @@ def statement | [goto_statement] def declaration - ['var' id ';'] + [`var id `;] def assignment_statement - [id ':=' expression ';'] + [id `:= expression `;] def if_statement - ['if' expression 'then' statement* opt_else_statement 'end'] + [`if expression `then statement* opt_else_statement `end] def opt_else_statement - ['else' statement*] + [`else statement*] | [] def while_statement - ['while' expression 'do' statement* 'end'] + [`while expression `do statement* `end] def do_statement - ['do' statement* 'while' expression ';'] + [`do statement* `while expression `;] def for_statement - ['for' id ':=' expression 'to' expression 'do' statement* 'end'] + [`for id `:= expression `to expression `do statement* `end] def read_statement - ['read' id ';'] + [`read id `;] def write_statement - ['write' expression ';'] + [`write expression `;] def expression [Term: term] | [expression eqop Term: term] -def eqop ['='] | ['!='] +def eqop [`=] | [`!=] def term [Factor: factor] | [term addop Factor: factor] -def addop ['+'] | ['-'] +def addop [`+] | [`-] def factor [Primary: primary] | [factor mulop Primary: primary] -def mulop ['*'] | ['/'] +def mulop [`*] | [`/] def primary [id] | [lit] -| ['(' expression ')'] +| [`( expression `)] def lit [integernumber] | [stringlit] def labelled_statement - [id ':' statement] + [id `: statement] def goto_statement - ['goto' id ';'] + [`goto id `;] parse P: program[stdin] diff --git a/test/rhsref2.lm b/test/rhsref2.lm index 20942559..4c831d7e 100644 --- a/test/rhsref2.lm +++ b/test/rhsref2.lm @@ -1,8 +1,8 @@ ##### LM ##### lex - literal '-', '=', ';', '*', '->' - literal 'option' + literal `- `= `; `* `-> + literal `option token id /[A-Za-z_][A-Za-z_0-9]*/ @@ -11,8 +11,8 @@ end def arg_option I: int - ['option' '-' Short: id '->' Func: id ';'] -| ['option' '-' '-' Long: id '->' Func: id ';'] + [`option `- Short: id `-> Func: id `;] +| [`option `- `- Long: id `-> Func: id `;] def arg_defs [arg_option+] diff --git a/test/rubyhere.lm b/test/rubyhere.lm index 7d5113e4..836b18cf 100644 --- a/test/rubyhere.lm +++ b/test/rubyhere.lm @@ -7,7 +7,7 @@ context rubyhere ignore /[ \t\n]+/ token id /ident_pattern/ token number /number_pattern/ - literal '<<', '*', ',', '(', ')', '!' + literal `<< `* `, `( `) `! end HereId: str @@ -58,7 +58,7 @@ context rubyhere [here_line* here_close_id] def heredoc - ['<<' here_id] + [`<< here_id] def primary [id] @@ -69,10 +69,10 @@ context rubyhere [primary arglist_more*] def arglist_more - [',' primary] + [`, primary] def call - [id '(' arglist? ')'] + [id `( arglist? `)] def statement [primary] @@ -81,7 +81,7 @@ context rubyhere token foobar /any+/ def item - [statement '!'] + [statement `!] | [foobar] def start diff --git a/test/string.lm b/test/string.lm index 4cc5e86a..ea41cb23 100644 --- a/test/string.lm +++ b/test/string.lm @@ -9,34 +9,34 @@ def str_item | [str_chr] def string - ['"' str_item* '"'] + [`" str_item* `"] lex token ident /[a-zA-Z_]+/ token number /[0-9]+/ - literal '+', '*', ';', '"', '\'', '(', ')' - literal '+=', '-=', '*=' + literal `+ `* `; `" `' `( `) + literal `+= `-= `*= ignore wp /[ \t\n]+/ end def expr - [expr '+' term] + [expr `+ term] | [term] def term - [term '*' primary] + [term `* primary] | [primary] def primary [number] | [ident] | [string] -| ['(' expr ')'] +| [`( expr `)] def expr_list - [expr_list expr ';'] + [expr_list expr `;] | [] def start diff --git a/test/superid.lm b/test/superid.lm index 4f16aca8..0d4060f0 100644 --- a/test/superid.lm +++ b/test/superid.lm @@ -1,7 +1,9 @@ ##### LM ##### context si lex - literal '!', 'a', ';\n' + literal `! `a + + token SEMI_NL /';\n'/ token id /'a'|'b'/ { @@ -27,7 +29,7 @@ context si def item1 msg: str - [ e1 '!' 'a' super_id super_id 'a'] + [ e1 `! `a super_id super_id `a] { lhs.msg = 'this is item1\n' } @@ -43,15 +45,15 @@ context si def item2 msg: str - [ e2 '!' 'a' super_id super_id 'a'] + [ e2 `! `a super_id super_id `a] { lhs.msg = 'this is item2\n' } def start - [item1 ';\n'] - | [item2 ';\n'] + [item1 SEMI_NL] + | [item2 SEMI_NL] { match lhs [Item2:item2 ';\n'] print( Item2.msg ) @@ -70,5 +72,5 @@ new_id = 14 old_id = NIL new_id = 13 this is item2 -<si::start><si::item2><si::e2></si::e2><si::_literal_0001>!</si::_literal_0001><si::_literal_0003>a</si::_literal_0003><si::super_id>b</si::super_id><si::super_id>b</si::super_id><si::_literal_0003>a</si::_literal_0003></si::item2><si::_literal_0005>; -</si::_literal_0005></si::start> +<si::start><si::item2><si::e2></si::e2><si::_literal_0001>!</si::_literal_0001><si::_literal_0003>a</si::_literal_0003><si::super_id>b</si::super_id><si::super_id>b</si::super_id><si::_literal_0003>a</si::_literal_0003></si::item2><si::SEMI_NL>; +</si::SEMI_NL></si::start> diff --git a/test/tags1.lm b/test/tags1.lm index 04a3f73b..ef17c460 100644 --- a/test/tags1.lm +++ b/test/tags1.lm @@ -16,7 +16,8 @@ context tags # Any single character can be a literal lex - literal '!\n', ';\n' + token BANG_NL /'!\n'/ + token SEMI_NL /';\n'/ # Ignore whitespace. ignore /rl_ws/ @@ -67,14 +68,14 @@ context tags [open_tag tag* close_tag] def start - [tag* ';\n'] + [tag* SEMI_NL] { print_xml( TS ) print_xml( lhs ) print( 'got structure\n' ) } - | [id* ';\n'] + | [id* SEMI_NL] { print_xml( TS ) print_xml( lhs ) @@ -88,5 +89,5 @@ parse tags::start(Tags)[stdin] ##### IN ##### y y a i i b c c m m n n b a; ##### EXP ##### -<tags::tag_stack><tags::id>sentinal</tags::id><tags::tag_stack></tags::tag_stack></tags::tag_stack><tags::start><tags::_repeat_tag><tags::tag><tags::open_tag><tags::id>y</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>y</tags::id></tags::close_tag></tags::tag><tags::tag><tags::open_tag><tags::id>a</tags::id></tags::open_tag><tags::_repeat_tag><tags::tag><tags::open_tag><tags::id>i</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>i</tags::id></tags::close_tag></tags::tag><tags::tag><tags::open_tag><tags::id>b</tags::id></tags::open_tag><tags::_repeat_tag><tags::tag><tags::open_tag><tags::id>c</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>c</tags::id></tags::close_tag></tags::tag><tags::tag><tags::open_tag><tags::id>m</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>m</tags::id></tags::close_tag></tags::tag><tags::tag><tags::open_tag><tags::id>n</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>n</tags::id></tags::close_tag></tags::tag></tags::_repeat_tag><tags::close_tag><tags::id>b</tags::id></tags::close_tag></tags::tag></tags::_repeat_tag><tags::close_tag><tags::id>a</tags::id></tags::close_tag></tags::tag></tags::_repeat_tag><tags::_literal_0003>; -</tags::_literal_0003></tags::start>got structure +<tags::tag_stack><tags::id>sentinal</tags::id><tags::tag_stack></tags::tag_stack></tags::tag_stack><tags::start><tags::_repeat_tag><tags::tag><tags::open_tag><tags::id>y</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>y</tags::id></tags::close_tag></tags::tag><tags::tag><tags::open_tag><tags::id>a</tags::id></tags::open_tag><tags::_repeat_tag><tags::tag><tags::open_tag><tags::id>i</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>i</tags::id></tags::close_tag></tags::tag><tags::tag><tags::open_tag><tags::id>b</tags::id></tags::open_tag><tags::_repeat_tag><tags::tag><tags::open_tag><tags::id>c</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>c</tags::id></tags::close_tag></tags::tag><tags::tag><tags::open_tag><tags::id>m</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>m</tags::id></tags::close_tag></tags::tag><tags::tag><tags::open_tag><tags::id>n</tags::id></tags::open_tag><tags::_repeat_tag></tags::_repeat_tag><tags::close_tag><tags::id>n</tags::id></tags::close_tag></tags::tag></tags::_repeat_tag><tags::close_tag><tags::id>b</tags::id></tags::close_tag></tags::tag></tags::_repeat_tag><tags::close_tag><tags::id>a</tags::id></tags::close_tag></tags::tag></tags::_repeat_tag><tags::SEMI_NL>; +</tags::SEMI_NL></tags::start>got structure diff --git a/test/tags2.lm b/test/tags2.lm index 2c22f326..e83b113d 100644 --- a/test/tags2.lm +++ b/test/tags2.lm @@ -43,7 +43,7 @@ lex # The opening quote belongs to the tag region. def sq_string - [ '\'' sq_item* sq_close ] + [ `' sq_item* sq_close ] end # @@ -65,14 +65,14 @@ lex # The opening quote belongs to the tag region. def dq_string - [ '"' dq_item* dq_close ] + [ `" dq_item* dq_close ] end # # Tag elements. # lex - literal '\'', '\"', '=', '\/' + literal `' `" `= `/ # Within this region whitespace is not significant. ignore xml_space / (0x20 | 0x9 | 0xD | 0xA)+ / @@ -83,7 +83,7 @@ lex token attr_name / name / end -literal '>' +literal `> # # Top Level @@ -99,7 +99,7 @@ lex # Opening a tag. - literal '<' + literal `< # # Character Data @@ -117,16 +117,16 @@ def attribute_value | [ dq_string ] def attribute - [ attr_name '=' attribute_value ] + [ attr_name `= attribute_value ] def empty_tag - [ '<' attr_name attribute* '/' '>' ] + [ `< attr_name attribute* `/ `> ] def close_tag - [ '<' '/' attr_name '>' ] + [ `< `/ attr_name `> ] def open_tag - [ '<' attr_name attribute* '>' ] + [ `< attr_name attribute* `> ] def tag [open_tag content close_tag] diff --git a/test/tags3.lm b/test/tags3.lm index ef84ac8f..645b00ba 100644 --- a/test/tags3.lm +++ b/test/tags3.lm @@ -22,7 +22,7 @@ context tags lex ignore /space+/ token attr_name /def_name_char+/ - literal '=' + literal `= end # Scanner for attribute values. @@ -33,7 +33,7 @@ context tags token unq_val /[^ \t\r\n<>"'] [^ \t\r\n<>]*/ end - literal '>', '/>' + literal `> `/> # # Tokens @@ -41,7 +41,7 @@ context tags lex ignore /space+/ - literal '<', '</', '<!DOCTYPE' + literal `< `</ `<!DOCTYPE token doc_data /[^<]+/ token comment /"<!--" any* :>> "-->"/ end @@ -103,14 +103,14 @@ context tags # covering dt_name lex ignore /space+/ - literal 'SYSTEM', 'PUBLIC' + literal `SYSTEM `PUBLIC end - def DOCTYPE ['<!DOCTYPE' dt_name external_id dt_bl? dt_close] + def DOCTYPE [`<!DOCTYPE dt_name external_id dt_bl? dt_close] def external_id - ['SYSTEM' dt_literal?] - | ['PUBLIC' dt_literal dt_literal?] + [`SYSTEM dt_literal?] + | [`PUBLIC dt_literal dt_literal?] # # Tags, with optionanal close. @@ -120,14 +120,14 @@ context tags [open_tag item* opt_close_tag] def open_tag - ['<' tag_id attr* '>'] + [`< tag_id attr* `>] { TagStack = construct tag_stack [r2 TagStack] } def opt_close_tag - ['</' close_id '>'] + [`</ close_id `>] { match TagStack [Top:tag_id Rest:tag_stack] if r2.data == Top.data @@ -146,13 +146,13 @@ context tags # Empty tags # def empty_tag - ['<' tag_id attr* '/>'] + [`< tag_id attr* `/>] # # Stray close tags # def stray_close - ['</' stray_close_id '>'] + [`</ stray_close_id `>] # @@ -162,7 +162,7 @@ context tags def attr [attr_name eql_attr_val?] - def eql_attr_val ['=' attr_val] + def eql_attr_val [`= attr_val] def attr_val [squote_val] @@ -196,7 +196,7 @@ context tags { for T: open_tag in Start { require T - ["<img" AttrList: attr* '>'] + ["<img" AttrList: attr* ">"] haveAlt: bool = false for A: attr in T { diff --git a/test/tags4.lm b/test/tags4.lm index 1136d85f..f710378c 100644 --- a/test/tags4.lm +++ b/test/tags4.lm @@ -28,10 +28,10 @@ context tags lex ignore /space+/ token attr_name /def_name_char+/ - literal '=' + literal `= end - literal '>', '/>' + literal `> `/> # Scanner for attribute values. lex @@ -48,7 +48,7 @@ context tags lex ignore /space+/ - literal '<', '</', '<!DOCTYPE' + literal `< `</ `<!DOCTYPE token close_tag /'</' [\t ]* [a-zA-Z]+ '>'/ @@ -136,14 +136,14 @@ context tags # covering dt_name lex ignore /space+/ - literal 'SYSTEM', 'PUBLIC' + literal `SYSTEM `PUBLIC end - def DOCTYPE ['<!DOCTYPE' dt_name external_id dt_bl? dt_close] + def DOCTYPE [`<!DOCTYPE dt_name external_id dt_bl? dt_close] def external_id - ['SYSTEM' dt_literal?] - | ['PUBLIC' dt_literal dt_literal?] + [`SYSTEM dt_literal?] + | [`PUBLIC dt_literal dt_literal?] # # Tags, with optionanal close. @@ -156,7 +156,7 @@ context tags [open_tag item* missing_close_id] def open_tag - ['<' tag_id attr* '>'] + [`< tag_id attr* `>] { TagStack = construct tag_stack [r2 TagStack] @@ -166,7 +166,7 @@ context tags # Empty tags # def empty_tag - ['<' tag_id attr* '/>'] + [`< tag_id attr* `/>] # # Stray close tags @@ -182,7 +182,7 @@ context tags def attr [attr_name eql_attr_val?] - def eql_attr_val ['=' attr_val] + def eql_attr_val [`= attr_val] def attr_val [squote_val] diff --git a/test/tcontext1.lm b/test/tcontext1.lm index b40aa2d5..4705b9e6 100644 --- a/test/tcontext1.lm +++ b/test/tcontext1.lm @@ -9,8 +9,8 @@ end lex ignore /[\t ]+/ ignore /'#' [^\n]*/ - literal ';' - literal '\n' + literal `; + token NL /'\n'/ end # Required whitespace, but newline is not allowed. @@ -21,7 +21,7 @@ token ws_no_nl } def method_call - [tIDENTIFIER ws_no_nl tIDENTIFIER ';' '\n'] + [tIDENTIFIER ws_no_nl tIDENTIFIER `; NL] parse R: method_call[stdin] @@ -31,5 +31,5 @@ print( '\n' ) ##### IN ##### a bc; ##### EXP ##### -<method_call><tIDENTIFIER>a</tIDENTIFIER><ws_no_nl> </ws_no_nl><tIDENTIFIER>bc</tIDENTIFIER><_literal_000b>;</_literal_000b><_literal_000d> -</_literal_000d></method_call> +<method_call><tIDENTIFIER>a</tIDENTIFIER><ws_no_nl> </ws_no_nl><tIDENTIFIER>bc</tIDENTIFIER><_literal_000b>;</_literal_000b><NL> +</NL></method_call> diff --git a/test/til.lm b/test/til.lm index 8b27b554..6a93ab35 100644 --- a/test/til.lm +++ b/test/til.lm @@ -1,8 +1,9 @@ ##### LM ##### lex - literal 'var', 'if', 'then', 'else', 'while', 'do', 'for', 'read', 'write', - 'end', 'to', 'goto' - literal ':=', '!=', ';', '+', '-', '*', '/', '=', '(', ')', ':' + literal `var `if `then `else `while `do `for `read `write + `end `to `goto + + literal `:= `!= `; `+ `- `* `/ `= `( `) `: ignore /'//' [^\n]* '\n'/ ignore /[\n\t ]+/ @@ -27,78 +28,78 @@ def statement | [goto_statement] def declaration - ['var' id ';'] + [`var id `;] def assignment_statement - [id ':=' expression ';'] + [id `:= expression `;] def if_statement - ['if' expression 'then' statement* opt_else_statement 'end'] + [`if expression `then statement* opt_else_statement `end] def opt_else_statement - ['else' statement*] + [`else statement*] | [] def while_statement - ['while' expression 'do' statement* 'end'] + [`while expression `do statement* `end] def do_statement - ['do' statement* 'while' expression ';'] + [`do statement* `while expression `;] def for_statement - ['for' id ':=' expression 'to' expression 'do' statement* 'end'] + [`for id `:= expression `to expression `do statement* `end] def read_statement - ['read' id ';'] + [`read id `;] def write_statement - ['write' expression ';'] + [`write expression `;] def expression [term] | [expression eqop term] -def eqop ['='] | ['!='] +def eqop [`=] | [`!=] def term [factor] | [term addop factor] -def addop ['+'] | ['-'] +def addop [`+] | [`-] def factor [primary] | [factor mulop primary] -def mulop ['*'] | ['/'] +def mulop [`*] | [`/] def primary [id] | [lit] -| ['(' expression ')'] +| [`( expression `)] def lit [integernumber] | [stringlit] def labelled_statement - [id ':' statement] + [id `: statement] def goto_statement - ['goto' id ';'] + [`goto id `;] parse P: program[stdin] #for S:statement* in P #{ -# if match S [L0: id ':' -# First: statement +# if match S [L0: id ':' +# First: statement # Rest: statement*] # { # for Check: statement* in Rest # { -# if match Check -# ['if' E: expression 'then' +# if match Check +# ['if' E: expression 'then' # 'goto' Targ: id ';' # 'end' # T: statement*] @@ -122,8 +123,8 @@ parse P: program[stdin] for S: statement* in P { - if match S [Label: id ':' - First: statement + if match S [Label: id `: + First: statement Rest: statement*] { Expr: expression @@ -134,10 +135,10 @@ for S: statement* in P # restricts our search to the same nesting depth as the label. for Check: statement* in Rest { - if match Check - ['if' E: expression 'then' - 'goto' L:id ';' - 'end' + if match Check + [`if E: expression `then + `goto L:id `; + `end SL: statement*] { Expr = E @@ -153,7 +154,7 @@ for S: statement* in P # If a goto was found, then perform the rewrite. if ( Expr ) { - # Replace the labelled statement through to the goto + # Replace the labelled statement through to the goto # with a do ... while. S = construct statement* [ "do diff --git a/test/translate1.lm b/test/translate1.lm index e062b530..4403ca62 100644 --- a/test/translate1.lm +++ b/test/translate1.lm @@ -1,7 +1,7 @@ ##### LM ##### lex ignore /space+/ - literal '*', '(', ')' + literal `* `( `) token id /[a-zA-Z_]+/ { t: str = input.pull( match_length ) @@ -14,7 +14,7 @@ def foo [id] def item [id] | [foo] -| ['(' item* ')'] +| [`( item* `)] def start [item*] diff --git a/test/translate2.lm b/test/translate2.lm index 8412eafa..47bda35d 100644 --- a/test/translate2.lm +++ b/test/translate2.lm @@ -1,13 +1,13 @@ ##### LM ##### lex ignore /space+/ - literal '#', '{', '}' + literal `# `{ `} token id2 /[a-zA-Z_]+/ end def item2 [id2] -| ['{' item2* '}'] +| [`{ item2* `}] def start2 [item2*] @@ -16,7 +16,8 @@ context ctx lex ignore /space+/ - literal '*', '(', ')', '!', ';\n' + literal `* `( `) `! + token SEMI_NL /';\n'/ token id /[a-zA-Z_0-9]+/ token ddd /'...'/ { @@ -30,7 +31,7 @@ context ctx def item [id] - | ['(' item* ')'] + | [`( item* `)] def A [] { print( 'A\n' ) @@ -42,8 +43,8 @@ context ctx def start - [A item* '!'] - | [B item* ';\n'] + [A item* `!] + | [B item* SEMI_NL] end # ctx diff --git a/test/travs1.lm b/test/travs1.lm index 22dd6dd7..c2f7171d 100644 --- a/test/travs1.lm +++ b/test/travs1.lm @@ -1,10 +1,10 @@ ##### LM ##### lex ignore /[\t\n ]+/ - literal '^', '|', '-', ',', ':', '!', '?', '.' - literal '(', ')', '{', '}', '*', '&', '+' + literal `^ `| `- `, `: `! `? `. + literal `( `) `{ `} `* `& `+ - literal '--', ':>', ':>>', '<:', '->', '**' + literal `-- `:> `:>> `<: `-> `** token word /[a-zA-Z_][a-zA-Z0-9_]*/ token uint /[0-9]+/ @@ -16,10 +16,10 @@ def start [expression] def expression [term expression_op*] def expression_op - ['|' term] -| ['&' term] -| ['-' term] -| ['--' term] + [`| term] +| [`& term] +| [`- term] +| [`-- term] def term [factor_rep term_rest] @@ -30,35 +30,35 @@ def term_rest def term_op [factor_rep] -| ['.' factor_rep] -| [':>' factor_rep] -| [':>>' factor_rep] -| ['<:' factor_rep] +| [`. factor_rep] +| [`:> factor_rep] +| [`:>> factor_rep] +| [`<: factor_rep] def factor_rep [factor_neg factor_rep_op*] def factor_rep_op - ['*'] -| ['**'] -| ['?'] -| ['+'] -| ['{' factor_rep_num '}'] -| ['{' ',' factor_rep_num '}'] -| ['{' factor_rep_num ',' '}'] -| ['{' factor_rep_num ',' factor_rep_num '}'] + [`*] +| [`**] +| [`?] +| [`+] +| [`{ factor_rep_num `}] +| [`{ `, factor_rep_num `}] +| [`{ factor_rep_num `, `}] +| [`{ factor_rep_num `, factor_rep_num `}] def factor_rep_num [uint] def factor_neg - ['!' factor_neg] -| ['^' factor_neg] + [`! factor_neg] +| [`^ factor_neg] | [factor] def factor [alphabet_num] | [word] -| ['(' expression ')'] +| [`( expression `)] def alphabet_num [uint] diff --git a/test/undofrag1.lm b/test/undofrag1.lm index 4cd23a7e..a997cb8a 100644 --- a/test/undofrag1.lm +++ b/test/undofrag1.lm @@ -1,13 +1,14 @@ ##### LM ##### + lex ignore /space+/ - literal '#', '{', '}' + literal `# `{ `} token id2 /[a-zA-Z_]+/ end def item2 [id2] -| ['{' item2* '}'] +| [`{ item2* `}] def start2 [item2*] @@ -19,13 +20,14 @@ context ctx lex ignore /space+/ - literal '*', '(', ')', '!', ';\n' + literal `* `( `) `! + token semi_nl /';\n'/ token id /[a-zA-Z_]+/ end def item [id] - | ['(' item* ')'] + | [`( item* `)] def A [] { @@ -39,8 +41,8 @@ context ctx } def start1 - [A item* '!'] - | [B item* ';\n'] + [A item* `!] + | [B item* semi_nl] end # ctx @@ -55,6 +57,7 @@ send CTX.SP "{e}f g" print( Input ) print( CTX.SP() '\n' ) + ##### IN ##### a b c ( d ) e f g ; ##### EXP ##### diff --git a/test/undofrag2.lm b/test/undofrag2.lm index 35e5f5c5..bbade5e6 100644 --- a/test/undofrag2.lm +++ b/test/undofrag2.lm @@ -3,7 +3,8 @@ context undo lex ignore /( ' ' | '\t')+/ - literal '*', '(', ')', '^', ';', '\n' + literal `* `( `) `^ `; + token NL /'\n'/ token id /[a-zA-Z_]+/ end @@ -11,7 +12,7 @@ context undo def out_item [id] - | ['(' item* ')'] + | [`( item* `)] def out [out_item*] @@ -21,7 +22,7 @@ context undo { send Out [r1] } - | ['(' item* ')'] + | [`( item* `)] { send Out ['('] send Out [r2] @@ -31,10 +32,9 @@ context undo def A1 [] def A2 [] - def start - [A1 item* '^'] - | [A2 item* ';' '\n'] + [A1 item* `^] + | [A2 item* `; NL] end # undo diff --git a/test/undofrag3.lm b/test/undofrag3.lm index b8ca8fb7..ed96cba6 100644 --- a/test/undofrag3.lm +++ b/test/undofrag3.lm @@ -3,7 +3,8 @@ context undo lex ignore /( ' ' | '\t' )+/ - literal '*', '(', ')', '^', ';', '\n', '.' + literal `* `( `) `^ `; `. + token NL /'\n'/ token id /[a-zA-Z_]+/ end @@ -11,7 +12,7 @@ context undo def out_item [id] - | ['(' item* ')'] + | [`( item* `)] def out [out_item*] @@ -21,7 +22,7 @@ context undo { send Out [r1] } - | ['(' item* ')'] + | [`( item* `)] { send Out ['('] send Out [r2] @@ -38,8 +39,8 @@ context undo } def start - [A1 item* F '.' '^'] - | [A2 item* F '.' ';' '\n'] + [A1 item* F `. `^] + | [A2 item* F `. `; NL] end # undo |