[antlr-interest] Semantic predicates that aren't & hoisting
ewbank at gmail.com
Wed Mar 16 03:27:47 PST 2005
I think this solves the original problem of eliminating ";" after "}".
I lost the thread of the discussion several emails ago, and then
ended up seeing something similar in a grammar I'm developing so
thought to share the idiom here.
The trick is to use recursion to eat away at the nested sequence (I've
noticed that recusive rules are my friend :-), rather than trying to
do it in one large production.
3 LCB exprSeq RCB
8 ( expressionList (exprSeq)?
9 | expr (SEMI (exprSeq)? )?
If this doesn't apply, my apologies. Just trying to help...
On Thu, 10 Mar 2005 10:57:15 -0500 (EST), David Jung <jungdl at ornl.gov> wrote:
> My problem is that I want to eliminate the requirement for
> the separating ';' after a sub-expressionList. I cannot just make
> the ';' optional in the expressionList rule (i.e. (';')?) as
> that makes expr ambiguous (i.e. can't distinguish between
> expr "3" followed by expr "-2" and expr "3-2" (evaluating to 1) ).
More information about the antlr-interest