[antlr-interest] Lexer for comments
Uli Bubenheimer
yahoogroups.10.ulibube at spamgourmet.com
Tue Feb 24 09:20:09 PST 2004
The documentation for ANTLR gives a variant of the following as an
example for parsing C-style multi-line comments:
class L extends Lexer;
options {k = 2;}
Comment : "/*" ( options { greedy = false; } : . )* "*/" ;
I have a specification for a lexer where everything except the
multi-line comment can be parsed with k == 1 lookahead. I assume that
setting k = 2 will slow down parsing for the rest of my grammar. So I
was wondering whether the following might work. Parsing comments may
be a bit slower now, but I'm thinking as long as there are few
comments in my source I would be faster overall, due to k == 1.
class ADLLexer extends Lexer;
options {k = 1;}
Comment : "/*" ( ( '*' ~'/') => '*' | ~'*' )* "*/" ;
Are there other alternatives?
Uli
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/antlr-interest/
<*> To unsubscribe from this group, send an email to:
antlr-interest-unsubscribe at yahoogroups.com
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
More information about the antlr-interest
mailing list