[antlr-interest] More hoisting pain

Sam Barnett-Cormack s.barnett-cormack at lancaster.ac.uk
Sat May 30 05:00:59 PDT 2009


Hi all,

Been away from work ill for a while, and now returning to my ASN.1 project.

I'm having another hoisting issue. I have the following rule:

fixedTypeValueFieldSpec
   : IOLCID t=typeOrClass
     ({!($t.obj)}? UNIQUE
     |)
     ( {!($t.obj)}? valueOptionalSpec
     | {$t.obj}? objectOptionalSpec
     ) ;

The obj element of the typeOrClass return is just a boolean. The problem 
is that the decision is being hoisted to a DFA class, which can't see t. 
I have really no idea how to approach this. If it worked, it would be a 
relatively clean, not too inefficient (I think) way to handle the 
problem of two *very* similar grammar specifications that cause a lot of 
ambiguity otherwise. However, although t has already been set when the 
DFA is called, it obviously can't see it.

For background, this was originally two rules (well, three, one main one 
that called two others), but problems with lookahead due to recursion 
meant that it was ambiguous. On the face of it, this should be a 
comfortable partial merging (relying on three other rules, of course).

Can anyone suggest a resolution? I'm running 3.1.3 inside Eclipse using 
ANTLR-IDE.


More information about the antlr-interest mailing list