> On Aug 29, 2009 2:20pm, Martijn Reuvers <[email protected]> wrote:
>> I would rewrite the markupStatement like this:
>
>> markupStatement :
>>   markup+ (expression | regularStatement | embedding)? ';'
   ;

[email protected] wrote:
> Thanks for the response. I'm aware of the left factoring approach,
> however then the alternative:
> 
> markup+ ';'
> 
> will have a higher priority then:
> 
> markup+ expression ';'
> 
> which is invalid for my language.

The left-factored version is completely equivalent to the original unless
you have an ambiguity. We don't have enough of the grammar to be sure that
there isn't an ambiguity, but if there were, ANTLR would warn about it.

(Strictly speaking, left-factoring alone would give you

   markupStatement :
     markup+ (expression ';' | regularStatement ';' | embedding ';' | ';')
   ;

but the difference doesn't matter here.)

> Is there any way to specify priorities other then the ordering of 
> alternatives?

At the risk of oversimplifying, alternatives are normally only prioritized
if at least one of them has a predicate. "The Definitive ANTLR Reference"
goes into detail about this in chapter 12.

Incidentally, you are matching ';' at the end of regularStatement as
well as in markupStatement, which seems likely to be wrong.

-- 
David-Sarah Hopwood  ⚥  http://davidsarah.livejournal.com


List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

--~--~---------~--~----~------------~-------~--~----~
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