# # R1 # namespace r1 lex literal '!', 'a', 'b' ignore /[ \n\t]+/ end def line [ '!' 'a' 'b' 'b' 'a'] end r1 # # R2 # namespace r2 lex literal '!' token id /[a-zA-Z_]+/ ignore /[ \n\t]+/ end def line [ '!' id ] end r2 def item [r1::line] | [r2::line] def btscan [item*] parse P: btscan[ stdin ] match P.tree ~!abb !abba !aab print_xml(P.tree) print( '\n' )