Closed peytonk132 closed 3 months ago
Did you follow my comments to first build the runtime then build the app that I wrote for you?
The grammar works for Cpp on Windows with VS2022.
PS C:\msys64\home\Kenne\fortran90-Cpp> msbuild .\MyParser.sln -p:Configuration=Debug > out.txt
PS C:\msys64\home\Kenne\fortran90-Cpp> .\x64\Debug\MyParser.exe C:\msys64\home\Kenne\issues\g4-current\fortran\fortran90\examples\flang\test\f90_correct\src\ac02.f90
Cpp 0 C:\msys64\home\Kenne\issues\g4-current\fortran\fortran90\examples\flang\test\f90_correct\src\ac02.f90 success 0.688818
Total Time: 0.729936
PS C:\msys64\home\Kenne\fortran90-Cpp>
As I mentioned in SO, you may have a #define
that is conflicting with the runtime. But, you need to first verify that your environment is at least set up correctly. You don't post the source code for your program, nor the .vcxproj. Every detail has to be checked, so it would be best that you wrap all the complete source and post a .zip or create a repo in github.com so we can see what you are doing.
I've updated the instructions in the Wiki to describe how to write a program with the grammars in the repo, including the bit about transformGrammar.py
. But, as I mentioned there, it is better to start with trgen instead of writing the program from scratch.
But I now see #include "../mainfunc/antlr-files/antlr4-common.h"
in ParseTreeTypes.h. You are not even using the runtime https://github.com/antlr/antlr4/blob/811b7fda58bd14d7f0abc496b6fd651dfa01ed97/runtime/Cpp/runtime/src/tree/ParseTreeType.h. You modified it! Who knows what runtime you are using.
I found the project you are working on here: https://github.com/peytonk132/FortIDE. Please check in the code you are working on (preferably in a branch of main git clone https://github.com/peytonk132/FortIDE.git; cd FortIDE; git branch with-antlr; git checkout with-antlr; ...... (modify with your new code) ...; (add, commit, and push changes).
. Then, close this issue (https://github.com/antlr/antlr4/issues/4674). I can help you get this compiling.
Basically, you should not be modifying the Antlr4 sources. You need to change the .vcxproj to add in an include path for every library you are referencing. It's likely that you also aren't specifying the language level correctly, among other things.
alright I made a seperate with-antlr
branch.
Just in case someone happens to see the same compilation errors (e.g., ParseTreeType.h(17,5): error C2143: syntax error: missing '}' before 'constant'
or IntStream.h(30,64): error C2589: '(': illegal token on right side of '::'
), it is caused by #define
conflicts when including windows.h
before Antlr4 runtime headers. One way to fix this is to silo the code for windows from the code that uses antlr4. But, it may just as well be solved by reversing the order of the #include
. In addition, I found (at least for the driver for the Cpp target used in grammars-v4) that after #include <windows.h>
, I also needed to add #undef min
. Apparently, min()
is defined as a macro. Such as life with C++ and the preprocessor.
Hello everyone, I've been trying to create a parser using antlr in VS 2022 for awhile now but I can never seem to shake these syntax errors. I had originally posted on Stackoverflow as requested but I didn't really get any answers there even though the people were very helpful. I had originally generated grammar files from https://github.com/antlr/grammars-v4/tree/master/fortran/fortran90 for the Cpp targets and in my folly hadn't used the transformGrammars.py file but had then used them after realizing my mistake and still got the errors. They range from various things like certain classes not being base class members to general syntax errors. The one file that i think holds the key to fixing a lot of other errors is ParseTreeType.h. These are my errors for for that file:
and this is the file I have:
Has anybody else experienced this before? Also, almost all the include files in the runtime src files were completely wack and didn't work at all. Could this be a bug or am I just stupid?