[antlr-interest] how to call a rule/token from its including rule
bkiers at gmail.com
Wed Jul 18 05:01:11 PDT 2012
On Mon, Jul 16, 2012 at 5:41 PM, Marinos Georgiades
<marinos at studyhood.com>wrote:
> 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' ':' primaryActor.actorName ......
> :actorName PA_TYPE
> :actorName | SA_TYPE
> :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.
I don't quite follow. If you want to match an `actorName`, why would you
want to write `primaryActor.actorName` (which isn't possible, btw) instead
of just writing `actorName` like this:
:'Description' ':' actorName
More information about the antlr-interest