[antlr-interest] Re: identifier with space

lloyd_from_far ld at galador.net
Wed Oct 29 13:47:29 PST 2003


Hi Loring,

I do want to separate "A Field" (1 space) from "A  Field" (2 spaces)
it's not my fault if I have to write a ADO.NET driver to a stupid & 
so-called "database"

anyway managing 1 space (and only one) is certainly better than no 
space at all !!
obviously I hit here a limitation of ANTLR, I guess I have to do as 
you suggested, would be better than nothing.

thanks for the feeback ;-)

--- In antlr-interest at yahoogroups.com, "lgcraymer" <lgc at m...> wrote:
> --- 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