-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Open
Description
I create a compiler with antlr and llvm in c++. I've created the two .g4
files and in my CMakeLists.txt I call the antlr jar to generate the lexer and the parser. Then I compile all my files with the same CMakeLists file and I got these errors :
Filc/src/generated/FilParser.cpp:803:16: error: invalid use of member function ‘antlrcppfil::FilParser::ExceptionContext* antlrcppfil::FilParser::ExprContext::exception()’ (did you forget the ‘()’ ?)
803 | _localctx->exception = std::current_exception();
| ~~~~~~~~~~~^~~~~~~~~
| ()
Filc/src/generated/FilParser.cpp:804:43: error: invalid use of non-static member function ‘antlrcppfil::FilParser::ExceptionContext* antlrcppfil::FilParser::ExprContext::exception()’
804 | _errHandler->recover(this, _localctx->exception);
| ~~~~~~~~~~~^~~~~~~~~
I looking in some tutorials and on stackoverflow why i've got these errors. But I didn't found any mention of that. And in tutorials code they have the same code as me, but it compile.
So I tried to update my antlr version to version 4.11.1 (originally I use 4.8) but it doesn't change anything.
For information, I use c++ 17, and this is my CMakeLists.txt :
project(Filc)
cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(antlr4-jar ${PROJECT_SOURCE_DIR}/bin/antlr-4.11.1-complete.jar)
set(antlr4-output
${PROJECT_SOURCE_DIR}/src/generated/FilLexer.cpp
${PROJECT_SOURCE_DIR}/src/generated/FilLexer.h
${PROJECT_SOURCE_DIR}/src/generated/FilParser.cpp
${PROJECT_SOURCE_DIR}/src/generated/FilParserBaseVisitor.cpp
${PROJECT_SOURCE_DIR}/src/generated/FilParserBaseVisitor.h
${PROJECT_SOURCE_DIR}/src/generated/FilParserVisitor.cpp
${PROJECT_SOURCE_DIR}/src/generated/FilParserVisitor.h
)
add_custom_target(GenerateLexerParser
COMMAND java -jar ${antlr4-jar} -Dlanguage=Cpp -visitor -no-listener -o ${PROJECT_SOURCE_DIR}/src/generated/ -package antlrcppfil ${PROJECT_SOURCE_DIR}/src/antlr/FilLexer.g4 ${PROJECT_SOURCE_DIR}/src/antlr/FilParser.g4
DEPENDS ${PROJECT_SOURCE_DIR}/src/antlr/FilLexer.g4 ${PROJECT_SOURCE_DIR}/src/antlr/FilParser.g4
)
include_directories(
src
src/generated
src/utils
antlr-runtime/src
)
add_executable(filc
src/main.cpp
src/utils/cxxopts.hpp
src/generated/FilLexer.cpp
src/generated/FilLexer.h
src/generated/FilParser.cpp
src/generated/FilParserBaseVisitor.cpp
src/generated/FilParserBaseVisitor.h
src/generated/FilParserVisitor.cpp
src/generated/FilParserVisitor.h
)
add_dependencies(filc GenerateLexerParser)
target_link_libraries(filc antlr4-runtime.a)
install(TARGETS filc DESTINATION bin)
I've asked on stackoverflow and be redirected here.
Metadata
Metadata
Assignees
Labels
No labels