Open
Description
Hi, I use antlr4 cpp target in a project currently with cpp17. There is some features of cpp23 such as https://en.cppreference.com/w/cpp/utility/expected that I want to use which are not available in 17. So I planned to update all my dependencies to meet the requirements and went the turn of antlr. I was already on version 4.13.2 so nothing to except finally upgrading set(CMAKE_CXX_STANDARD 23)
When regenerating then build the parser I got an error:
FilParser.cpp:1064:113: error: non-pointer operand type 'std::string' (aka 'basic_string<char>') incompatible with nullptr
1064 | type_name = (antlrcpp::downCast<Variable_declarationContext *>(_localctx)->typeContext != nullptr ? _input->getText(antlrcpp::downCast<Variable_declarationContext *>(_localctx)->typeContext->start, antlrcpp::downCast<Variable_declarationContext *>(_localctx)->typeContext->stop) : nullptr);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This code is in generated parser from this g4 file:
variable_declaration returns[std::shared_ptr<filc::VariableDeclaration> tree]
@init {
bool is_constant = true;
std::string type_name;
std::shared_ptr<filc::Expression> value = nullptr;
}
@after {
$tree = std::make_shared<filc::VariableDeclaration>(is_constant, $name.text, type_name, value);
}
: (VAL | VAR {
is_constant = false;
}) name=IDENTIFIER (COLON type {
type_name = $type.text;
})? (EQ value=expression {
value = $value.tree;
})?;
type : IDENTIFIER (STAR | LBRACK INTEGER RBRACK)?;
I don't know if there is a simple way to fix this. If not, is it planned to fully support cpp23 for the generated code?
Metadata
Metadata
Assignees
Labels
No labels