File tree Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Expand file tree Collapse file tree 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -1248,8 +1248,11 @@ class cppfront
1248
1248
1249
1249
auto id = std::string{};
1250
1250
printer.emit_to_string (&id);
1251
- assert (alt->id_expression );
1252
- emit (*alt->id_expression );
1251
+ assert (alt->id_expression || alt->literal );
1252
+ if (alt->id_expression )
1253
+ emit (*alt->id_expression );
1254
+ else if (alt->literal )
1255
+ emit (*alt->literal );
1253
1256
printer.emit_to_string ();
1254
1257
1255
1258
assert (*alt->is_as_keyword == " is" || *alt->is_as_keyword == " as" );
Original file line number Diff line number Diff line change @@ -639,6 +639,7 @@ struct alternative_node
639
639
std::unique_ptr<id_expression_node> id_expression;
640
640
source_position equal_sign;
641
641
std::unique_ptr<statement_node> statement;
642
+ token const * literal;
642
643
643
644
auto position () const -> source_position
644
645
{
@@ -751,8 +752,11 @@ auto alternative_node::visit(auto& v, int depth) -> void
751
752
}
752
753
assert (is_as_keyword);
753
754
v.start (*is_as_keyword, depth+1 );
754
- assert (id_expression);
755
- id_expression->visit (v, depth+1 );
755
+ assert (id_expression || literal);
756
+ if (id_expression)
757
+ id_expression->visit (v, depth+1 );
758
+ else if (literal)
759
+ literal->visit (v, depth+1 );
756
760
assert (statement);
757
761
statement->visit (v, depth+1 );
758
762
v.end (*this , depth);
@@ -2293,8 +2297,12 @@ class parser
2293
2297
if (auto id = id_expression ()) {
2294
2298
n->id_expression = std::move (id);
2295
2299
}
2300
+ else if (is_literal (curr ().type ())) {
2301
+ n->literal = &curr ();
2302
+ next ();
2303
+ }
2296
2304
else {
2297
- error (" expected id-expression after 'is' in inspect alternative" );
2305
+ error (" expected id-expression or literal after 'is' in inspect alternative" );
2298
2306
return {};
2299
2307
}
2300
2308
You can’t perform that action at this time.
0 commit comments