Minion Skywalker
Minion Skywalker

Reputation: 37

Can't integrate antlr 4 in the C# project again

I got a problem with a project using language parser tool antlr. First when i created project and installed antlr4, then it had succesfully integrated with a grammar file ECMAScript.g4, but once i added antlr3 framework and under this yet one grammar file JSDeobfucs.g and after that i tried to integrate this in the existing project, then project stopped building and files of lexer, parser, listener e.t.c. also are not created anymore, what outputs the compilation errors:

[Error] File 'C:\Users\Dima\Desktop\Projects\C#\JsAstVisitor\JsAstVisitor\obj\Debug\ECMAScriptBaseListener.cs' not found. [Error] File 'C:\Users\Dima\Desktop\Projects\C#\JsAstVisitor\JsAstVisitor\obj\Debug\ECMAScriptLexer.cs' not found. [Error] File 'C:\Users\Dima\Desktop\Projects\C#\JsAstVisitor\JsAstVisitor\obj\Debug\ECMAScriptListener.cs' not found. [Error] File 'C:\Users\Dima\Desktop\Projects\C#\JsAstVisitor\JsAstVisitor\obj\Debug\ECMAScriptParser.cs' not found.

For integration antlr3 in the Visual Studio 2017 i followed next instruction.

Althought it is strangely what similar instruction isn't created for Visual Studio 2017, so as project antlr build by target differs not only from depending on the antlr framework version

, but on the Visual Studio version. As well as, what in latest version of Visual Studio antlr 3 and 4 not suppored over graphical nuget package manager, but only over nuget manager console i can install them. Here is link to my project( i can't attach archive with a project here because stackoverflow are not supported all file types as i think ).

Therefore please say me:

  1. What is problem can be here in ?

  2. How to resolve it ?

  3. Is it really that in Visual Studio in one C# project two different versions of antlr conflict and will conflict with each other ???

  4. If two version of antlr conflicts in single project, then how to do now that antlr4 again works in my current project at least and in the same time i wouldn't do project initially, if this is possibly of course ???

p.s. I found the similar problem with antlr source code generation in C# target here:

Use ANTLR to parse C++ with C#

As i understand what i can use IKVM, but i don't understand: how it helps me in my common problem with antlr integration in C# project. Anyway help me, please.

Upvotes: 0

Views: 1373

Answers (1)

Radioguy
Radioguy

Reputation: 23

I was facing the same issue, and this fixed it- "You will need to right click the grammar file in Solution Explorer and select Properties. In the properties window, configure the following items.

Build Action: Antlr4

Custom Tool: MSBuild:Compile

Custom Tool Namespace: The complete name of the namespace you want the generated classes to be located within. The ANTLR Language Support extension configures this field according to the root namespace configured for the C# project combined with the subfolder within the project where the grammar is located."

Refer - https://github.com/tunnelvisionlabs/antlr4cs

Upvotes: 0

Related Questions