[antlr-interest] How do I specify start-of-line (^ in [F]Lex in ANTLR Lexers?
Terence Parr
parrt at jguru.com
Mon May 27 11:25:28 PDT 2002
On Monday, May 27, 2002, at 08:37 AM, Greg Lindholm wrote:
> ANTLR doesn't have a way of specifing start-of-line as part of a rule.
> Once you have entered a rule you can use a sematic predicate to check
> what column your at, but this probably doesn't help you.
>
> IMHO ANTLR is not well suited for writing a preprocessor as;
> 1) Preprocessors are line-oriented and ANTLR isn't.
> 2) The output of an ANTLR lexer is a token stream where the
> output of a preprocessor is a character stream (or file) that
> then gets fed into a lexer.
Very good points...
Here is a strategy that you may not have considered: do a line oriented
loop to get input and then when you find a directive in column one, use
ANTLR to lex or parse just that line :) Works great.
Ter
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list