[antlr-interest] new line processing

mzukowski at yci.com mzukowski at yci.com
Fri Aug 30 09:49:54 PDT 2002


If you can do it in the lexer then that is best.  Having all newlines get to
the parser would make a big mess.  It might be simple enough that you can
solve it with lexer switching.

Another option is to use a TokenStreamFilter that recognizes the sqlplus
tokens, causes the newlines behind them to become END_STATEMENT tokens or
whatever, and discards all other newlines.

See http://www.codetransform.com/filterexample.html as an example of how I
forced IDs, NUMBERs and keywords into LABELs only when they followed GOTO or
GOSUB or etc.

Monty

> -----Original Message-----
> From: richardhensley99 [mailto:richard.hensley at mckesson.com]
> Sent: Friday, August 30, 2002 8:27 AM
> To: antlr-interest at yahoogroups.com
> Subject: [antlr-interest] new line processing
> 
> 
> I have a case where a newline is ignorable whitespace at times, and 
> the end of a command at times. Specifically, I'm trying to parse a 
> file that is valid for Oracle SQLPLUS. The file includes SQL commands 
> that end with a semicolon or slash. The file also contains SQLPLUS 
> commands which terminate with a NEWLINE.
> 
> I'm not real sure what the solution is. Do I need to always kick a 
> new line out of the lexer and deal with it in the parser, or can I 
> only kick the new line out when I known I'm in an SQLPLUS command.
> 
> SQL commands are things like "create", "drop"
> 
> SQLPLUS commands are things like "set", "execute", "whenever"
> 
> The keywords that used in the two command sets are different. 
> 
> 
>  
> 
> Your use of Yahoo! Groups is subject to 
http://docs.yahoo.com/info/terms/ 


 

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



More information about the antlr-interest mailing list