summaryrefslogtreecommitdiff
path: root/cli/cli.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-09-27 19:17:22 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-09-27 19:17:22 +0200
commitc2b7e8a5a7bc98bcf5e03b32eefaa664442c26fe (patch)
tree9d900b5da803aaf55870c8364d4f605aa786d103 /cli/cli.cxx
parente7cd4db81539a04935f00ee01c81541ec1e9b464 (diff)
Add option file for the CLI compiler itself
Diffstat (limited to 'cli/cli.cxx')
-rw-r--r--cli/cli.cxx21
1 files changed, 18 insertions, 3 deletions
diff --git a/cli/cli.cxx b/cli/cli.cxx
index 9b2495d..eaf15f7 100644
--- a/cli/cli.cxx
+++ b/cli/cli.cxx
@@ -7,6 +7,7 @@
#include <fstream>
#include <iostream>
+#include "options.hxx"
#include "parser.hxx"
#include "generator.hxx"
@@ -14,7 +15,7 @@ using namespace std;
int main (int argc, char* argv[])
{
- if (argc != 2)
+ if (argc < 2)
{
cerr << "usage: " << argv[0] << " file.cli" << endl;
return 1;
@@ -22,7 +23,16 @@ int main (int argc, char* argv[])
try
{
- semantics::path path (argv[1]);
+ int end;
+ options ops (argc, argv, end);
+
+ if (end == argc)
+ {
+ cerr << "error: no input file specified" << endl;
+ return 1;
+ }
+
+ semantics::path path (argv[end]);
ifstream ifs (path.string ().c_str ());
if (!ifs.is_open ())
@@ -37,7 +47,12 @@ int main (int argc, char* argv[])
auto_ptr<semantics::cli_unit> unit (p.parse (ifs, path));
generator g;
- g.generate (*unit, path);
+ g.generate (ops, *unit, path);
+ }
+ catch (cli::exception const& e)
+ {
+ cerr << e << endl;
+ return 1;
}
catch (semantics::invalid_path const& e)
{