[antlr-interest] Syntactic predicate confusion
Christopher Nebel
c.nebel at apple.com
Thu Feb 12 17:03:56 PST 2004
Apparently I don't quite "get" syntactic predicates. Does the
predicate imply that the attached alternative will fire *only* if the
predicate is true, or it only apply the predicate if the lookahead is
otherwise ambiguous? It appears to be the former, which seems lame.
Here's my situation:
x: a | b
a: c | b d
(The real thing is far more complicated, but this is the basic
problem.) Naturally, I get an ambiguity warning here -- if it sees the
stuff predicted by "b", it doesn't know whether to follow x-> a-> b e
or just x-> b. So, I put in a predicate:
x: (b d)=> a | b
a: c | b d
This doesn't work, however: if I give it something c-like, then it
can't parse it -- it just completely ignores the a-> c production. If
I add a duplicate of x-> a without the predicate, I just get more
ambiguity warnings. What to do? I don't want to break up the "a"
rule, since the real thing is rather complicated, not to mention
self-referential. I suppose I could come up with a syntactic predicate
for the duplicate x-> a rule, but it's going to be sort of large.
Suggestions?
--Chris Nebel
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list