[antlr-interest] predicate question
Loring Craymer
lgcraymer at yahoo.com
Mon May 5 20:06:36 PDT 2008
I'll vote nay. p2 is guaranteed to be tested out of context in a synpred (the sempred will execute but not the action). PCCTS did not (IIRC) worry about actions when hoisting sempreds.
This is a playing with fire issue. The rule needs to be "semantic context changes which will affect the outcome of a decision cannot legally be made within the scope of that decision". You can never be sure when you will need to insert a synpred in a grammar, so sempred behavior within synpreds should be the same as when they are encountered outside a synpred.
I believe that changing the currently implemented behavior would be unwise--this is the sort of change that introduces new and more exciting behaviors (bug city).
--Loring
----- Original Message ----
> From: Terence Parr <parrt at cs.usfca.edu>
> To: ANTLR Interest <antlr-interest at antlr.org>
> Sent: Monday, May 5, 2008 6:20:28 PM
> Subject: [antlr-interest] predicate question
>
> Consider:
>
> parser grammar T;
>
> a : {p1}? {action} {p2}? A
> | A
> ;
>
> Someone pointed out that p2 should not be tested out of context (i.e.,
> before action executes). ANTLR v2 (PCCTS) correctly ignored preds
> after actions. v3 definitely walks right over actions looking for
> preds. I propose to prevent p2 from being hoisted into the decision
> for rule 'a'. Right now it generates enclosed DFA. After fix, it
> would only see p1. Not sure how to fix just yet, but i'll figure it
> out.
>
> Contrary opinions?
>
> Ter
>
>
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
More information about the antlr-interest
mailing list