[antlr-interest] Please help to left-refactor this simple ebnf grammar
Artem Golubev
artemkagolubev at gmail.com
Sun Sep 20 03:45:24 PDT 2009
I just can't get how I can left-refactor the following grammar. Please,
help.
Currently I get "(211): ebnf.g:1:8: [fatal] rule Tokens has non-LL(*)
decision due to recursive rule invocations reachable from alts 8,9. Resolve
by left-factoring or using syntactic predicates or using backtrack=true
option." error with it.
grammar ebnf;
options {
output = AST;
language = CSharp2;
}
tokens {
OPENBRACKET = '(';
CLOSEBRACKET = ')';
ONEORMOREKEYWORD= '+';
ANYKEYWORD = '*';
OPTIONALKEYWORD = '?';
ORKEYWORD = '|';
}
/*------------------------------------------------------------------
* PARSER RULES
*------------------------------------------------------------------*/
OrList : List (ORKEYWORD List)*;
List : (Mutliplication)+;
Mutliplication : Atom ( ONEORMOREKEYWORD | OPTIONALKEYWORD | ANYKEYWORD )?;
Atom : IDENTIFIER | Group;
Group : OPENBRACKET OrList CLOSEBRACKET;
/*------------------------------------------------------------------
* LEXER RULES
*------------------------------------------------------------------*/
IDENTIFIER : (DIGIT)+ ;
WHITESPACE : ( '\t' | ' ' | '\r' | '\n' )+ { $channel = HIDDEN; } ;
fragment DIGIT : '0'..'9' ;
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090920/aeb54822/attachment.html
More information about the antlr-interest
mailing list