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 @@ -1240,10 +1240,16 @@ class cppfront
1240
1240
auto id = std::string{};
1241
1241
printer.emit_to_string (&id);
1242
1242
assert (alt->id_expression || alt->literal );
1243
- if (alt->id_expression )
1243
+ if (alt->id_expression ) {
1244
1244
emit (*alt->id_expression );
1245
- else if (alt->literal )
1245
+ if (alt->expr ) {
1246
+ push_need_expression_list_parens (true );
1247
+ emit (*alt->expr );
1248
+ pop_need_expression_list_parens ();
1249
+ }
1250
+ } else if (alt->literal ) {
1246
1251
emit (*alt->literal );
1252
+ }
1247
1253
printer.emit_to_string ();
1248
1254
1249
1255
assert (*alt->is_as_keyword == " is" || *alt->is_as_keyword == " as" );
Original file line number Diff line number Diff line change @@ -607,6 +607,7 @@ struct alternative_node
607
607
source_position equal_sign;
608
608
std::unique_ptr<statement_node> statement;
609
609
token const * literal;
610
+ std::unique_ptr<expression_list_node> expr;
610
611
611
612
auto position () const -> source_position
612
613
{
@@ -2249,6 +2250,25 @@ class parser
2249
2250
return {};
2250
2251
}
2251
2252
2253
+ if (curr ().type () == lexeme::LeftParen) {
2254
+ auto open_paren = curr ().position ();
2255
+ next ();
2256
+ auto expr_list = expression_list (open_paren);
2257
+ if (!expr_list) {
2258
+ error (" unexpected text - ( is not followed by an expression-list" );
2259
+ next ();
2260
+ return {};
2261
+ }
2262
+ if (curr ().type () != lexeme::RightParen) {
2263
+ error (" unexpected text - expression-list is not terminated by )" );
2264
+ next ();
2265
+ return {};
2266
+ }
2267
+ expr_list->close_paren = curr ().position ();
2268
+ next ();
2269
+ n->expr = std::move (expr_list);
2270
+ }
2271
+
2252
2272
if (curr ().type () != lexeme::Assignment) {
2253
2273
error (" expected = at start of inspect alternative body" );
2254
2274
return {};
You can’t perform that action at this time.
0 commit comments