aboutsummaryrefslogtreecommitdiff
path: root/src/libexpr/eval.cc
diff options
context:
space:
mode:
authoreldritch horrors <pennae@lix.systems>2024-03-08 05:35:12 +0100
committereldritch horrors <pennae@lix.systems>2024-03-09 00:25:54 -0700
commit92693973b6e059e9d6056cf6547cc66459efc580 (patch)
tree9194588c9a016787219b13f34a93cf80647c5bca /src/libexpr/eval.cc
parentfaaae9d045c392894ed78d9f9466ce2968f9bcb4 (diff)
decouple parser and EvalState
there's no reason the parser itself should be doing semantic analysis like bindVars. split this bit apart (retaining the previous name in EvalState) and have the parser really do *only* parsing, decoupled from EvalState. (cherry picked from commit b596cc9e7960b9256bcd557334d81e9d555be5a2) Change-Id: I481a7623afc783e9d28a6eb4627552cf8a780986
Diffstat (limited to 'src/libexpr/eval.cc')
-rw-r--r--src/libexpr/eval.cc17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libexpr/eval.cc b/src/libexpr/eval.cc
index 35b09f4d5..2a6a89ddb 100644
--- a/src/libexpr/eval.cc
+++ b/src/libexpr/eval.cc
@@ -17,6 +17,7 @@
#include "gc-small-vector.hh"
#include "fetch-to-store.hh"
#include "flake/flakeref.hh"
+#include "parser-tab.hh"
#include <algorithm>
#include <chrono>
@@ -2806,6 +2807,22 @@ std::optional<std::string> EvalState::resolveSearchPathPath(const SearchPath::Pa
return res;
}
+
+Expr * EvalState::parse(
+ char * text,
+ size_t length,
+ Pos::Origin origin,
+ const SourcePath & basePath,
+ std::shared_ptr<StaticEnv> & staticEnv)
+{
+ auto result = parseExprFromBuf(text, length, origin, basePath, symbols, positions);
+
+ result->bindVars(*this, staticEnv);
+
+ return result;
+}
+
+
std::string ExternalValueBase::coerceToString(const Pos & pos, NixStringContext & context, bool copyMore, bool copyToStore) const
{
throw TypeError({