File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -1283,10 +1283,16 @@ class cppfront
1283
1283
auto id = std::string{};
1284
1284
printer.emit_to_string (&id);
1285
1285
assert (alt->id_expression || alt->literal );
1286
- if (alt->id_expression )
1286
+ if (alt->id_expression ) {
1287
1287
emit (*alt->id_expression );
1288
- else if (alt->literal )
1288
+ if (alt->expr ) {
1289
+ push_need_expression_list_parens (true );
1290
+ emit (*alt->expr );
1291
+ pop_need_expression_list_parens ();
1292
+ }
1293
+ } else if (alt->literal ) {
1289
1294
emit (*alt->literal );
1295
+ }
1290
1296
printer.emit_to_string ();
1291
1297
1292
1298
assert (*alt->is_as_keyword == " is" || *alt->is_as_keyword == " as" );
Original file line number Diff line number Diff line change @@ -668,6 +668,7 @@ struct alternative_node
668
668
source_position equal_sign;
669
669
std::unique_ptr<statement_node> statement;
670
670
token const * literal;
671
+ std::unique_ptr<expression_list_node> expr;
671
672
672
673
auto position () const -> source_position
673
674
{
@@ -2359,6 +2360,25 @@ class parser
2359
2360
return {};
2360
2361
}
2361
2362
2363
+ if (curr ().type () == lexeme::LeftParen) {
2364
+ auto open_paren = curr ().position ();
2365
+ next ();
2366
+ auto expr_list = expression_list (open_paren);
2367
+ if (!expr_list) {
2368
+ error (" unexpected text - ( is not followed by an expression-list" );
2369
+ next ();
2370
+ return {};
2371
+ }
2372
+ if (curr ().type () != lexeme::RightParen) {
2373
+ error (" unexpected text - expression-list is not terminated by )" );
2374
+ next ();
2375
+ return {};
2376
+ }
2377
+ expr_list->close_paren = curr ().position ();
2378
+ next ();
2379
+ n->expr = std::move (expr_list);
2380
+ }
2381
+
2362
2382
if (curr ().type () != lexeme::Assignment) {
2363
2383
error (" expected = at start of inspect alternative body" );
2364
2384
return {};
You can’t perform that action at this time.
0 commit comments