On 08/19/2010 11:56 AM, Brian Lavender wrote:
> 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> };

Do it with a LEXER rule instead of a parser rule.

AUTHOR : LTR LTR LTR LTR LTR LTR LTR LTR LTR LTR
       ;

If you still need to do something in a parser rule, do it as

author : AUTHOR
         { ... }
       ;

> LTR  :   . ;

Having a lexer rule that matches any single character is going to get
you into trouble later on if you are not careful.  The whole point of
lexing to the convert single characters into TOKENs which can then be
parsed by the parser.

-- 
Kevin J. Cummings
[email protected]
[email protected]
[email protected]
Registered Linux User #1232 (http://counter.li.org)

List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe: 
http://www.antlr.org/mailman/options/antlr-interest/your-email-address

-- 
You received this message because you are subscribed to the Google Groups 
"il-antlr-interest" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/il-antlr-interest?hl=en.

Reply via email to