Hopefully this is a really quick one 😉 I have written a lexer / parser specification in ANTLR3, and am targeting the CSharp2 target. The generated code works correctly, but I can’t get ANTLR to put the C# output into a namespace.
The relevant section of the Grammar file is as follows:
grammar MyGrammar; options { language = CSharp2; output = AST; ASTLabelType = CommonTree; }
To generate the correct namespace, I have tried:
@namespace { MyNamespace }
and
@lexer::namespace { MyNamespace } @parser::namespace { MyNamespace }
but both of these generate errors, claiming that the file has no rules.
Any help is appreciated.
I use this for a combined lexer and parser (and it generates the namespace correctly):
So i wonder why your version didn’t work – maybe you want to try this simple example and see if it works for you.