I was wondering if there is any plan to support parse tree visitors that return something as in the Java implementation of antlr. I find this is a convenient way to write a visitor that constructs AST node objects. Concretely, the current implementation of visit_terminal has signature:
fn visit_terminal(self, TerminalNode<...>) {},
but if it were instead
fn visit_terminal<T>(self, TerminalNode<...>) -> T {}
(and similar for the other functions in the ParseTreeVisitor trait)
then it would be possible to write a visitor that builds an AST by returning the AST nodes with each of these calls.
I was wondering if there is any plan to support parse tree visitors that return something as in the Java implementation of antlr. I find this is a convenient way to write a visitor that constructs AST node objects. Concretely, the current implementation of visit_terminal has signature:
fn visit_terminal(self, TerminalNode<...>) {}
,but if it were instead
fn visit_terminal<T>(self, TerminalNode<...>) -> T {}
(and similar for the other functions in the ParseTreeVisitor trait)then it would be possible to write a visitor that builds an AST by returning the AST nodes with each of these calls.