[antlr-interest] Lexer inheritance

mzukowski at yci.com mzukowski at yci.com
Fri Oct 18 10:45:24 PDT 2002


A lexer is defined by a lexical grammar.  Simply extend it the same way you
do with parsers.  For example:


class GnuCLexer extends StdCLexer;
...

Monty

-----Original Message-----
From: Paul J. Lucas [mailto:dude at darkfigure.org]
Sent: Friday, October 18, 2002 10:20 AM
To: antlr-interest at yahoogroups.com
Subject: [antlr-interest] Lexer inheritance


So, even though one can inherit grammars, there's no mention of the ability
to inherit lexers.  If I have several lexers implementing what otherwise
would be done with lexical states, I'd like to have a "base" lexer that is
able to return tokens like string literals, comments, etc.  Apparantly, if I
have multiple lexers, I have to repeat the pattern rules for common items in
every lexer.

Is there an easier way?  If not, why not?

- Paul


 

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