Is it possible for ANTLR to change the AST depends on the condition we have during parsing?
For example, when parsing a string like: foo().dropLastBar(true).bar(), we hope to drop the last occurrence of the bar if we have know that there is dropLastBar(true) exists.
Now I have used "members" in ANTLR to record whether there exists dropLastBar with true value. But I don't know how to modify the rule of ANTLR, so that the generated AST will be different based on the string we have. The string can be foo().dropLastBar(true).bar().bar().bar(), then is it possible for us to get the AST generated by foo().dropLastBar(true).bar().bar() without parsing twice?