@@ -138,7 +138,7 @@ static Expr * makeCall(Exprs & exprs, PosIdx pos, Expr * fn, Expr * arg) {
138138%type <std::vector<std::pair<PosIdx, Expr *> >> string_parts_interpolated
139139%type <std::vector<std::pair<PosIdx, std::variant<Expr *, StringToken> >>> ind_string_parts
140140%type <Expr *> path_start
141- %type <std::variant<Expr *, std::string_view> > string_parts string_attr
141+ %type <ToBeStringyExpr > string_parts string_attr
142142%type <StringToken> attr
143143%token <StringToken> ID
144144%token <StringToken> STR IND_STR
@@ -297,12 +297,7 @@ expr_simple
297297 }
298298 | INT_LIT { $$ = state->exprs.add<ExprInt>($1); }
299299 | FLOAT_LIT { $$ = state->exprs.add<ExprFloat>($1); }
300- | '"' string_parts '"' {
301- std ::visit (overloaded {
302- [&](std::string_view str) { $$ = state->exprs.add<ExprString>(state->exprs.alloc, str); },
303- [&](Expr * expr) { $$ = expr; }},
304- $2);
305- }
300+ | '"' string_parts '"' { $$ = $2.toExpr(state->exprs); }
306301 | IND_STRING_OPEN ind_string_parts IND_STRING_CLOSE {
307302 $$ = state->stripIndentation(CUR_POS, $2);
308303 }
@@ -342,9 +337,9 @@ expr_simple
342337 ;
343338
344339string_parts
345- : STR { $$ = $1 ; }
346- | string_parts_interpolated { $$ = state->exprs.add<ExprConcatStrings>(state->exprs.alloc, CUR_POS, true, $1); }
347- | { $$ = std::string_view(); }
340+ : STR { $$ = {$1} ; }
341+ | string_parts_interpolated { $$ = { state->exprs.add<ExprConcatStrings>(state->exprs.alloc, CUR_POS, true, $1)} ; }
342+ | { $$ = { std::string_view()} ; }
348343 ;
349344
350345string_parts_interpolated
@@ -447,15 +442,15 @@ attrs
447442 : attrs attr { $$ = std::move($1); $$.emplace_back(state->symbols.create($2), state->at(@2)); }
448443 | attrs string_attr
449444 { $$ = std::move($1);
450- std :: visit (overloaded {
445+ $2. visit(overloaded{
451446 [&](std::string_view str) { $$.emplace_back(state->symbols.create(str), state->at(@2)); },
452447 [&](Expr * expr) {
453- throw ParseError ({
454- .msg = HintFmt (" dynamic attributes not allowed in inherit" ),
455- .pos = state->positions [state->at (@2 )]
456- });
457- }
458- }, $2 );
448+ throw ParseError({
449+ .msg = HintFmt("dynamic attributes not allowed in inherit"),
450+ .pos = state->positions[state->at(@2)]
451+ });
452+ }}
453+ );
459454 }
460455 | { }
461456 ;
@@ -464,17 +459,17 @@ attrpath
464459 : attrpath '.' attr { $$ = std::move($1); $$.emplace_back(state->symbols.create($3)); }
465460 | attrpath '.' string_attr
466461 { $$ = std::move($1);
467- std :: visit (overloaded {
462+ $3. visit(overloaded{
468463 [&](std::string_view str) { $$.emplace_back(state->symbols.create(str)); },
469- [&](Expr * expr) { $$ .emplace_back(expr); }
470- }, std :: move ($3) );
464+ [&](Expr * expr) { $$.emplace_back(expr); }}
465+ );
471466 }
472467 | attr { $$.emplace_back(state->symbols.create($1)); }
473468 | string_attr
474- { std:: visit(overloaded {
469+ { $1. visit(overloaded{
475470 [&](std::string_view str) { $$.emplace_back(state->symbols.create(str)); },
476- [&](Expr * expr) { $$.emplace_back(expr); }
477- }, std::move($1) );
471+ [&](Expr * expr) { $$.emplace_back(expr); }}
472+ );
478473 }
479474 ;
480475
485480
486481string_attr
487482 : '"' string_parts '"' { $$ = std::move($2); }
488- | DOLLAR_CURLY expr '}' { $$ = $2 ; }
483+ | DOLLAR_CURLY expr '}' { $$ = {$2} ; }
489484 ;
490485
491486list
0 commit comments