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