context ctx { i: int j: int k: int lex start { ignore /space+/ literal '*', '(', ')' token id /[a-zA-Z_]+/ } def foo [id] def item [id] | [foo] | ['(' item* ')'] { i = 0 } def start [item*] } cons SP: parser [] SP.ctx = cons ctx [] send SP stdin Input: ctx::start = SP() print( Input '\n' )