File tree 2 files changed +16
-5
lines changed 2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -1239,8 +1239,11 @@ class cppfront
1239
1239
1240
1240
auto id = std::string{};
1241
1241
printer.emit_to_string (&id);
1242
- assert (alt->id_expression );
1243
- emit (*alt->id_expression );
1242
+ assert (alt->id_expression || alt->literal );
1243
+ if (alt->id_expression )
1244
+ emit (*alt->id_expression );
1245
+ else if (alt->literal )
1246
+ emit (*alt->literal );
1244
1247
printer.emit_to_string ();
1245
1248
1246
1249
assert (*alt->is_as_keyword == " is" || *alt->is_as_keyword == " as" );
Original file line number Diff line number Diff line change @@ -606,6 +606,7 @@ struct alternative_node
606
606
std::unique_ptr<id_expression_node> id_expression;
607
607
source_position equal_sign;
608
608
std::unique_ptr<statement_node> statement;
609
+ token const * literal;
609
610
610
611
auto position () const -> source_position
611
612
{
@@ -718,8 +719,11 @@ auto alternative_node::visit(auto& v, int depth) -> void
718
719
}
719
720
assert (is_as_keyword);
720
721
v.start (*is_as_keyword, depth+1 );
721
- assert (id_expression);
722
- id_expression->visit (v, depth+1 );
722
+ assert (id_expression || literal);
723
+ if (id_expression)
724
+ id_expression->visit (v, depth+1 );
725
+ else if (literal)
726
+ literal->visit (v, depth+1 );
723
727
assert (statement);
724
728
statement->visit (v, depth+1 );
725
729
v.end (*this , depth);
@@ -2236,8 +2240,12 @@ class parser
2236
2240
if (auto id = id_expression ()) {
2237
2241
n->id_expression = std::move (id);
2238
2242
}
2243
+ else if (is_literal (curr ().type ())) {
2244
+ n->literal = &curr ();
2245
+ next ();
2246
+ }
2239
2247
else {
2240
- error (" expected id-expression after 'is' in inspect alternative" );
2248
+ error (" expected id-expression or literal after 'is' in inspect alternative" );
2241
2249
return {};
2242
2250
}
2243
2251
You can’t perform that action at this time.
0 commit comments