lex start { ignore /space+/ literal '*', '(', ')' token id /[a-zA-Z_]+/ } def item [id] | ['(' item* ')'] def start [item*] Input: start = parse start( stdin ) match Input [ItemList: item*] for I: item* in repeat( ItemList ) print( I '\n' ) for I: item* in rev_repeat( ItemList ) print( I '\n' )