[antlr-interest] Testing For Alternative Terminals In Actions

Randall R Schulz rschulz at sonic.net
Thu Mar 20 12:38:40 PDT 2008


Hi,

I have a few productions such as this one:

booleanSentence
    :   ( Open! ( If^ | Then^ | Iff^ | XOr^ ) sentence sentence Close! )
    ;


The grammar has extensions (in this case signified by the "Then" 
and "XOr" cases) which must elicit warnings or errors (or not) 
depending on the optional conformance level established when the parser 
is created.

I'd like to avoid a lot of extra productions to distinguish the extended 
from the base-level tokens. Is there a way for me to write action code 
that distinguish which terminal was used in this sort of production?

If so, how?


Thanks.


Randall Schulz


More information about the antlr-interest mailing list