[antlr-interest] Regarding lexer rules return values
Raghavendra Anjana (RBEI/EMT2)
Raghavendra.Anjana at in.bosch.com
Wed Jun 3 03:59:54 PDT 2009
Hello Dave,
I have used the parser rule with some modifications and started working....
Thanks a lot for your suggestion..
Regards
Raghavendra
________________________________
From: Dave Dutcher [mailto:dave at tridecap.com]
Sent: Tuesday, 2. June 2009 8:10 PM
To: Raghavendra Anjana (RBEI/EMT2); antlr-interest at antlr.org
Subject: RE: [antlr-interest] Regarding lexer rules return values
Is there a reason you can't make LEXERRULE a parser rule?
parserrule: (parserrule2);
parserrule2: (LEXERRULE1) (LEXERRULE2) (LEXERRULE3);
Then you can do exactly what you want.
Dave
________________________________
From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-bounces at antlr.org] On Behalf Of Raghavendra Anjana (RBEI/EMT2)
Sent: Tuesday, June 02, 2009 4:27 AM
To: antlr-interest at antlr.org
Subject: [antlr-interest] Regarding lexer rules return values
Hello,
I have a grammar with a parser rule as shown below
parserrule: (LEXERRULE);
LEXERRULE: (LEXERRULE1)(LEXERRULE2)(LEXERRULE3);
Whenever my parser rule is recognized I want to return the text identified for LEXERRULE1,2,3 separately. But I believe that we cannot return values from a lexer rule.
Is there a way so that I can get the LEXERRULE1,2,3 from LEXERRULE.
i.e. Something like
Parserrule return [x,y,z]: (LEXERRULE) {$x= LEXERRULE.LEXERRULE1;$y =LEXERRULE.LEXERRULE2;$z=LEXERRULE.LEXERRULE3 };
LEXERRULE: (LEXERRULE1)(LEXERRULE2)(LEXERRULE3);
LEXERRULE1:'ab';
LEXERRULE2:'xy';
LEXERRULE3:'12';
The input for this parser is abxy12
The scenario is that whenver this text is recognized or matched then I want ab, xy and 12 to be return back from the parser rule each separately.
Thanks a lot in advance.
Thanks and Regards
Raghavendra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090603/b88efff2/attachment.html
More information about the antlr-interest
mailing list