Skip to content
Snippets Groups Projects
Commit 17f05dba authored by Eelco Dolstra's avatar Eelco Dolstra
Browse files

* Allow the top-level expression to be a list of expressions that

  normalise to Nix expression.
parent d6b6b2d3
No related branches found
No related tags found
No related merge requests found
...@@ -130,6 +130,7 @@ static Expr evalExpr2(EvalState & state, Expr e) ...@@ -130,6 +130,7 @@ static Expr evalExpr2(EvalState & state, Expr e)
/* Normal forms. */ /* Normal forms. */
if (ATmatch(e, "<str>", &s1) || if (ATmatch(e, "<str>", &s1) ||
ATmatch(e, "[<list>]", &e1) ||
ATmatch(e, "Function([<list>], <term>)", &e1, &e2) || ATmatch(e, "Function([<list>], <term>)", &e1, &e2) ||
ATmatch(e, "FSId(<str>)", &s1)) ATmatch(e, "FSId(<str>)", &s1))
return e; return e;
...@@ -299,6 +300,23 @@ static Expr evalFile(EvalState & state, string relPath) ...@@ -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) void run(Strings args)
{ {
openDB(); openDB();
...@@ -333,11 +351,7 @@ void run(Strings args) ...@@ -333,11 +351,7 @@ void run(Strings args)
it != files.end(); it++) it != files.end(); it++)
{ {
Expr e = evalFile(state, *it); Expr e = evalFile(state, *it);
char * s; printFSId(state, e);
if (ATmatch(e, "FSId(<str>)", &s)) {
cout << format("%1%\n") % s;
}
else throw badTerm("top level is not a package", e);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment