about summary refs log tree commit diff
path: root/src/libexpr/parser.y
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-09-02T16·34+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-09-02T16·34+0200
commit57d18df7d0005cf822368d9f1d0c33396c6b9f9f (patch)
tree41ad0f3493b8c4baeb35f5b5028fb6cf9a17dc9f /src/libexpr/parser.y
parent92077b4547b473bb4ea7b38077299e8fba75ca62 (diff)
Add some support code for nix-repl
Diffstat (limited to 'src/libexpr/parser.y')
-rw-r--r--src/libexpr/parser.y14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/libexpr/parser.y b/src/libexpr/parser.y
index 60ad3f0792c4..623ac641cca9 100644
--- a/src/libexpr/parser.y
+++ b/src/libexpr/parser.y
@@ -481,7 +481,7 @@ namespace nix {
 
 
 Expr * EvalState::parse(const char * text,
-    const Path & path, const Path & basePath)
+    const Path & path, const Path & basePath, StaticEnv & staticEnv)
 {
     yyscan_t scanner;
     ParseData data(*this);
@@ -496,7 +496,7 @@ Expr * EvalState::parse(const char * text,
     if (res) throw ParseError(data.error);
 
     try {
-        data.result->bindVars(staticBaseEnv);
+        data.result->bindVars(staticEnv);
     } catch (Error & e) {
         throw ParseError(format("%1%, in `%2%'") % e.msg() % path);
     }
@@ -527,7 +527,7 @@ Expr * EvalState::parseExprFromFile(Path path)
        tree cache. */
     Expr * e = parseTrees[path];
     if (!e) {
-        e = parse(readFile(path).c_str(), path, dirOf(path));
+        e = parse(readFile(path).c_str(), path, dirOf(path), staticBaseEnv);
         parseTrees[path] = e;
     }
 
@@ -535,9 +535,15 @@ Expr * EvalState::parseExprFromFile(Path path)
 }
 
 
+Expr * EvalState::parseExprFromString(const string & s, const Path & basePath, StaticEnv & staticEnv)
+{
+    return parse(s.c_str(), "(string)", basePath, staticEnv);
+}
+
+
 Expr * EvalState::parseExprFromString(const string & s, const Path & basePath)
 {
-    return parse(s.c_str(), "(string)", basePath);
+    return parseExprFromString(s, basePath, staticBaseEnv);
 }