[antlr-interest] How to set imaginary token text?
Vaclav Barta
vbar at comp.cz
Mon Jul 16 22:13:47 PDT 2007
On Monday 16 July 2007 21:20, Randall R Schulz wrote:
> On Monday 16 July 2007 12:04, Vaclav Barta wrote:
> > Experimenting some more, maybe I'd like to parse (some of) these
> > characters individually but consolidate them into one AST node -
> > something like
> Let me clarify that it is at the lexical level that a
> token-per-character approach incurs potentially excessive overhead. For
> example, a whitespace rule that matched single white-space characters
> vs. one that collected them together could make a large difference in
Well, I'm not tokenizing whitespace characters individually. String characters
may well run into thousands, but what's a few thousand objects between
friends?
> > string
> >
> > : s = quotedString -> LITERAL
> > | BareString -> LITERAL
> > ;
> >
> > where LITERAL is an imaginary token - but as written, it obviously
> > loses the string value. How can I set LITERAL token text to the value
> > returned from quotedString, or $BareString.getText() ?
> Do you have TDAR (The Definitive ANTLR Refernce)? If so, on page 176
No.
Bye
Vasek
More information about the antlr-interest
mailing list