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 @@ -1282,8 +1282,11 @@ class cppfront
1282
1282
1283
1283
auto id = std::string{};
1284
1284
printer.emit_to_string (&id);
1285
- assert (alt->id_expression );
1286
- emit (*alt->id_expression );
1285
+ assert (alt->id_expression || alt->literal );
1286
+ if (alt->id_expression )
1287
+ emit (*alt->id_expression );
1288
+ else if (alt->literal )
1289
+ emit (*alt->literal );
1287
1290
printer.emit_to_string ();
1288
1291
1289
1292
assert (*alt->is_as_keyword == " is" || *alt->is_as_keyword == " as" );
Original file line number Diff line number Diff line change @@ -667,6 +667,7 @@ struct alternative_node
667
667
std::unique_ptr<id_expression_node> id_expression;
668
668
source_position equal_sign;
669
669
std::unique_ptr<statement_node> statement;
670
+ token const * literal;
670
671
671
672
auto position () const -> source_position
672
673
{
@@ -776,8 +777,11 @@ auto alternative_node::visit(auto& v, int depth) -> void
776
777
}
777
778
assert (is_as_keyword);
778
779
v.start (*is_as_keyword, depth+1 );
779
- assert (id_expression);
780
- id_expression->visit (v, depth+1 );
780
+ assert (id_expression || literal);
781
+ if (id_expression)
782
+ id_expression->visit (v, depth+1 );
783
+ else if (literal)
784
+ literal->visit (v, depth+1 );
781
785
assert (statement);
782
786
statement->visit (v, depth+1 );
783
787
v.end (*this , depth);
@@ -2346,8 +2350,12 @@ class parser
2346
2350
if (auto id = id_expression ()) {
2347
2351
n->id_expression = std::move (id);
2348
2352
}
2353
+ else if (is_literal (curr ().type ())) {
2354
+ n->literal = &curr ();
2355
+ next ();
2356
+ }
2349
2357
else {
2350
- error (" expected id-expression after 'is' in inspect alternative" );
2358
+ error (" expected id-expression or literal after 'is' in inspect alternative" );
2351
2359
return {};
2352
2360
}
2353
2361
You can’t perform that action at this time.
0 commit comments