tunnelvisionlabs / antlr4cs

The original, highly-optimized C# Target for ANTLR 4
Other
444 stars 104 forks source link

Generated Parser/Lexer Files in Visual Studio Failing #300

Open AashrayAnand opened 6 years ago

AashrayAnand commented 6 years ago

I am currently using:

ANTLR4.Runtime.Standard (by Sam Harwell, Terrence Parr) version 4.7.1 ANTLR4.CodeGenerator (by Sam Harwell, Terrence Parr) version 4.6.5-rc002

to integrate ANTLR into a visual studio project. I have been able to successfully integrate an existing grammar into a different project until now by generating ANTLR C# files from the command line, and moving them into my Visual Studio project, but I wanted to integrate ANTLR through the NuGet packages for a new project

Upon generating the base classes, lexer, parser etc. , and running my project, I came across the following errors

Error CS0115 'grammar_Parser.TokenNames': no suitable method found to override C:\Users\t-aaana\Documents\Visual Studio 2015\Projects\parserConversionAgent\ssmaAntlr4\obj\Debug\grammar_Parser.cs

Error CS0115 'grammar_Lexer.TokenNames': no suitable method found to override C:\Users\t-aaana\Documents\Visual Studio 2015\Projects\parserConversionAgent\ssmaAntlr4\obj\Debug\grammar_Lexer.cs 380 N/A

Any ideas why this is happening? It's worth noting that generating the C# files from the command line and using these instead of the files generated by the NuGet packages do work.

lextm commented 6 years ago

https://github.com/tunnelvisionlabs/antlr4cs/releases

You should choose a release number from GitHub, and then use the packages from the same release.

sharwell commented 6 years ago

Antlr4.CodeGenerator produces code for the Antlr4.Runtime runtime library. The Antlr4.Runtime.Standard library is maintained by a different person and is not compatible with the build-time code generation tools I maintain.

lextm commented 6 years ago

@sharwell A possible way to avoid confusion is to list which packages belong to a release. I did that for another project, https://github.com/dockpanelsuite/dockpanelsuite/releases

shiloh09630 commented 2 years ago

@sharwell I don't know if you are still maintaining/ working on ANTLR4, but it has become almost impossible to figure out how to use and work with in VS19. Thea ease and usefulness of how ANTLR4 works in Java is incredible where as with C# it is quite the opposite. In no way am I trying to offend, just as an undergrad who is trying to use the tool in his preferred language, I thought you might want to know mine and others current experience.

lextm commented 2 years ago

@shiloh09630 There are several C# based projects (like NHibernate and my little parser) using ANTLR so if you want a reliable tutorial, please

This project's readme already covers the key points, but it is impossible to document everything because the beginners can come from different backgrounds. Nothing can be better than working samples.

shiloh09630 commented 2 years ago

@lextm I completely agree that going through already created projects to see how ANTLR works (or really anything works) is one of if not the best way to learn things. However, I was having trouble even just getting ANTLR installed in VS19. To get ANTLR installed and working as some guides described (like "The ANTLR Mega Tutorial") I had to create the project in .NetFramework, Open it in VS17, install the NuGet packages there and create the ANTLR files in 2017 build the files and add as link in 2017 and then reopen the project in 2019. I am just an undergrad so there might be an easier way to get ANTLR4 running in vs2019 that I don't know about, but I spent about a week trying to find a way to do it and even now go back and say "Hey maybe if I did it like this" but no, nothing. The template files don't show up in 2019 no matter what I do. And If I use the 4.9.2.Runtime.Standard library, as mentioned by sharwell, the generated code will not work.

shiloh09630 commented 2 years ago

If you have a better way to install and use ANTLR4 in VS19 please, I am begging ... show me the way

lextm commented 2 years ago

I don't understand what exactly you are asking for. The owners of this repo have no responsibility over guides written by others.

And if the steps of "I had to create the project in .NetFramework, Open it in VS17, install the NuGet packages there and create the ANTLR files in 2017 build the files and add as link in 2017" work for VS 2017, I wonder why you cannot try to do the same in VS2019. The two VS versions do not differ that much to invalidate the steps.

If you observe a specific issue with VS2019, like some steps break, then you should report as a new issue, not trailing under a different issue.