[antlr-interest] Antlr 3 Lexer problem

Jim Idle jimi at temporal-wave.com
Tue Jun 26 11:52:16 PDT 2007



> -----Original Message-----
> From: antlr-interest-bounces at antlr.org [mailto:antlr-interest-
> bounces at antlr.org] On Behalf Of Geoffrey Zhu
> Sent: Tuesday, June 26, 2007 11:44 AM
> To: antlr-interest at antlr.org
> Subject: Re: [antlr-interest] Antlr 3 Lexer problem
> 
> I can't do this. I am constructing complicated lexer rules because in
> my
> input there are code blocks within which the grammar is totally
> different from the rest of the file. My file is a custom
mini-language.
> Embeded in it there are some SQL statements with surrounding
> parentheses. My program does not need to deal with full SQL syntax. I
> only need to correctly recognize the beginning and ending of the SQL
> statements.

OK:

fragment WS : ' ' | '\t' ;
fragment LSELECT : '(' WS* 'select' ;
LPAREN    : '(' ;
LP_SELECT : (LSELECT)=> LSELECT;


Should do it. ANTLR 
Perhaps you can tokenize the whole SQL statement to one token, unless
you need to look in it for host variables or something?

Jim



More information about the antlr-interest mailing list