[antlr-interest] Syntactic predicates vs branch-local declarations.
Monty Zukowski
monty at codetransform.com
Sat Dec 9 08:20:12 PST 2006
> I disagree:
>
> $ cat t.a
> class test
> extends Parser;
>
> a: { char c; } A { c = 'A'; }
> | B { c = 'B'; }
> ;
>
> $ java antlr.Tool t.a
> ANTLR Parser Generator Version 2.7.6 (20060528) 1989-2005
>
> $ javac test.java
> test.java:58: cannot find symbol
> symbol : variable c
> location: class test
> c = 'B';
> ^
> 1 error
>
> $
>
> The code for each branch is enclosed in a separate scope, so anything
> declared in one branch is not accessible outside the branch; hence
> branch-local declarations.
>
>
Well, I could be wrong there, but I had never heard of it before (and
I've been around a while.)
Monty
More information about the antlr-interest
mailing list