[antlr-interest] Trouble with syntactic predicates that reference semantic predicates that rely on a current dynamic attribute scope

Sam Harwell sharwell at pixelminegames.com
Fri Jul 25 09:33:31 PDT 2008


Wow that's a big statement!

 

Consider the following setup:

 

rule2

scope

{

    int a;

}

@init

{

    a = -1;

}

: { (a < 0) }? rule3 { ((a=1) >= 0) /* intentional assignment */ }?

;

 

rule1

: ((rule2) => rule2)+

;

 

rule0

: (rule1) => rule1

| rule4

;

 

In evaluating the syntactic predicate in rule0, the semantic predicate
at the beginning of rule2 is evaluated without pushing a new dynamic
attribute scope. I can detect the lack of a dynamic scope
(rule2_stack.Count == 0), but there is a path for rule0 to be reached
inside rule2, in which case the semantic predicate is checking the value
of a in the wrong scope. Is this a bug?

 

Sam

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080725/969b7154/attachment.html 


More information about the antlr-interest mailing list