about summary refs log tree commit diff
path: root/src/libexpr/parser.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-02-04T16·03+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-02-04T16·03+0000
commit9b44480612dd30a7292ec94a88e4018b8f18e3f0 (patch)
tree0c83114806a4f7724a5dd8dcb0694103e70acb71 /src/libexpr/parser.cc
parentc4f7ae4aa5fc7071cfa853ec5d75aaf00e7a97fc (diff)
* Use a map to lookup primops.
* Various performance improvements in the evaluator.
* Do not link against unused (and missing!) libraries (-lsglr, etc.).

Diffstat (limited to 'src/libexpr/parser.cc')
-rw-r--r--src/libexpr/parser.cc24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/libexpr/parser.cc b/src/libexpr/parser.cc
index 0a550fb35507..68b367340acf 100644
--- a/src/libexpr/parser.cc
+++ b/src/libexpr/parser.cc
@@ -66,7 +66,8 @@ int yyparse(yyscan_t scanner, ParseData * data);
 }
 
 
-static Expr parse(const char * text, const string & location,
+static Expr parse(EvalState & state,
+    const char * text, const string & location,
     const Path & basePath)
 {
     yyscan_t scanner;
@@ -81,18 +82,8 @@ static Expr parse(const char * text, const string & location,
     
     if (res) throw Error(data.error);
 
-    ATermMap primOps;
-    primOps.set("import", (ATerm) ATempty);
-    primOps.set("derivation", (ATerm) ATempty);
-    primOps.set("true", (ATerm) ATempty);
-    primOps.set("false", (ATerm) ATempty);
-    primOps.set("null", (ATerm) ATempty);
-    primOps.set("isNull", (ATerm) ATempty);
-    primOps.set("toString", (ATerm) ATempty);
-    primOps.set("baseNameOf", (ATerm) ATempty);
-
     try {
-        checkVarDefs(primOps, data.result);
+        checkVarDefs(state.primOpsAll, data.result);
     } catch (Error & e) {
         throw Error(format("%1%, in %2%") % e.msg() % location);
     }
@@ -101,7 +92,7 @@ static Expr parse(const char * text, const string & location,
 }
 
 
-Expr parseExprFromFile(Path path)
+Expr parseExprFromFile(EvalState & state, Path path)
 {
     assert(path[0] == '/');
 
@@ -137,11 +128,12 @@ Expr parseExprFromFile(Path path)
     readFull(fd, (unsigned char *) text, st.st_size);
     text[st.st_size] = 0;
 
-    return parse(text, "`" + path + "'", dirOf(path));
+    return parse(state, text, "`" + path + "'", dirOf(path));
 }
 
 
-Expr parseExprFromString(const string & s, const Path & basePath)
+Expr parseExprFromString(EvalState & state,
+    const string & s, const Path & basePath)
 {
-    return parse(s.c_str(), "(string)", basePath);
+    return parse(state, s.c_str(), "(string)", basePath);
 }