diff options
Diffstat (limited to 'src/tuplr.cpp')
-rw-r--r-- | src/tuplr.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/tuplr.cpp b/src/tuplr.cpp index 481885c..867897d 100644 --- a/src/tuplr.cpp +++ b/src/tuplr.cpp @@ -35,13 +35,13 @@ print_usage(char* name, bool error) os << "Usage: " << name << " [OPTION]... [FILE]..." << endl; os << "Evaluate and/or compile Tuplr code" << endl; os << endl; - os << " -h Display this help and exit" << endl; - os << " -r Enter REPL after evaluating files" << endl; - os << " -p Pretty-print input only" << endl; - os << " -g Debug (disable optimisation)" << endl; - os << " -d Dump assembly output" << endl; - os << " -e EXPRESSION Evaluate EXPRESSION" << endl; - os << " -o FILE Write output to FILE" << endl; + os << " -h Display this help and exit" << endl; + os << " -r Enter REPL after evaluating files" << endl; + os << " -p Pretty-print input only" << endl; + os << " -g Debug (disable optimisation)" << endl; + os << " -d Dump assembly output" << endl; + os << " -e EXPRESSION Evaluate EXPRESSION" << endl; + os << " -o FILE Compile output to FILE (don't run)" << endl; return error ? 1 : 0; } @@ -80,6 +80,8 @@ main(int argc, char** argv) if (backend_name == "llvm") engine = tuplr_new_llvm_engine(); + else if (backend_name == "c") + engine = tuplr_new_c_engine(); if (!engine) { std::cerr << "Unable to open backend " << backend_name << std::endl; @@ -95,6 +97,7 @@ main(int argc, char** argv) int ret = 0; a = args.find("-o"); + bool batch = a != args.end(); const string output = (a != args.end()) ? a->second : ""; if (args.find("-p") != args.end()) { @@ -111,13 +114,13 @@ main(int argc, char** argv) a = args.find("-e"); if (a != args.end()) { istringstream is(a->second); - ret = eval(*cenv, "(command line)", is); + ret = eval(*cenv, "(command line)", is, !batch); } for (list<string>::iterator f = files.begin(); f != files.end(); ++f) { ifstream is(f->c_str()); if (is.good()) { - ret = ret | eval(*cenv, *f, is); + ret = ret | eval(*cenv, *f, is, !batch); } else { cerr << argv[0] << ": " << *f << ": " << strerror(errno) << endl; ++ret; |