diff options
author | David Robillard <d@drobilla.net> | 2010-12-09 23:08:25 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-12-09 23:08:25 +0000 |
commit | 9ca23b0ba970e58d2207cb85ab6093c9ddaa4e2a (patch) | |
tree | 7a97817405f31effc042623033d0252bbdb0c063 | |
parent | c06034464c9f0465224b46775b771b175429c9c1 (diff) | |
download | resp-9ca23b0ba970e58d2207cb85ab6093c9ddaa4e2a.tar.gz resp-9ca23b0ba970e58d2207cb85ab6093c9ddaa4e2a.tar.bz2 resp-9ca23b0ba970e58d2207cb85ab6093c9ddaa4e2a.zip |
Add option -a to annotate printed code (for -T and -L).
git-svn-id: http://svn.drobilla.net/resp/resp@340 ad02d1e2-f140-0410-9f75-f8b11f17cedd
-rw-r--r-- | src/repl.cpp | 5 | ||||
-rw-r--r-- | src/resp.cpp | 31 |
2 files changed, 20 insertions, 16 deletions
diff --git a/src/repl.cpp b/src/repl.cpp index a1d3e74..52d35c5 100644 --- a/src/repl.cpp +++ b/src/repl.cpp @@ -96,7 +96,7 @@ eval(CEnv& cenv, Cursor& cursor, istream& is, bool execute) if (cenv.args.find("-T") != cenv.args.end()) { for (Parsed::const_iterator i = parsed.begin(); i != parsed.end(); ++i) - pprint(cout, *i, &cenv, true); + pprint(cout, *i, &cenv, (cenv.args.find("-a") != cenv.args.end())); return 0; } @@ -113,7 +113,8 @@ eval(CEnv& cenv, Cursor& cursor, istream& is, bool execute) if (cenv.args.find("-L") != cenv.args.end()) { for (Code::const_iterator i = lifted.begin(); i != lifted.end(); ++i) - pprint(cout, *i, &cenv, true); + pprint(cout, *i, &cenv, (cenv.args.find("-a") != cenv.args.end())); + return 0; } diff --git a/src/resp.cpp b/src/resp.cpp index e3c956f..765939c 100644 --- a/src/resp.cpp +++ b/src/resp.cpp @@ -68,16 +68,18 @@ print_usage(char* name, bool error) os << "Usage: " << name << " [OPTION]... [FILE]..." << endl; os << "Evaluate and/or compile Resp code" << endl; os << endl; - os << " -h Display this help and exit" << endl; - os << " -r Enter REPL after evaluating files" << endl; - os << " -b BACKEND Use backend (llvm or c)" << endl; - os << " -g Debug (disable optimisation)" << endl; - os << " -P Parse and pretty-print only" << endl; - os << " -T Type check and annotate only" << endl; - os << " -L Lambda lift only" << endl; - os << " -S Compile to assembly only (do not evaluate)" << endl; - os << " -e EXPRESSION Evaluate EXPRESSION" << endl; - os << " -o FILE Compile output to FILE (don't run)" << endl; + os << " -a Annotate output with types" << endl; + os << " -b BACKEND Use backend (llvm or c)" << endl; + os << " -e EXPRESSION Evaluate EXPRESSION" << endl; + os << " -g Debug (disable optimisation)" << endl; + os << " -h Display this help and exit" << endl; + os << " -o FILE Compile output to FILE (don't run)" << endl; + os << " -r Enter REPL after evaluating files" << endl; + os << " -P Parse only" << endl; + os << " -T Type check only" << endl; + os << " -L Lambda lift only" << endl; + os << " -S Compile to assembly only (do not execute)" << endl; + return error ? 1 : 0; } @@ -92,12 +94,13 @@ main(int argc, char** argv) return print_usage(argv[0], false); } else if (argv[i][0] != '-') { files.push_back(argv[i]); - } else if (!strncmp(argv[i], "-r", 3) - || !strncmp(argv[i], "-g", 3) + } else if (!strncmp(argv[i], "-L", 3) || !strncmp(argv[i], "-P", 3) + || !strncmp(argv[i], "-S", 3) || !strncmp(argv[i], "-T", 3) - || !strncmp(argv[i], "-L", 3) - || !strncmp(argv[i], "-S", 3)) { + || !strncmp(argv[i], "-a", 3) + || !strncmp(argv[i], "-g", 3) + || !strncmp(argv[i], "-r", 3)) { args.insert(make_pair(argv[i], "")); } else if (i == argc-1 || argv[i+1][0] == '-') { return print_usage(argv[0], true); |