File tree 2 files changed +28
-2
lines changed
2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -1273,10 +1273,16 @@ class cppfront
1273
1273
auto id = std::string{};
1274
1274
printer.emit_to_string (&id);
1275
1275
assert (alt->id_expression || alt->literal );
1276
- if (alt->id_expression )
1276
+ if (alt->id_expression ) {
1277
1277
emit (*alt->id_expression );
1278
- else if (alt->literal )
1278
+ if (alt->expr ) {
1279
+ push_need_expression_list_parens (true );
1280
+ emit (*alt->expr );
1281
+ pop_need_expression_list_parens ();
1282
+ }
1283
+ } else if (alt->literal ) {
1279
1284
emit (*alt->literal );
1285
+ }
1280
1286
printer.emit_to_string ();
1281
1287
1282
1288
assert (*alt->is_as_keyword == " is" || *alt->is_as_keyword == " as" );
Original file line number Diff line number Diff line change @@ -647,6 +647,7 @@ struct alternative_node
647
647
source_position equal_sign;
648
648
std::unique_ptr<statement_node> statement;
649
649
token const * literal;
650
+ std::unique_ptr<expression_list_node> expr;
650
651
651
652
auto position () const -> source_position
652
653
{
@@ -2313,6 +2314,25 @@ class parser
2313
2314
return {};
2314
2315
}
2315
2316
2317
+ if (curr ().type () == lexeme::LeftParen) {
2318
+ auto open_paren = curr ().position ();
2319
+ next ();
2320
+ auto expr_list = expression_list (open_paren);
2321
+ if (!expr_list) {
2322
+ error (" unexpected text - ( is not followed by an expression-list" );
2323
+ next ();
2324
+ return {};
2325
+ }
2326
+ if (curr ().type () != lexeme::RightParen) {
2327
+ error (" unexpected text - expression-list is not terminated by )" );
2328
+ next ();
2329
+ return {};
2330
+ }
2331
+ expr_list->close_paren = curr ().position ();
2332
+ next ();
2333
+ n->expr = std::move (expr_list);
2334
+ }
2335
+
2316
2336
if (curr ().type () != lexeme::Assignment) {
2317
2337
error (" expected = at start of inspect alternative body" );
2318
2338
return {};
You can’t perform that action at this time.
0 commit comments