I think I am not being clear.  In essence, because of where I want to
embed actions or rewrites, a simplifed example of what I am trying to
do is to write a rule like this:

simplified: Identifier* Identifier;

ANTLR tells me:

warning(200): Decision can match input such as "Identifier" using
multiple alternatives: 1, 2
As a result, alternative(s) 2 were disabled for that input
error(201): The following alternatives can never be matched: 2

I've tried using (options {greedy=false;}: Identifier)*, but then
precisely the opposite thing happens: The first alternative gets
disabled and can never be reached.

What am I not understanding here, and how can I remedy this?



On Aug 13, 8:48 am, Shambolic <[email protected]> wrote:
> I want to perform a different embedded action (or generate a
> different
> AST node) on the final rule in a list of rules.
>
> Here's the most basic example I can think of:
>
> identifierList:
>         : (Identifier -> ^(ID $Identifier))* (Identifier -> ^(OTHER
> $Identifier))
>         ;
>
> This doesn't work because there are two alternatives when matching
> just against one Identifier.  So I tried making the first nongreedy
> with no success:
>
> identifierList:
>         : ( options { greedy = false; } : Identifier -> ^(ID
> $Identifier))*  (Identifier -> ^(OTHER $Identifier))
>         ;
>
> Again, ANTLR says this is ambiguous - if it's passed just "Identifier"
> then it can supposedly either match the one that goes to ^(ID
> $Identifier), or the one that goes to ^(OTHER $Identifier).  I don't
> understand how this is the case given the first one is nongreedy
>
> My actual example is a good amount lengthier and requires referencing
> the rule itself in the rewrite, so solutions that require this to be
> broken into multiple rules won't help me except maybe to help me
> understand ANTLR better.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to