[antlr-interest] Re: Semantic predicates that aren't & hoisting
John D. Mitchell
johnm-antlr at non.net
Fri Mar 11 16:55:29 PST 2005
>>>>> "David" == David Jung <jungdl at ornl.gov> writes:
>>>>>> John D. Mitchell said:
[...]
> You're right. Good spotting. However, I still get the same result when
> changed to LCURLY. So, one of us is going mad (probably me). Perhaps I
> am still missing something - what first and second alternative are you
> speaking of?
exprList.
> The whole "{if...}" is an ExprList. Within that the "if {a>0;} then
> {f();g();}" can only be an expr, can't it? (can't be an exprList as it
> doesn't start with a '{', hence it needs a trailing ';').
Really look at the trace information and see the flow through the grammar.
> Here is the output for "{if {a>0;} then {f();g();} x();}" :
Ugh. Notice how your example input is actually malformed...
{if {a>0;} then {f();g();} x();}
I.e., your grammar only allows one expression for the then block but you're
trying to put in a sequence of expressions ("{f();g();} x();").
So, the parser sees the 'x' but it's expecting e.g., the closing RCURLY.
Take care,
John
More information about the antlr-interest
mailing list