On 12/06/2010 12:20 PM, Markus Lottmann wrote:
> Hi,
> 
> i am quite new to antlr and dont understand whats wrong with the 
> following grammar:
> 
> grammar test2;
> options{
> backtrack=false;
> }
> octal_literal
>      :    '0' octal_digit*;
> 
> octal_digit
>      :    '0'..'7';
> 
> The error is:
> 
> [18:17:06] warning(200): test2.g:6:8: Decision can match input such as 
> "EOF" using multiple alternatives: 1, 2
> As a result, alternative(s) 2 were disabled for that input
> [18:17:06] error(201): test2.g:6:8: The following alternatives can never 
> be matched: 2

To begin with, octal_literal and octal_digit are parser rules and not
token rules?  This means that (assuming you discard whitespace) that the
strings "0 1 2 3" and "0123" are both valid octal_literals.

Did you mean to write:

octal_literal : '0' octal_digit+ ;

Is the character '0' an octal_digit or the beginning of an
octal_literal?  To me, this is ambiguous as to which you want.

OCTAL_LITERAL : '0' OCTAL_DIGIT+
              ;

fragment
OCTAL_DIGIT   : '0' .. '7'
              ;

Might be closer to what you intend here.

> Thanks so far.
> Greetings,
> ML

-- 
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)

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