[antlr-interest] Error in Backtracking (?)
Michele Bortolato
zuper85 at hotmail.it
Sat Jan 12 07:41:24 PST 2008
Hi
I putted down this simple grammar:
-------------------------------------
rule : exp conf exp;
exp : expA|expB|FIELD|expS;
expA : multExpr (('+'|'-')multExpr)*;
multExpr: atom(('*'|'/')atom)*;
atom : FLOAT|'('expA')';
expB : bexp(('||'|'&&')bexp)*;
bexp : 'TRUE'|'FALSE'|'('expB')';
expS : '('expS')'|String;
conf : '='|'!='|'<'|'>'|'<='|'>=';
FLOAT : ('0'..'9')+('.'('0'..'9')+)?;
FIELD : SUBFIELD('.'SUBFIELD)*;
String : '"' (~('\\'|'"') )* '"' ;
WHITESPACE : (' '|'\n'|'\t'|'\r')+{ skip();};
fragment SUBFIELD : CHAR(CHAR|('0'..'9'))*;
fragment CHAR : ('a'..'z')|('A'..'Z')|'_';
---------------------
This grammar could(?) generate 4 kind of differen expressions
Aritmethic expressions(expA)
Boolean expressions(expB)
String expressions(expS)
and an expression consisting of a simple field (FIELD)
whithout any option the compiler says that when i find a '(' it can't decide if the expression is a expA or a expB or a expS.
if i use the option backtrack=true and memoize=true the interpreter don't accept any kind of string.
where is the problem?
Thanks
_________________________________________________________________
Ti piace giocare con le lettere? Prova ABCLive!
http://messengergiochi.it.msn.com/
More information about the antlr-interest
mailing list