You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With a grammar like this:
```antlr
rule: (VAL | VAR {
is_constant = false;
}) name=IDENTIFIER (COLON type {
type_name = $type.text; <-- we look this line
})? (EQ value=expression {
value = $value.tree;
})?
```
When generating for Cpp target we get this specific result:
```cpp
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);
```
If input doesn't match the `type` branch then we fallback on nullptr. As
of cpp23 standard this line doesn't compile as it waits for
`std::string`.
AS `Token::getText` returns `std::string`, then fallback value should be
empty string
Signed-off-by: Kevin Traini <kevin@ktraini.com>
0 commit comments