[antlr-interest] Help needed upgrading java.g to support Gene rics

Matt Quail matt at cortexebusiness.com.au
Thu Mar 13 15:18:25 PST 2003

> The semantic predicate is a good possible approach.

Okay, I've tried the semantic predicate approach, this is what I have:

         (  arrayDecl
         |  typeArguments

         {int currentLtLevel = ltCounter;}
         LT {ltCounter++;}
             COMMA referenceType
         {(currentLtLevel != 0) || ltCounter == currentLtLevel}?
         GT {ltCounter-=1;}
     |   SR {ltCounter-=2;}
     |   BSR {ltCounter-=3;}

Things to note:
- this grammar now handles lists of arguments like <String,Integer>
- this grammar compiles with nondeterminism warnings, I'm not sure
   if they are ignorable yet.
- typeArguments ends in a "validating" semantic predicate, that
   ensures that if there was a zero 'LT' count upon entry, then it
   is zero upon exit. So it allows the LT count to cross "nested
- typeArgumentsEnd may match nothing. But it must match eventually
   because of the validating sematnic predicate in typeArguments

I'll play with it further, but I think this semantic-predicate approach may be 
the easiest way forward.



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 

More information about the antlr-interest mailing list