[antlr-interest] how to call a rule/token from its including rule

Marinos Georgiades marinos at studyhood.com
Mon Jul 16 08:41:59 PDT 2012


Hello,

I am new to ANTLR, so I am trying to learn the basics. 
I would like to know how I can call a rule or token which is defined within another rule, as in the example below:

description
:'Description' ':' primaryActor.actorName ......
;

primaryActor
:actorName PA_TYPE
;

secondaryActor
:actorName | SA_TYPE
;

actorName
:ARTICLE SMALL_NOUN
;
So, 'primaryActor' and 'secondaryActor' both have an 'actorName'. When the user will write the actual syntax "e.g. 'Description: a Doctor...", 'Doctor should be assigned to 'primaryActor.actorName. Because 'actorName' is of the same type for both primary and secondary actors, I don't want to create an actorName for each one of them but being able to distinguish the actorName (sub-rule/token) through its  including rule.

 Thank you,


Sincerely,

Marinos Georgiades, Ph.D.


More information about the antlr-interest mailing list