[antlr-interest] uh oh...trouble in meaning of (..)=> pred!!!
Terence Parr
parrt at cs.usfca.edu
Wed Mar 14 16:05:58 PDT 2007
Hi. Harmut submitted a bug report, which I have converted to a parser:
grammar T;
x : (a d) => a
| (b d) => b
| ('a'|'b')+
;
a : 'a' 'a' ;
b : 'a' 'a' 'b' ;
digit : '0'|'1' ;
Basically, in the book and in my intentions, predicates order the
alts. The problem is that ANTLR's analysis doesn't consider
syntactic predicates if it can figure out what to do w/o them.
That's an optimization. The problem is that you are often specifying
the lookahead in the predicate that must be evaluated. Crap. ANTLR
is not forcing those predicates in there.
For semantic predicates, we have {...}? and {...}?=> where the latter
forces backtracking. Perhaps (...)=> should always force
backtracking. BUT, for backtracking=true, I add a predicate to every
alt! I guess for that backtracking mode, those predicates should be
analogous to {...}? and manually specified (...)=> should operate
like {..}?
I have exactly 4 days to resolve this issue before the book goes to
copy editing. Anybody wanna help me think about this?
Ter
More information about the antlr-interest
mailing list