----------------------- CUT -------------------
>
> //=== Parser ===//
> expr: orexpression*;
> orexpression
>  
>      :   andexpression (OR orexpression)*
>     ;
>
> andexpression
>     : notexpression (AND andexpression)*
>     ;
>
> notexpression
>     : (NOT)? atom
>     ;
>
> atom
>     : WORD+
>     | LEFT_PAREN! expr RIGHT_PAREN!
>     ;
>
> --- On Thu, 9/18/08, jack zhang <[EMAIL PROTECTED]> wrote:
> From: jack zhang <[EMAIL PROTECTED]>
> Subject: Alternative(s) 2 were disabled for that input
> To: [EMAIL PROTECTED]
> Date: Thursday, September 18, 2008, 4:46 PM
>
> Hi,
>   I keep getting following errors:
>
> warning(138): Query.g:0:0: grammar Query: no start rule (no rule can
> obviously be followed by EOF) warning(200): Query.g:27:40: Decision can
> match input such as "OR" using multiple alternatives: 1, 2 As a result,
> alternative(s) 2 were disabled for that input
> warning(200): Query.g:31:39: Decision can match input such as "AND" using
> multiple alternatives: 1, 2 As a result, alternative(s) 2 were disabled for
> that input
> warning(200): Query.g:39:7: Decision can match input such as "WORD" using
> multiple alternatives: 1, 2 As a result, alternative(s) 2 were disabled for
> that input
>
------------------------- CUT --------------------
The parser complains because it can match a OR b OR c in two ways, one by 
using the kleene star * in or_expression twice and so matching two ORs with 
their corresponding expressions reduced to atoms, and the other one by using 
the kleene star * in or_expression once, and matching b OR c with another 
or_expression. You want to change or_expression (and similar and_expression) 
to
or_expression
 : and_expression (OR and_expression)*
 ;
so it always has to match the kleene star * twice and the parser won't 
complain about this anymore. I know the error messages can be sometimes quite 
confusing, and the best way to deal with this is to make a copy of your 
grammar and remove one rule at a time to see which one really causes the 
error. Then at least you know which rule to fix.

Markus


List: http://www.antlr.org:8080/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org:8080/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