Missing classes in Antlr.Runtime for C#
I'm trying to get Antlr working using NuGet.
The current version of the Antlr.Runtime.dll that I'm trying to reference is 3.1.3.42154.
The issue is that when I try and build my Lexer and Parser .cs files I get a lot of build errors about missing types.
e.g. The class GrammarRuleAttribute
cannot be found. I've looking in the Antlr.Runtime.dll and the class isn't there. However if you look at the Antlr project on GitHub then your can see the GrammarRuleAttribute
should ind开发者_开发知识库eed be in the Antlr.Runtime.dll.
Is this a bug or am I missing something?
This is a somewhat time-sensitive Q/A because the C# targets for ANTLR (CSharp2 by Johannes Luber and CSharp3 by myself) change over time. I know the CSharp2 target has had some issues recently that are being worked on. As of this writing, the current version of the CSharp3 target is 3.3.1.
Here is a link to the CSharp3 target documentation, which includes several download links to the C# port of the ANTLR tool, the CSharp3 runtime, MSBuild support, and some tools for Visual Studio. I update this document periodically as new versions are released.
Edit: If you are experiencing display problems or exception messages when opening a grammar file, you should uninstall the ANTLR 3, StringTemplate, and Extensibility Framework extensions from the Extension Manager and reinstall them per the instructions in the linked documentation. I've updated the extensions to resolve the problem.
I had this problem when using CSharp2 or CSharp3. I'm building in ANTLRWorks 1.5rc1.
It turned out to be related to the ANTLR version. I installed the official package using NuGet, which was 3.1.x. After removing that and installing the unoffical 3.4.1 package, it worked.
There was still a minor issue relating to the HIDDEN channel in my test grammar. Changing it to Hidden (as defined in Antlr3.Runtime) resolved the issue
精彩评论