[antlr-interest] [SPAM] Re: [SPAM] [SPAM] Syntax ambiguity?

Olivier Lefevre lefevrol at yahoo.com
Fri Mar 4 12:28:13 PST 2011


First, a correction. I wrote: So, how can I force ANTLR to
"consider" ID1 in this position? I meant ID2, of course.

On 3/4/2011 9:33 AM, Kevin J. Cummings wrote:
> fun2 : 'fun2(' (id1=ID1 { id1.setType(ID2); } | ID2 ) ')' ;

This is a perfectly good solution, thanks! It's a pity the
ANTLR book doesn't mention this technique.

Just for my understanding of ANTLR, though, I wonder if
there isn't a solution at the lexer level: some way to tell
the lexer that if it sees a 'fun2(' then it *must* look for
an ID2 next.

Regards,

-- O.L.



More information about the antlr-interest mailing list