aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-08-05 11:13:38 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-08-05 11:13:38 +0000
commit17f05dba775bb95858d9ac60ab9a9abcbe88b2fc (patch)
tree29fb9ccef778d5748e7d9654d10077c4199caf3f
parentd6b6b2d3a83aa2afe3cae361954d8aa640fd77da (diff)
* Allow the top-level expression to be a list of expressions that
normalise to Nix expression.
-rw-r--r--src/fix.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/fix.cc b/src/fix.cc
index 4235165cc..57cb12630 100644
--- a/src/fix.cc
+++ b/src/fix.cc
@@ -130,6 +130,7 @@ static Expr evalExpr2(EvalState & state, Expr e)
/* Normal forms. */
if (ATmatch(e, "<str>", &s1) ||
+ ATmatch(e, "[<list>]", &e1) ||
ATmatch(e, "Function([<list>], <term>)", &e1, &e2) ||
ATmatch(e, "FSId(<str>)", &s1))
return e;
@@ -299,6 +300,23 @@ static Expr evalFile(EvalState & state, string relPath)
}
+static void printFSId(EvalState & state, Expr e)
+{
+ ATermList es;
+ char * s;
+ if (ATmatch(e, "FSId(<str>)", &s)) {
+ cout << format("%1%\n") % s;
+ }
+ else if (ATmatch(e, "[<list>]", &es)) {
+ while (!ATisEmpty(es)) {
+ printFSId(state, evalExpr(state, ATgetFirst(es)));
+ es = ATgetNext(es);
+ }
+ }
+ else throw badTerm("top level does not evaluate to a (list of) Nix expression(s)", e);
+}
+
+
void run(Strings args)
{
openDB();
@@ -333,11 +351,7 @@ void run(Strings args)
it != files.end(); it++)
{
Expr e = evalFile(state, *it);
- char * s;
- if (ATmatch(e, "FSId(<str>)", &s)) {
- cout << format("%1%\n") % s;
- }
- else throw badTerm("top level is not a package", e);
+ printFSId(state, e);
}
}