[antlr-interest] A simple prepocessor with a lexer?

Terence Parr parrt at cs.usfca.edu
Sun Oct 5 14:40:14 PDT 2003


Hi.  Damn yahoogroups sucks.  Post from home didn't make it.  Anyway, 
try this:

class L extends Lexer;

options {
	filter=true;
}

CMT : "--" ( PRAGMA | (options{greedy=false;}:.)* '\n' ) ;

protected
PRAGMA : "<pragma"> ... ;

On Saturday, October 4, 2003, at 08:21 PM, maaxxxcal wrote:

> I am trying to write a very simple preprocessor but I'm not quite
> sure how to go about it.
> Here's the problem, I need to process pragmas that are really inside
> single-line comments in a SQL script (not necessarily from the start
> of line).
> For instance, I can have input of the form:
>
> <sql>
> ...
> <sql> -- <pragma>
> ...
> <sql>
>
> What is the simplest way to achieve this with ANTLR? Is a lexer
> enough as long as the syntax of the pragma is not too complex?
> I tried writing such a lexer but I'm having trouble defining a rule
> that would match "anything until --"
>
> Thanks for your help!
>
>
>
>
> Your use of Yahoo! Groups is subject to 
> http://docs.yahoo.com/info/terms/
>
>
>
--
Professor Comp. Sci., University of San Francisco
Creator, ANTLR Parser Generator, http://www.antlr.org
Co-founder, http://www.jguru.com
Co-founder, http://www.knowspam.net enjoy email again!
Co-founder, http://www.peerscope.com pure link sharing




 

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




More information about the antlr-interest mailing list