[antlr-interest] predicate question

Mark Wright markwright at internode.on.net
Mon May 5 23:31:18 PDT 2008


I share Loring's concerns.

I don't mind if ANTLR is changed, as long as it still works.
That might be hard to test though.

If ANTLR is changed, then I will run some tests with my grammar which
has lots of dis-ambiguating semantic predicates.  However my grammar
has no syntactic predicates.

Personally I would not mind if ANTLR dis-allowed this, and issued an
error message.  In:

http://www.antlr.org:8888/browse/ANTLR-222

it says that {p2}? may depend on a variable that is calculated
in {action}.  I think I must not understand the issue, as it seems
to me that the issue could be avoided by making the following
changes to the parser:

(1) Change the grammar to:

a : {p1}? {p2}? A
  | A
  ;

(2) Change {p2}? to calculate the variable that was calculated in
{action}.

(3) To address this concern in:

http://www.antlr.org:8888/browse/ANTLR-222

"Also it seems it could cause some performance problem if calculating 
the semantic predicates was a costly operation."

The disambiguating semantic predicates can be coded to cache their
results as I described in:

http://www.antlr.org/pipermail/antlr-interest/2008-February/026385.html

Thanks, Mark

-- 


More information about the antlr-interest mailing list