kaby76 / scrape-c-plus-plus-spec

A program to scrape the grammar from Annex A of one of the ISO148822 specs
MIT License
3 stars 0 forks source link

Using the latest ANTLR 4.9.3 - InputStream is not usable #2

Open DonMathi opened 2 years ago

DonMathi commented 2 years ago

Hi Kaby76

Thank you for your great work. I have tried to compile your parser and lexer with the latest ANTLR4.9.3 release. There is a small issue in the use of InputStream.LA(1). I think a workaround is to use this._input.LA(1) instread.

https://github.com/kaby76/scrape-c-plus-plus-spec/blob/bda703d5e6e23f9f284c4f313223119e1b2efe3d/g2/Generated/Cpp14Parser.g4#L328

kaby76 commented 2 years ago

This doesn't sound right. I just upgraded the .csproj to 4.9.3, and it works fine (just type "dotnet build"). It might be that you were using Antlr4BuildTasks version 8.16? I thnk there's a bug in the probing code for finding the version of the "antlr-....-complete.jar" file.

DonMathi commented 2 years ago

I have tried to run the command line with the antlr-4.9.3-complete.jar and the Cpp14Parser.g4 and Cpp14Lexer.g4, and this created a target Cpp14Parser.java file. This now doesn't compile because InputStream is not found.

kaby76 commented 2 years ago

Right, that's because the grammar's for a C# target right now, not Java. I haven't written the code to be "target agnostic" yet. But, I'm still just finishing up the scraper program, the program that reads any of the ISO C++ Specs and outputs a psuedo-Antlr4 grammar, to read the C++20 standard doc and the drafts for C++23. Then, I plan to update the optimizing script with what I discovered in the "g2" program for C#, and bundle GNU, Clang, and MS header files for a minimal environment to parse real C++ programs. Sorry, this is a lot of work and it does take time. I will try to write the Java base classes for the grammar in the next day or two.