about summary refs log tree commit diff
path: root/src/fix-ng/fix.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-11-16T17·46+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-11-16T17·46+0000
commit3e5a019a070cbaac7d1248e208c66da9fdb23313 (patch)
treedc18227825e04cabe6a4829cc76c7729792b7d78 /src/fix-ng/fix.cc
parent06ae269c7c5cdda32072f3f00cf644e540ba12cd (diff)
* Some utility functions for working with ATerms.
Diffstat (limited to 'src/fix-ng/fix.cc')
-rw-r--r--src/fix-ng/fix.cc36
1 files changed, 3 insertions, 33 deletions
diff --git a/src/fix-ng/fix.cc b/src/fix-ng/fix.cc
index dc2790a60ad9..49f19669a08b 100644
--- a/src/fix-ng/fix.cc
+++ b/src/fix-ng/fix.cc
@@ -27,37 +27,6 @@ static Path searchPath(const Paths & searchDirs, const Path & relPath)
 #endif
 
 
-#if 0
-static Expr evalExpr2(EvalState & state, Expr e)
-{
-    /* Ad-hoc function for string matching. */
-    if (ATmatch(e, "HasSubstr(<term>, <term>)", &e1, &e2)) {
-        e1 = evalExpr(state, e1);
-        e2 = evalExpr(state, e2);
-        
-        char * s1, * s2;
-        if (!ATmatch(e1, "<str>", &s1))
-            throw badTerm("expecting a string", e1);
-        if (!ATmatch(e2, "<str>", &s2))
-            throw badTerm("expecting a string", e2);
-        
-        return
-            string(s1).find(string(s2)) != string::npos ?
-            ATmake("True") : ATmake("False");
-    }
-
-    /* BaseName primitive function. */
-    if (ATmatch(e, "BaseName(<term>)", &e1)) {
-        e1 = evalExpr(state, e1);
-        if (!ATmatch(e1, "<str>", &s1)) 
-            throw badTerm("string expected", e1);
-        return ATmake("<str>", baseNameOf(s1).c_str());
-    }
-
-}
-#endif
-
-
 static Expr evalStdin(EvalState & state)
 {
     startNest(nest, lvlTalkative, format("evaluating standard input"));
@@ -70,9 +39,10 @@ static Expr evalStdin(EvalState & state)
 
 static void printNixExpr(EvalState & state, Expr e)
 {
+    ATMatcher m;
     ATermList es;
 
-    if (ATmatch(e, "Attrs([<list>])", &es)) {
+    if (atMatch(m, e) >> "Attrs" >> es) {
         Expr a = queryAttr(e, "type");
         if (a && evalString(state, a) == "derivation") {
             a = queryAttr(e, "drvPath");
@@ -83,7 +53,7 @@ static void printNixExpr(EvalState & state, Expr e)
         }
     }
 
-    if (ATmatch(e, "[<list>]", &es)) {
+    if (ATgetType(e) == AT_LIST) {
         while (!ATisEmpty(es)) {
             printNixExpr(state, evalExpr(state, ATgetFirst(es)));
             es = ATgetNext(es);