@@ -63,7 +63,7 @@ Expr * parseExprFromBuf(
6363 size_t length,
6464 Pos::Origin origin,
6565 const SourcePath & basePath,
66- std::pmr::polymorphic_allocator< char > & alloc ,
66+ Exprs & exprs ,
6767 SymbolTable & symbols,
6868 const EvalSettings & settings,
6969 PosTable & positions,
@@ -186,23 +186,23 @@ expr_function
186186 | formal_set ':' expr_function[body]
187187 {
188188 state->validateFormals($formal_set);
189- auto me = new ExprLambda(state->positions, state->alloc, CUR_POS, std::move($formal_set), $body);
189+ auto me = new ExprLambda(state->positions, state->exprs. alloc, CUR_POS, std::move($formal_set), $body);
190190 $$ = me;
191191 SET_DOC_POS(me, @1);
192192 }
193193 | formal_set '@' ID ':' expr_function[body]
194194 {
195195 auto arg = state->symbols.create($ID);
196196 state->validateFormals($formal_set, CUR_POS, arg);
197- auto me = new ExprLambda(state->positions, state->alloc, CUR_POS, arg, std::move($formal_set), $body);
197+ auto me = new ExprLambda(state->positions, state->exprs. alloc, CUR_POS, arg, std::move($formal_set), $body);
198198 $$ = me;
199199 SET_DOC_POS(me, @1);
200200 }
201201 | ID '@' formal_set ':' expr_function[body]
202202 {
203203 auto arg = state->symbols.create($ID);
204204 state->validateFormals($formal_set, CUR_POS, arg);
205- auto me = new ExprLambda(state->positions, state->alloc, CUR_POS, arg, std::move($formal_set), $body);
205+ auto me = new ExprLambda(state->positions, state->exprs. alloc, CUR_POS, arg, std::move($formal_set), $body);
206206 $$ = me;
207207 SET_DOC_POS(me, @1);
208208 }
@@ -251,9 +251,9 @@ expr_op
251251 | expr_op OR expr_op { $$ = new ExprOpOr(state->at(@2), $1, $3); }
252252 | expr_op IMPL expr_op { $$ = new ExprOpImpl(state->at(@2), $1, $3); }
253253 | expr_op UPDATE expr_op { $$ = new ExprOpUpdate(state->at(@2), $1, $3); }
254- | expr_op '?' attrpath { $$ = new ExprOpHasAttr(state->alloc, $1, std::move($3)); }
254+ | expr_op '?' attrpath { $$ = new ExprOpHasAttr(state->exprs. alloc, $1, std::move($3)); }
255255 | expr_op '+' expr_op
256- { $$ = new ExprConcatStrings(state->alloc, state->at(@2), false, {{state->at(@1), $1}, {state->at(@3), $3}}); }
256+ { $$ = new ExprConcatStrings(state->exprs. alloc, state->at(@2), false, {{state->at(@1), $1}, {state->at(@3), $3}}); }
257257 | expr_op '-' expr_op { $$ = new ExprCall(state->at(@2), new ExprVar(state->s.sub), {$1, $3}); }
258258 | expr_op '*' expr_op { $$ = new ExprCall(state->at(@2), new ExprVar(state->s.mul), {$1, $3}); }
259259 | expr_op '/' expr_op { $$ = new ExprCall(state->at(@2), new ExprVar(state->s.div), {$1, $3}); }
@@ -272,9 +272,9 @@ expr_app
272272
273273expr_select
274274 : expr_simple '.' attrpath
275- { $$ = new ExprSelect(state->alloc, CUR_POS, $1, std::move($3), nullptr); }
275+ { $$ = new ExprSelect(state->exprs. alloc, CUR_POS, $1, std::move($3), nullptr); }
276276 | expr_simple '.' attrpath OR_KW expr_select
277- { $$ = new ExprSelect(state->alloc, CUR_POS, $1, std::move($3), $5); $5->warnIfCursedOr(state->symbols, state->positions); }
277+ { $$ = new ExprSelect(state->exprs. alloc, CUR_POS, $1, std::move($3), $5); $5->warnIfCursedOr(state->symbols, state->positions); }
278278 | /* Backwards compatibility: because Nixpkgs has a function named ‘or’,
279279 allow stuff like ‘map or [...]’. This production is problematic (see
280280 https://github.com/NixOS/nix/issues/11118) and will be refactored in the
@@ -299,7 +299,7 @@ expr_simple
299299 | FLOAT_LIT { $$ = new ExprFloat($1); }
300300 | '"' string_parts '"' {
301301 std ::visit (overloaded {
302- [&](std::string_view str) { $$ = new ExprString(state->alloc, str); },
302+ [&](std::string_view str) { $$ = new ExprString(state->exprs. alloc, str); },
303303 [&](Expr * expr) { $$ = expr; }},
304304 $2);
305305 }
@@ -309,14 +309,14 @@ expr_simple
309309 | path_start PATH_END
310310 | path_start string_parts_interpolated PATH_END {
311311 $2.insert($2.begin(), {state->at(@1), $1});
312- $$ = new ExprConcatStrings(state->alloc, CUR_POS, false, std::move($2));
312+ $$ = new ExprConcatStrings(state->exprs. alloc, CUR_POS, false, std::move($2));
313313 }
314314 | SPATH {
315315 std ::string_view path ($1.p + 1, $1.l - 2);
316316 $$ = new ExprCall(CUR_POS,
317317 new ExprVar(state->s.findFile),
318318 {new ExprVar(state->s.nixPath),
319- new ExprString(state->alloc, path)});
319+ new ExprString(state->exprs. alloc, path)});
320320 }
321321 | URI {
322322 static bool noURLLiterals = experimentalFeatureSettings.isEnabled(Xp::NoUrlLiterals);
@@ -325,35 +325,35 @@ expr_simple
325325 .msg = HintFmt("URL literals are disabled"),
326326 .pos = state->positions[CUR_POS]
327327 });
328- $$ = new ExprString(state->alloc, $1);
328+ $$ = new ExprString(state->exprs. alloc, $1);
329329 }
330330 | '(' expr ')' { $$ = $2; }
331331 /* Let expressions `let {..., body = ...}' are just desugared
332332 into `(rec {..., body = ...}).body'. */
333333 | LET '{' binds '}'
334- { $3->recursive = true; $3->pos = CUR_POS; $$ = new ExprSelect(state->alloc, noPos, $3, state->s.body); }
334+ { $3->recursive = true; $3->pos = CUR_POS; $$ = new ExprSelect(state->exprs. alloc, noPos, $3, state->s.body); }
335335 | REC '{' binds '}'
336336 { $3->recursive = true; $3->pos = CUR_POS; $$ = $3; }
337337 | '{' binds1 '}'
338338 { $2->pos = CUR_POS; $$ = $2; }
339339 | '{' '}'
340340 { $$ = new ExprAttrs(CUR_POS); }
341- | '[' list ']' { $$ = new ExprList(state->alloc, std::move($2)); }
341+ | '[' list ']' { $$ = new ExprList(state->exprs. alloc, std::move($2)); }
342342 ;
343343
344344string_parts
345345 : STR { $$ = $1; }
346- | string_parts_interpolated { $$ = new ExprConcatStrings(state->alloc, CUR_POS, true, std::move($1)); }
346+ | string_parts_interpolated { $$ = new ExprConcatStrings(state->exprs. alloc, CUR_POS, true, std::move($1)); }
347347 | { $$ = std::string_view(); }
348348 ;
349349
350350string_parts_interpolated
351351 : string_parts_interpolated STR
352- { $$ = std::move($1); $$.emplace_back(state->at(@2), new ExprString(state->alloc, $2)); }
352+ { $$ = std::move($1); $$.emplace_back(state->at(@2), new ExprString(state->exprs. alloc, $2)); }
353353 | string_parts_interpolated DOLLAR_CURLY expr '}' { $$ = std::move($1); $$.emplace_back(state->at(@2), $3); }
354354 | DOLLAR_CURLY expr '}' { $$.emplace_back(state->at(@1), $2); }
355355 | STR DOLLAR_CURLY expr '}' {
356- $$.emplace_back(state->at(@1), new ExprString(state->alloc, $1));
356+ $$.emplace_back(state->at(@1), new ExprString(state->exprs. alloc, $1));
357357 $$.emplace_back(state->at(@2), $3);
358358 }
359359 ;
@@ -379,8 +379,8 @@ path_start
379379 root filesystem accessor, rather than the accessor of the
380380 current Nix expression. */
381381 literal.front() == '/'
382- ? new ExprPath(state->alloc, state->rootFS, path)
383- : new ExprPath(state->alloc, state->basePath.accessor, path);
382+ ? new ExprPath(state->exprs. alloc, state->rootFS, path)
383+ : new ExprPath(state->exprs. alloc, state->basePath.accessor, path);
384384 }
385385 | HPATH {
386386 if (state->settings.pureEval) {
@@ -390,7 +390,7 @@ path_start
390390 );
391391 }
392392 Path path(getHome() + std::string($1.p + 1, $1.l - 1));
393- $$ = new ExprPath(state->alloc, ref<SourceAccessor>(state->rootFS), path);
393+ $$ = new ExprPath(state->exprs. alloc, ref<SourceAccessor>(state->rootFS), path);
394394 }
395395 ;
396396
@@ -432,7 +432,7 @@ binds1
432432 $accum->attrs.emplace(
433433 i.symbol,
434434 ExprAttrs ::AttrDef (
435- new ExprSelect (state- >alloc , iPos , from , i.symbol ),
435+ new ExprSelect (state- >exprs. alloc , iPos , from , i.symbol ),
436436 iPos ,
437437 ExprAttrs ::AttrDef ::Kind ::InheritedFrom ));
438438 }
@@ -525,7 +525,7 @@ Expr * parseExprFromBuf(
525525 size_t length,
526526 Pos::Origin origin,
527527 const SourcePath & basePath,
528- std::pmr::polymorphic_allocator< char > & alloc ,
528+ Exprs & exprs ,
529529 SymbolTable & symbols,
530530 const EvalSettings & settings,
531531 PosTable & positions,
@@ -540,7 +540,7 @@ Expr * parseExprFromBuf(
540540 };
541541 ParserState state {
542542 .lexerState = lexerState,
543- .alloc = alloc ,
543+ .exprs = exprs ,
544544 .symbols = symbols,
545545 .positions = positions,
546546 .basePath = basePath,
0 commit comments