lex start { ignore /space+/ literal '*', '(', ')' token id /[a-zA-Z_]+/ { str t = input.pull( match_length ) input.push( make_token( typeid id, t ) ) } } def foo [id] def item [id] | [foo] | ['(' item* ')'] def start [item*] start Input = parse start( stdin ) print( Input, '\n' )