views:

29

answers:

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 for example as MDDBaseParser and MDDLexer.

A: 

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.

Bart Kiers