diff options
Diffstat (limited to 'test/matchex.lm')
-rw-r--r-- | test/matchex.lm | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/test/matchex.lm b/test/matchex.lm new file mode 100644 index 0000000..9dd24c4 --- /dev/null +++ b/test/matchex.lm @@ -0,0 +1,41 @@ +##### LM ##### +lex + token id /[a-zA-Z_][a-zA-Z0-9_]*/ + literal `= `< `> `/ + ignore /[ \t\n\r\v]+/ +end + +def attr + [id `= id] + +def open_tag + [`< id attr* `>] + +def close_tag + [`< `/ id `>] + +def tag + [open_tag item* close_tag] + +def item + [tag] +| [id] + +parse Tag: tag[ stdin ] + +# Style: List of literal text and types. +match Tag ["<person name=" Val1:id attr*">" item* "</person>"] + +# Style: Literal text with embedded lists of types. +match Tag "<person name=[Val2:id attr*]>[item*]</person>" + +print( ^Val1 '\n' ) +print( ^Val2 '\n' ) + +##### IN ##### +<person name=adrian hometown=kingston> + <t1 foo=bar2 e=f></t2> +</person> +##### EXP ##### +adrian +adrian |