[antlr-interest] How do I specify start-of-line (^ in [F]Lex in
ANTLR Lexers?
Sinan
sinan.karasu at boeing.com
Wed May 29 09:06:06 PDT 2002
Terence Parr wrote:
>
> 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
In TinyBasic, I use
line:nl statement;
where nl is a new line (unless it is the first line.....)
If I only knew how to push a token into the string before starting the
whole thing,
it'd a lot easier...
Then you can say
file { push(NL)} : (nl statement)+ ;
Sinan
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list