A simple modification in one line gives parse a root option. With it one can simply type
def setup ; @parser = LambdaCalculus.new ; end
result = @parser.parse text, root: :function
@parser.root = "function"
result = @parser.parse text
@parser.root = "program"
The existing/old interface is unchanged, so no code breaks.
added :root option to parse()
I too would like to see this nicety included, particularly for writing tests.
Sorry it took time to incorporate - you provided no test and hadn't done the equivalent thing with consume_all_input. The latest GH version and gem contain both these, with tests.