[antlr-interest] How to have consistently named lexer/parser in a package?
John Woods
jqwoods at gmail.com
Mon Mar 17 20:22:38 PDT 2008
I just came across the answer, which is painfully obvious now that I see
it... Simply differentiate the grammar files by extension:
Foobar.lg3 // lexer grammar file
Foobar.g3 // parser grammar file
Sorry for the noob post.
-----Original Message-----
From: John Woods
Sent: 03/17/2008 08:02 PM
> I would like to end up with the java classes:
>
> foo.bar.FoobarLexer
> foo.bar.FoobarParser
>
> I start with a combined grammar file Foobar.g3 which includes a package
> statement:
>
> @header {
> package foo.bar;
> }
>
> But the package statement only gets copied into FoobarParser.java and
> not FoobarLexer.java which then won't compile.
>
> So it seems I need separate lexer and parser grammar files rather than a
> combined one. Obviously the files need to be named differently, and
> since antlr requires the filename to match the grammar name, it seems
> the best I can do is have java classes like so:
>
> foo.bar.FoobarXXXLexer
> foo.bar.FoobarParser
>
> I guess that's kinda trivial to worry about, but out of curiousity, I
> was wondering if there's another way?
>
> Thanks for any tips.
>
>
More information about the antlr-interest
mailing list