aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-08-15 09:21:19 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-08-15 09:21:19 +0000
commit163db7367fb45955069b46014e60224b1bc037b6 (patch)
tree7fa36ec65ee0131620b94a2673ac7b31796e1eda /src
parent161aab582bb3d794414c0275ff8216292f85ab5c (diff)
* Fix can now read expressions from stdin (by saying `fix -').
Diffstat (limited to 'src')
-rw-r--r--src/fix.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/fix.cc b/src/fix.cc
index e50d77620..2a1c09c2a 100644
--- a/src/fix.cc
+++ b/src/fix.cc
@@ -375,6 +375,16 @@ static Expr evalFile(EvalState & state, string relPath)
}
+static Expr evalStdin(EvalState & state)
+{
+ Nest nest(lvlTalkative, format("evaluating standard input"));
+ Expr e = ATreadFromFile(stdin);
+ if (!e)
+ throw Error(format("unable to read a term from stdin"));
+ return evalExpr(state, e);
+}
+
+
static void printFSId(EvalState & state, Expr e)
{
ATermList es;
@@ -398,6 +408,7 @@ void run(Strings args)
EvalState state;
Strings files;
+ bool readStdin = false;
state.searchDirs.push_back(".");
state.searchDirs.push_back(nixDataDir + "/fix");
@@ -414,13 +425,18 @@ void run(Strings args)
}
else if (arg == "--verbose" || arg == "-v")
verbosity = (Verbosity) ((int) verbosity + 1);
+ else if (arg == "-")
+ readStdin = true;
else if (arg[0] == '-')
throw UsageError(format("unknown flag `%1%`") % arg);
else
files.push_back(arg);
}
- if (files.empty()) throw UsageError("no files specified");
+ if (readStdin) {
+ Expr e = evalStdin(state);
+ printFSId(state, e);
+ }
for (Strings::iterator it = files.begin();
it != files.end(); it++)