[antlr-interest] Semantic predicates
jimi at temporal-wave.com
Tue Oct 20 00:44:51 PDT 2009
I don’t think that there any bugs here. The gated predicates work fine for me (not that that means there are therefore no bugs ;-), but that it is more likely there is a misuse going on somewhere in the grammar).
If you think that there is a bug then you should pin it down to a small piece of grammar so that it can be investigated. What usually happens is that the grammar is so ambiguous that the predicates don’t cover all the possibilities and your gate fails… and then what? You might need to put your gate before the reference to the rule rather than within the rule.
So, can you provide a small example of gated predicates not doing what you think that they should?
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Naveen Chawla
Sent: Monday, October 19, 2009 12:15 AM
To: David-Sarah Hopwood
Cc: antlr-interest at antlr.org
Subject: Re: [antlr-interest] Semantic predicates
Yes, I alluded to that in another thread, "How to make a syntactic predicate exit a rule completely". I am a beginner in this area, but I think that what you said is true of syntactic predicates as well. I think it would make ANTLR more powerful, if this feature existed (of not matching a rule if all or the only predicate(s) fail in it), but as Jim pointed out, there could be problems such as bad development practices. If you do use predicates, it would seem more intuitive to work that way.
2009/10/17 David-Sarah Hopwood david-sarah at jacaranda.org
I think we have to interpret this as an ANTLR bug, not the grammar writer
being confused. Conceptually, a gated semantic predicate with a single
alternative has a clear meaning: if the predicate fails then it should be
equivalent to a rule that never matches. It would be very strange for it
to mean anything else.
David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com <http://davidsarah.livejournal.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the antlr-interest