[antlr-interest] Names of generated files and classes

Thomas Brandon tbrandonau at gmail.com
Mon Aug 6 04:13:29 PDT 2007


On 8/6/07, Johannes Luber <jaluber at gmx.de> wrote:
> Hello!
>
> I've noticed that for separate lexer and parser grammars the generated
> files still attach Lexer and Parser to the class names. As I already
> named mu grammars CSharp3Lexer.g and CSharp3Parser.g, I end up with
> CSharp3LexerLexer and CSharp3ParserParser. My suggestion is to leave the
> grammar names as they are, because the generated files won't have a
> naming conflict.
>
> I've talked with Ter about this and he said that the behaviour wasn't
> changed before because the book was written for the old behaviour
> (actually, I remember an example which showed my suggested behaviour so
> nobody should be surprised. Maybe a editor thought that the source code
> was wrong there.). But as for 3.1 the bets are off.
>
> The biggest question is how much the existing code would break. I rename
> the generated files and classes every time because I can't stand the
> names aesthetically. In my case no code would break. Other people will
> have to rename the types in their rigs or add Lexer and Parser to the
> grammar names. Both are one time operations and done via Search&Replace
> (if necessary at all) so it isn't a big deal.
>
> What are your opionions?
As combined grammars will still need to append Lexer and Parser this
will complicate a mapping from .g file names to generated file names
that tools may need. They would need to analyse the grammars to
determine the files they generate.
An alternate solution is to name your files MyGrammar.g3l,
MyGrammar.g3p and MyGrammar.g3t for lexer, parser and tree parser.

Tom.
>
> Best regards,
> Johannes Luber
>


More information about the antlr-interest mailing list