Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated Parser/Lexer Files in Visual Studio Failing #300

Open
AashrayAnand opened this issue Aug 9, 2018 · 8 comments
Open

Generated Parser/Lexer Files in Visual Studio Failing #300

AashrayAnand opened this issue Aug 9, 2018 · 8 comments

Comments

@AashrayAnand
Copy link

AashrayAnand commented Aug 9, 2018

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
Copy link

lextm commented Aug 10, 2018

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

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

@sharwell
Copy link
Member

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
Copy link

lextm commented Aug 10, 2018

@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
Copy link

@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
Copy link

lextm commented Sep 25, 2021

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

  • Dump most of the blog posts as their authors might not keep things up-to-date.
  • Dig those projects to see how ANTLR tool chain is used to generate the parser/lexer.

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
Copy link

@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
Copy link

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

@lextm
Copy link

lextm commented Sep 25, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants