Reputation: 1
Is there a way to specify custom class name (meaning independent of the grammar name) for the ANTLRv3 generated Parser and Lexer classes?
So in the case of
grammar MDD;
//other stufff
Automatically it would crate MDDParser and MDDLexer, but I would like to have them as MDDBaseParser and MDDLexer.
Upvotes: 0
Views: 532
Reputation: 170138
No, in a combined grammar like MDD
, the parser and lexer are named MDDParser and MDDLexer. A combined grammar is a grammar where you don't specify the type (parser
or lexer
).
You could define a separate parser- and lexer-grammar:
// put this in a file called MDDBaseParser.g
parser grammar MDDBaseParser;
parse
: Token+
;
and:
// put this in a file called MDDLexer.g
lexer grammar MDDLexer;
Token
: 'a'..'z'
;
Now both the parser and lexer source files will get the same name as their grammar file.
Upvotes: 1