[antlr-interest] Regarding lexer rules return values

Raghavendra Anjana (RBEI/EMT2) Raghavendra.Anjana at in.bosch.com
Fri May 8 06:31:24 PDT 2009


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.

The kind of support I got by antlr-interest is great and appreciable.

Thanks and Regards
Raghavendra


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20090508/a1c38fc0/attachment.html 


More information about the antlr-interest mailing list