[antlr-interest] disambiguation of petal identifiers

Jeff Barnes jbarnesweb at yahoo.com
Fri Feb 24 22:14:28 PST 2006


This is an excerpt from my grammar file:

protected 
OBJECTS: "objects"
;

protected
OBJECTFLOWS: "objectflows"
;

protected
OBJECTFLOWLIST: "objectflow_list"
;

protected
OBJECT: "object"
;

KEYWORD_OR_IDENTIFIER:
       (OBJECTS) => OBJECTS {$setType(ID);}
   |    (OBJECTFLOWS) => OBJECTFLOWS {$setType(ID);}
   |    (OBJECTFLOWLIST) => (OBJECTFLOWLIST)
{$setType(ID);}
   |    (OBJECT) => OBJECT {$setType(OBJECT);}
   |    (ID) => ID {$setType(ID);}
;

Of course, OBJECT is the most often occurring one out
of the four...

Sigh.

Funny how little setup this joke needs.

Regards,
Jeff



More information about the antlr-interest mailing list