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

Jim Idle jimi at temporal-wave.com
Wed Jul 18 09:32:25 PDT 2012


I think you need to step away from your current problem and do some
reading on how lexers and parsers work - the problem is that you are
asking the wrong questions and we won't really be able to help until you
have a better understanding of the technologies you are trying to use. You
might start with the ANTLR book itself if you can afford the $$, otherwise
start with the articles in the wiki and the examples that you can
download.

Jim

> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Marinos Georgiades
> Sent: Wednesday, July 18, 2012 5:10 AM
> To: Bart Kiers
> Cc: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] how to call a rule/token from its
> including rule
>
> Hi,
>
> and thank you for your reply.
>
> If I just call the 'actorName', then once I write the actual syntax and
> replace 'actorName' with a value, (e.g. 'Doctor'), the parser will not
> be able to distinguish if it is the actorName of the PrimaryActor or
> the actorName of the SecondaryActor. Both 'primaryActor' and
> 'secondaryActor' have an actorName of the same type. 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,
>
> Marinos
>
> ________________________________
>  From: Bart Kiers <bkiers at gmail.com>
> To: Marinos Georgiades <marinos at studyhood.com>
> Cc: "antlr-interest at antlr.org interest" <antlr-interest at antlr.org>
> Sent: Wednesday, July 18, 2012 3:01 PM
> Subject: Re: [antlr-interest] how to call a rule/token from its
> including rule
>
>
>
>
>
> On Mon, Jul 16, 2012 at 5:41 PM, Marinos Georgiades
> <marinos at studyhood.com> wrote:
>
> 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.
> >
> >
>
> 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
> :'Description' ':' actorName
> ;
>
> Regards,
>
> Bart.
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe: http://www.antlr.org/mailman/options/antlr-interest/your-
> email-address


More information about the antlr-interest mailing list