[antlr-interest] return LTR values

Victor Giordano power_giordo at yahoo.com.ar
Thu Aug 19 09:15:22 PDT 2010


Hi Brian. I am newbie too. But i will try to answer the matter of question.

If you want to "grab" the values of the labels, you have to ways:
1) Assing each rule (lexel or parser) to a label, each label must be 
have a diferent name (in order to use then later)
2) Assign a group of rules (lexer or parser) in a "list", that is: an 
array of labels. So you doesn't have to use diferent names, and can have 
the advantage of categorise same elements in an array for work with then 
like an unit.

1)
author	:l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR
It's isn't right, how do you select the second rule or the first rule.

So you must diferenciate:
author	:l1=LTR l2=LTR ... ln=LTR
l1 is the first, l2 is the second.. and so on.

2)
You can do this:

author	:l+=LTR l+=LTR l+=LTR l+=LTR l+=LTR l+=LTR l+=LTR l+=LTR l+=LTR 
l+=LTR
{
   $l[0] <--- is the first
   $l[1] <--- is the second!.
   // Sorry i don't know how to iterate through them.
It's target lenguaje specific the action part.
}
;


wELL, I HOPE, really i hope, you understand my explanation and help a 
little!!.
Grettings!.


El 19/08/2010 12:56 p.m., Brian Lavender escribió:
> So, I have a parser rule that grabs 10 LTR lexer values. I would like to have the parser
> rule set its $text value to be the concatonation of these LTR values and put an
> XML tag around it.
>
> How do I do that?
>
> author	:	l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR l=LTR
> {<Author>$l+</Author>  };
>
> LTR  :   . ;



More information about the antlr-interest mailing list