[antlr-interest] Re: Getting at the token text in a parser

offline314159 offline at shaw.ca
Sun Feb 29 18:50:50 PST 2004


Halleleujah!

Thank you for the help.  Much, MUCH better now.

So, in a not-quite related note, since i'm asking anyway, here's an
interesting one:

The input for my parser may consist of "folded" text - basically, some
lines that are beyond a reasonable length will be wrapped with leading
whitespace indicating that their values are to be unfolded and treated
as all one piece.

So how do i look for that?  I was originally handling it by filtering
the input, but that was messing with my linefeeds and CRs, so i'd like
to handle it in the parser.  Essentially what i want is to return a
single token, call it VALUE, that takes everything from the first ":"
on a line to the first ENDL character that is not followed by some
whitespace.

Can this even be done?

--- In antlr-interest at yahoogroups.com, "lgcraymer" <lgc at m...> wrote:
> $getText works in the lexer, not in the parser--in the lexer, there is
> text associated with a rule, but not in the parser..  What you want to
> do is label the AST (or Token) nodes that you want to extract text
> from--say
> v:value { #v.getText(); }




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/antlr-interest/

<*> To unsubscribe from this group, send an email to:
     antlr-interest-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 



More information about the antlr-interest mailing list