The Java 8 grammar in one of my branches uses the grammar to handle this case:
Then, in order for this grammar to produce a usable parse tree, I implemented the “baseContext” option to allow multiple rules in the grammar to share a single parse tree representation. For example, the ifThenStatement and ifThenElseStatement both produce a IfThenElseStatementContext parse tree node, but only the latter actually allows an else statement to appear. The feature is part of a pull request to ANTLR 4 (antlr/antlr4#697) but not yet accepted. If you need it in the meantime you can try using my fork of the project which includes it.
Sam
--
You received this message because you are subscribed to the Google Groups "antlr-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
antlr-discussi...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.