diff options
Diffstat (limited to 'test/string.lm')
-rw-r--r-- | test/string.lm | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/test/string.lm b/test/string.lm new file mode 100644 index 0000000..ea41cb2 --- /dev/null +++ b/test/string.lm @@ -0,0 +1,60 @@ +##### LM ##### +lex + token str_escape /'\\' any/ + token str_chr /[^\\"]+/ +end + +def str_item + [str_escape] +| [str_chr] + +def string + [`" str_item* `"] + +lex + token ident /[a-zA-Z_]+/ + token number /[0-9]+/ + + literal `+ `* `; `" `' `( `) + literal `+= `-= `*= + + ignore wp /[ \t\n]+/ +end + +def expr + [expr `+ term] +| [term] + +def term + [term `* primary] +| [primary] + +def primary + [number] +| [ident] +| [string] +| [`( expr `)] + +def expr_list + [expr_list expr `;] +| [] + +def start + [expr_list] + { + if match lhs + ~a + "%{{"; 1 * 2; + { + print( 'yes\n' ) + } + } + +parse S: start[stdin] +print_xml( S ) +print( '\n' ) +##### IN ##### +a + "%{{"; 1 * 2; + +##### EXP ##### +yes +<start><expr_list><expr_list><expr_list></expr_list><expr><expr><term><primary><ident>a</ident></primary></term></expr><_literal_0009>+</_literal_0009><term><primary><string><_literal_000f>"</_literal_000f><_repeat_str_item><str_item><str_chr>%{{</str_chr></str_item></_repeat_str_item><_literal_000f>"</_literal_000f></string></primary></term></expr><_literal_000d>;</_literal_000d></expr_list><expr><term><term><primary><number>1</number></primary></term><_literal_000b>*</_literal_000b><primary><number>2</number></primary></term></expr><_literal_000d>;</_literal_000d></expr_list></start> |