lex ignore /space+/ literal '*', '(', ')' token id /[a-zA-Z_]+/ end def item [id] | ['(' item* ')'] def start [item*] parse Input: start[ stdin ] InputTree: start = Input.tree cons Output: accum [] for Id: id in InputTree { send Output "( [^Id] ) } S: start = Output() print( S '\n' )