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 @@ -1272,8 +1272,11 @@ class cppfront
1272
1272
1273
1273
auto id = std::string{};
1274
1274
printer.emit_to_string (&id);
1275
- assert (alt->id_expression );
1276
- emit (*alt->id_expression );
1275
+ assert (alt->id_expression || alt->literal );
1276
+ if (alt->id_expression )
1277
+ emit (*alt->id_expression );
1278
+ else if (alt->literal )
1279
+ emit (*alt->literal );
1277
1280
printer.emit_to_string ();
1278
1281
1279
1282
assert (*alt->is_as_keyword == " is" || *alt->is_as_keyword == " as" );
Original file line number Diff line number Diff line change @@ -646,6 +646,7 @@ struct alternative_node
646
646
std::unique_ptr<id_expression_node> id_expression;
647
647
source_position equal_sign;
648
648
std::unique_ptr<statement_node> statement;
649
+ token const * literal;
649
650
650
651
auto position () const -> source_position
651
652
{
@@ -758,8 +759,11 @@ auto alternative_node::visit(auto& v, int depth) -> void
758
759
}
759
760
assert (is_as_keyword);
760
761
v.start (*is_as_keyword, depth+1 );
761
- assert (id_expression);
762
- id_expression->visit (v, depth+1 );
762
+ assert (id_expression || literal);
763
+ if (id_expression)
764
+ id_expression->visit (v, depth+1 );
765
+ else if (literal)
766
+ literal->visit (v, depth+1 );
763
767
assert (statement);
764
768
statement->visit (v, depth+1 );
765
769
v.end (*this , depth);
@@ -2300,8 +2304,12 @@ class parser
2300
2304
if (auto id = id_expression ()) {
2301
2305
n->id_expression = std::move (id);
2302
2306
}
2307
+ else if (is_literal (curr ().type ())) {
2308
+ n->literal = &curr ();
2309
+ next ();
2310
+ }
2303
2311
else {
2304
- error (" expected id-expression after 'is' in inspect alternative" );
2312
+ error (" expected id-expression or literal after 'is' in inspect alternative" );
2305
2313
return {};
2306
2314
}
2307
2315
You can’t perform that action at this time.
0 commit comments