From 21071bfdeb0a5bc2b75018c91a4c2f138f233e33 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Tue, 14 Sep 2021 10:49:22 -0600 Subject: shared_ptr for StaticEnv --- src/libexpr/parser.y | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index f948dde47..d1e898677 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -570,7 +570,7 @@ namespace nix { Expr * EvalState::parse(const char * text, FileOrigin origin, - const Path & path, const Path & basePath, StaticEnv & staticEnv) + const Path & path, const Path & basePath, std::shared_ptr & staticEnv) { yyscan_t scanner; ParseData data(*this); @@ -633,13 +633,13 @@ Expr * EvalState::parseExprFromFile(const Path & path) } -Expr * EvalState::parseExprFromFile(const Path & path, StaticEnv & staticEnv) +Expr * EvalState::parseExprFromFile(const Path & path, std::shared_ptr & staticEnv) { return parse(readFile(path).c_str(), foFile, path, dirOf(path), staticEnv); } -Expr * EvalState::parseExprFromString(std::string_view s, const Path & basePath, StaticEnv & staticEnv) +Expr * EvalState::parseExprFromString(std::string_view s, const Path & basePath, std::shared_ptr & staticEnv) { return parse(s.data(), foString, "", basePath, staticEnv); } -- cgit v1.2.3 From cd8c232b554776031f61cee5f70a8825c60fbfdb Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Wed, 15 Sep 2021 16:16:53 -0600 Subject: add cout debugging --- src/libexpr/parser.y | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index d1e898677..a3432eb32 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -22,6 +22,8 @@ #include "eval.hh" #include "globals.hh" +#include + namespace nix { struct ParseData @@ -572,6 +574,10 @@ namespace nix { Expr * EvalState::parse(const char * text, FileOrigin origin, const Path & path, const Path & basePath, std::shared_ptr & staticEnv) { + std::cout << "EvalState::parse " << std::endl; + for (auto i = staticEnv->vars.begin(); i != staticEnv->vars.end(); ++i) + std::cout << "EvalState::parse staticEnv " << i->first << std::endl; + yyscan_t scanner; ParseData data(*this); data.origin = origin; @@ -595,8 +601,13 @@ Expr * EvalState::parse(const char * text, FileOrigin origin, if (res) throw ParseError(data.error.value()); + + std::cout << "EvalState::parse pre bindvars " << std::endl; + data.result->bindVars(staticEnv); + std::cout << "EvalState::parse post bindVars " << std::endl; + return data.result; } -- cgit v1.2.3 From c7e3d830c1f305797b7a4c8b8199ba913d6b8a02 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Wed, 22 Sep 2021 16:22:53 -0600 Subject: more debug stuff --- src/libexpr/parser.y | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index a3432eb32..f10e73cda 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -574,7 +574,7 @@ namespace nix { Expr * EvalState::parse(const char * text, FileOrigin origin, const Path & path, const Path & basePath, std::shared_ptr & staticEnv) { - std::cout << "EvalState::parse " << std::endl; + std::cout << "EvalState::parse " << text << std::endl; for (auto i = staticEnv->vars.begin(); i != staticEnv->vars.end(); ++i) std::cout << "EvalState::parse staticEnv " << i->first << std::endl; -- cgit v1.2.3 From 427fb8d1581d7b20b0f5205cc59f3857275860c1 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 11 Oct 2021 16:48:10 -0600 Subject: comment out debugs --- src/libexpr/parser.y | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index f10e73cda..46bbce1f6 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -574,9 +574,9 @@ namespace nix { Expr * EvalState::parse(const char * text, FileOrigin origin, const Path & path, const Path & basePath, std::shared_ptr & staticEnv) { - std::cout << "EvalState::parse " << text << std::endl; - for (auto i = staticEnv->vars.begin(); i != staticEnv->vars.end(); ++i) - std::cout << "EvalState::parse staticEnv " << i->first << std::endl; + // std::cout << "EvalState::parse " << text << std::endl; + // for (auto i = staticEnv->vars.begin(); i != staticEnv->vars.end(); ++i) + // std::cout << "EvalState::parse staticEnv " << i->first << std::endl; yyscan_t scanner; ParseData data(*this); @@ -602,11 +602,11 @@ Expr * EvalState::parse(const char * text, FileOrigin origin, if (res) throw ParseError(data.error.value()); - std::cout << "EvalState::parse pre bindvars " << std::endl; + // std::cout << "EvalState::parse pre bindvars " << std::endl; data.result->bindVars(staticEnv); - std::cout << "EvalState::parse post bindVars " << std::endl; + // std::cout << "EvalState::parse post bindVars " << std::endl; return data.result; } -- cgit v1.2.3 From e54f17eb46bc487abc38e70dfc2f1c617fb59d32 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Fri, 22 Oct 2021 14:27:04 -0600 Subject: remove more debug code --- src/libexpr/parser.y | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 46bbce1f6..d6d5c85f5 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -574,10 +574,6 @@ namespace nix { Expr * EvalState::parse(const char * text, FileOrigin origin, const Path & path, const Path & basePath, std::shared_ptr & staticEnv) { - // std::cout << "EvalState::parse " << text << std::endl; - // for (auto i = staticEnv->vars.begin(); i != staticEnv->vars.end(); ++i) - // std::cout << "EvalState::parse staticEnv " << i->first << std::endl; - yyscan_t scanner; ParseData data(*this); data.origin = origin; @@ -601,13 +597,8 @@ Expr * EvalState::parse(const char * text, FileOrigin origin, if (res) throw ParseError(data.error.value()); - - // std::cout << "EvalState::parse pre bindvars " << std::endl; - data.result->bindVars(staticEnv); - // std::cout << "EvalState::parse post bindVars " << std::endl; - return data.result; } -- cgit v1.2.3 From fb8377547bcb6d4dc6464ca34c0fe433e1cfda44 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Fri, 22 Oct 2021 14:49:58 -0600 Subject: more code cleanup --- src/libexpr/parser.y | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index d6d5c85f5..d1e898677 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -22,8 +22,6 @@ #include "eval.hh" #include "globals.hh" -#include - namespace nix { struct ParseData -- cgit v1.2.3 From f317019edda7afac8590e68d4d979b03a2cdbf62 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 20 Dec 2021 12:32:21 -0700 Subject: :d error --- src/libexpr/parser.y | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 58af0df7d..066dc4ecc 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -21,6 +21,7 @@ #include "nixexpr.hh" #include "eval.hh" #include "globals.hh" +#include namespace nix { @@ -615,6 +616,10 @@ Expr * EvalState::parse(const char * text, FileOrigin origin, if (res) throw ParseError(data.error.value()); + std::cout << " data.result->bindVars(staticEnv); " << std::endl; + + // printStaticEnvBindings(*staticEnv, 0); + data.result->bindVars(staticEnv); return data.result; -- cgit v1.2.3 From 4610e02d04c9f41ac355d2ca6a27d3a631ffefc6 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 27 Dec 2021 18:12:46 -0700 Subject: remove debug code --- src/libexpr/parser.y | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 066dc4ecc..c537aa0c2 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -616,10 +616,6 @@ Expr * EvalState::parse(const char * text, FileOrigin origin, if (res) throw ParseError(data.error.value()); - std::cout << " data.result->bindVars(staticEnv); " << std::endl; - - // printStaticEnvBindings(*staticEnv, 0); - data.result->bindVars(staticEnv); return data.result; -- cgit v1.2.3 From eaecaaa00ba79b05f49a908f2c96c6507d3a2d7b Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Mon, 14 Mar 2022 11:39:53 -0600 Subject: more debug_throw coverage of EvalErrors --- src/libexpr/parser.y | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index d9291e7a2..184fba03e 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -783,13 +783,14 @@ Path EvalState::findFile(SearchPath & searchPath, const std::string_view path, c if (hasPrefix(path, "nix/")) return concatStrings(corepkgsPrefix, path.substr(4)); - throw ThrownError({ + debug_throw(ThrownError({ .msg = hintfmt(evalSettings.pureEval ? "cannot look up '<%s>' in pure evaluation mode (use '--impure' to override)" : "file '%s' was not found in the Nix search path (add it using $NIX_PATH or -I)", path), .errPos = pos - }); + })); + return Path(); // should never execute due to debug_throw above. } -- cgit v1.2.3 From b8b8ec710160cfd343a8fce33ec8734e23c98444 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Fri, 8 Apr 2022 12:34:27 -0600 Subject: move throw to preverve Error type; turn off debugger for tryEval --- src/libexpr/parser.y | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 4182f36d5..ecfa5b7c2 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -783,14 +783,15 @@ Path EvalState::findFile(SearchPath & searchPath, const std::string_view path, c if (hasPrefix(path, "nix/")) return concatStrings(corepkgsPrefix, path.substr(4)); - debug_throw(ThrownError({ + auto e = ThrownError({ .msg = hintfmt(evalSettings.pureEval ? "cannot look up '<%s>' in pure evaluation mode (use '--impure' to override)" : "file '%s' was not found in the Nix search path (add it using $NIX_PATH or -I)", path), .errPos = pos - })); - return Path(); // should never execute due to debug_throw above. + }); + debugLastTrace(e); + throw e; } -- cgit v1.2.3 From 27d45f9eb3c151afed8a20f1adc1d4dd1a200f09 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Fri, 8 Apr 2022 15:46:12 -0600 Subject: minor cleanup --- src/libexpr/parser.y | 1 - 1 file changed, 1 deletion(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index ecfa5b7c2..1a5832e6b 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -23,7 +23,6 @@ #include "nixexpr.hh" #include "eval.hh" #include "globals.hh" -#include namespace nix { -- cgit v1.2.3 From 2c9fafdc9e43f6da39c289888dedbbbf0ea0b208 Mon Sep 17 00:00:00 2001 From: Ben Burdette Date: Fri, 6 May 2022 08:47:21 -0600 Subject: trying debugThrow --- src/libexpr/parser.y | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index 8edafdd57..b960cd8df 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -789,8 +789,7 @@ Path EvalState::findFile(SearchPath & searchPath, const std::string_view path, c path), .errPos = positions[pos] }); - debugLastTrace(e); - throw e; + debugThrowLastTrace(e); } -- cgit v1.2.3 From 91b7d5373acdc5d9b3f2c13d16b9850ab5fc9e9d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 25 May 2022 12:32:22 +0200 Subject: Style tweaks --- src/libexpr/parser.y | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index b960cd8df..e3e0ac168 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -782,14 +782,13 @@ Path EvalState::findFile(SearchPath & searchPath, const std::string_view path, c if (hasPrefix(path, "nix/")) return concatStrings(corepkgsPrefix, path.substr(4)); - auto e = ThrownError({ + debugThrowLastTrace(ThrownError({ .msg = hintfmt(evalSettings.pureEval ? "cannot look up '<%s>' in pure evaluation mode (use '--impure' to override)" : "file '%s' was not found in the Nix search path (add it using $NIX_PATH or -I)", path), .errPos = positions[pos] - }); - debugThrowLastTrace(e); + })); } -- cgit v1.2.3 From 9acc770ce4bf0e748b41d2f9515c436ae6960c6d Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 25 May 2022 15:49:41 +0200 Subject: Remove pre-C++11 hackiness --- src/libexpr/parser.y | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/libexpr/parser.y') diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y index e3e0ac168..8cbc2da4d 100644 --- a/src/libexpr/parser.y +++ b/src/libexpr/parser.y @@ -193,7 +193,7 @@ static Formals * toFormals(ParseData & data, ParserFormals * formals, static Expr * stripIndentation(const PosIdx pos, SymbolTable & symbols, - std::vector > > & es) + std::vector>> & es) { if (es.empty()) return new ExprString(""); @@ -233,7 +233,7 @@ static Expr * stripIndentation(const PosIdx pos, SymbolTable & symbols, } /* Strip spaces from each line. */ - auto * es2 = new std::vector >; + auto * es2 = new std::vector>; atStartOfLine = true; size_t curDropped = 0; size_t n = es.size(); @@ -320,8 +320,8 @@ void yyerror(YYLTYPE * loc, yyscan_t scanner, ParseData * data, const char * err StringToken uri; StringToken str; std::vector * attrNames; - std::vector > * string_parts; - std::vector > > * ind_string_parts; + std::vector> * string_parts; + std::vector>> * ind_string_parts; } %type start expr expr_function expr_if expr_op @@ -415,7 +415,7 @@ expr_op | expr_op UPDATE expr_op { $$ = new ExprOpUpdate(CUR_POS, $1, $3); } | expr_op '?' attrpath { $$ = new ExprOpHasAttr($1, *$3); } | expr_op '+' expr_op - { $$ = new ExprConcatStrings(CUR_POS, false, new std::vector >({{makeCurPos(@1, data), $1}, {makeCurPos(@3, data), $3}})); } + { $$ = new ExprConcatStrings(CUR_POS, false, new std::vector>({{makeCurPos(@1, data), $1}, {makeCurPos(@3, data), $3}})); } | expr_op '-' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__sub")), {$1, $3}); } | expr_op '*' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__mul")), {$1, $3}); } | expr_op '/' expr_op { $$ = new ExprCall(CUR_POS, new ExprVar(data->symbols.create("__div")), {$1, $3}); } @@ -503,9 +503,9 @@ string_parts_interpolated : string_parts_interpolated STR { $$ = $1; $1->emplace_back(makeCurPos(@2, data), new ExprString(std::string($2))); } | string_parts_interpolated DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); } - | DOLLAR_CURLY expr '}' { $$ = new std::vector >; $$->emplace_back(makeCurPos(@1, data), $2); } + | DOLLAR_CURLY expr '}' { $$ = new std::vector>; $$->emplace_back(makeCurPos(@1, data), $2); } | STR DOLLAR_CURLY expr '}' { - $$ = new std::vector >; + $$ = new std::vector>; $$->emplace_back(makeCurPos(@1, data), new ExprString(std::string($1))); $$->emplace_back(makeCurPos(@2, data), $3); } @@ -528,7 +528,7 @@ path_start ind_string_parts : ind_string_parts IND_STR { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $2); } | ind_string_parts DOLLAR_CURLY expr '}' { $$ = $1; $1->emplace_back(makeCurPos(@2, data), $3); } - | { $$ = new std::vector > >; } + | { $$ = new std::vector>>; } ; binds -- cgit v1.2.3