kaby76 / AntlrVSIX

AntlrVSIX is a language server for use with Visual Studio 2019, Visual Studio Code, and Gnu Emacs to support Antlr, Bison, and W3C EBNF grammars. In addition to the IDE extensions provided here, a command-line tool is available to refactor grammars in order to make them cleaner, more readable, and more efficient.
https://marketplace.visualstudio.com/items?itemName=KenDomino.AntlrVSIX
MIT License
90 stars 13 forks source link

Unable to compile generated code of plsql grammar #125

Open filippobottega opened 3 years ago

filippobottega commented 3 years ago

Hello, I'have tried to generate the plsql grammar. This is my stack (end of paths):

image

I have got 3 warnings and 14 errors.

Thank you for your support.

kaby76 commented 3 years ago

Yep. It can't find the generated classes because they're in the wrong namespace when code was generated by the tool--the base classes are in namespace "PlSqlParseTree". I forgot to add the "package" parameter to the "generate" command. But, the C# code that is in grammars-v4 uses "_input" (PlSqlParseTree.cs, line 14), and "_input" doesn't exist in Antlr4.Runtime.Standard. It's likely this is being targeted for the ancient Harwell's version of Antlr, not the official version. Fortunately, I have a shim library for all this junk. It'll take a few hours to make a new release and give a script to show how to do the generate and run.

kaby76 commented 3 years ago

Submitted https://github.com/antlr/grammars-v4/issues/1976 in the Grammars-v4 repo for multiple issues (no CI builds, targeting ancient Antlr runtime, wrong namespace).

romarro commented 3 years ago

Regarding the "_input" in the C# generated files should be InputStream

kaby76 commented 3 years ago

Regarding the "_input" in the C# generated files should be InputStream

Correct. "_input" should be InputStream in C# Antlr4.Runtime.Standard. It could, of course, be for another runtime like Java, Go, Dart, or the old Antlr4cs style. I have plans for a shim to bridge the gap between that style with C# Antlr4.Runtime.Standard and to parse the grammars to determine what to do.

For all of these, I am starting the process of pulling the Trash command-line tool out completely from Antlrvsix, and turning it into a collection of stand-alone Dotnet tools. Generate in Trash will be one of these, and it will be able to handle any target.

For the last month or two, I've been working on a replacement for Generate called "dotnet-antlr". It is now the basis for C# CI testing in antlr/grammars-v4. It can handle most of the target types. It also uses StringTemplates so one can tweak the driver code to ones needs, e.g., one set of templates for basic tree output, another for performance testing with warmup, etc. The tool works well with the pom.xml/Antlr plugin, but it doesn't work well right now for arbitrarily organized grammars plus source.

There will be a lot of changes coming in a few weeks.

--Ken