[antlr-interest] Re: simple question

Lubos Vnuk lubos.vnuk at rts.at
Wed Oct 29 09:39:36 PST 2003


You might be mixing up the meaning of lexer and parser somewhat.

I suggest you should get a single SELECT token, then a series of ID 
tokens (ignoring the WS in the lexer), then a FROM token and an ID 
token. This would be the lexer's task.

In your parser you define a rule to put it together, something like 
this:
select_stmt: SELECT (ID)+ FROM ID;

I think you have a few SQL grammars at www.antlr.org to study from.

HTH,
Lubos.

--- In antlr-interest at yahoogroups.com, "lloyd_from_far" <ld at g...> 
wrote:
> given this (or change this tokens as you see fit):
> SELECT: "SELECT" ;
> FROM: "FROM" ;
> NAME: options { testLiterals=true; }:
> 	( 'a' .. 'z' );
> SPACE: (' ') +;
> 
> how would you cut the following string:
> "SELECT a field name with plenty of space FROM aTable"
> 
> into the 4 following Tokens:
> 'SELECT'
> 'a field name with plenty of space'
> 'FROM'
> 'aTable'


 

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




More information about the antlr-interest mailing list