Question

I recently started to play with ANTLR4 and C#. I like the whole support that extensions give to Visual Studio. What I do not like is that whenever I generate Lexer/Parser, it is being through into the default namespace of my project - which is not what I want and as it generates automatically, it's kind of hopeless activity to try to push it into the proper namespace manually. Is there any way to change that? @parser/lexer::namespace { } and namespace in options (with or without specified language) do not seem to work.

Is there any way to do it?

Thanks!

Was it helpful?

Solution 2

You can set the Custom Tool Namespace property for the grammar file in the project, as described in the Readme file.

OTHER TIPS

java -jar antlr4.jar -package NameSpace -Dlanguage=CSharp grammar.g4

Insert your namespace in NameSpace above, and it will create your codes within that namespace.

We were also attempting to use: @parser/lexer::namespace { } and found that it didn't work. We worked around the problem using the -package option to the code generator.

It's obviously not a high priority, but we are wondering if a fix for this might be coming?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top