[antlr-interest] ANTLR 3: Problem with static DFA class generation

Oliver Zeigermann oliver.zeigermann at gmail.com
Sat Sep 10 15:01:00 PDT 2005


2005/9/10, Terence Parr <parrt at cs.usfca.edu>:
> I would generate a DFA that looked like this:
> 
> boolean[] pred34 = {x!=0, x>=0};
> int alt34 = DFA34.predict(input, pred34);

Sounds like a good solution to me. 

> Actually, don't forget though that hoisting makes parameters unusable
> also.
> 
> a[int x] : {x!=0}? ID ;
> 
> If {x!=0}? gets hoisted into another decision it won't compile.
> Officially then only values visible to the class are valid, though in
> most cases even parameters would work if I can figure out the pre-
> evaluation thing.

Only allowing non local values makes sense to me. 

I know this is sick, but a problem I had with ANTLR 2.x as well are
semantic actions for which it may be desirable to have them executed
in prediction mode as well, as other parts in the same rule rely on
the value being set. I had a solution for ANTLR 2.x, but maybe this is
so weird we should simply forget about...

Anyway, thanks a lot for spending so much time on my problems :)

Oliver


More information about the antlr-interest mailing list