[antlr-interest] Re: identifier with space
lgcraymer
lgc at mail1.jpl.nasa.gov
Wed Oct 29 10:15:41 PST 2003
--- In antlr-interest at yahoogroups.com, "lloyd_from_far" <ld at g...>
wrote:
> sorry, my example was bad.
> let parse this:
>
> SELECT A Field With Name FROM ATable
>
Lloyd--
You're trying to do too much in the lexer--spaces are significant for
separating tokens in your example. If you really want "A Field With
Name" as a single AST node, you are probably better off reconstructing
it:
select
:
"SELECT" text "FROM" text
;
text
{ String foo }
:
a:IDENTIFIER { foo = $a.getText(); }
{ b:IDENTIFIER! { foo += " " + $b.getText(); } )*
{ $a.setText(foo); }
;
That also has the advantage of converting text to a canonical form
with single spaces--you really don't want "A field" to be different
than "A field", do you?
--Loring
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list