summaryrefslogtreecommitdiff
path: root/cli/cli.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'cli/cli.cxx')
-rw-r--r--cli/cli.cxx21
1 files changed, 17 insertions, 4 deletions
diff --git a/cli/cli.cxx b/cli/cli.cxx
index 39fff16..3d54452 100644
--- a/cli/cli.cxx
+++ b/cli/cli.cxx
@@ -3,10 +3,12 @@
// copyright : Copyright (c) 2009 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
+#include <memory> // std::auto_ptr
#include <fstream>
#include <iostream>
#include "parser.hxx"
+#include "generator.hxx"
using namespace std;
@@ -20,21 +22,32 @@ int main (int argc, char* argv[])
try
{
- ifstream ifs (argv[1]);
+ semantics::path path (argv[1]);
+
+ ifstream ifs (path.string ().c_str ());
if (!ifs.is_open ())
{
- wcerr << argv[1] << ": error: unable to open in read mode" << endl;
+ cerr << path << ": error: unable to open in read mode" << endl;
return 1;
}
ifs.exceptions (ifstream::failbit | ifstream::badbit);
parser p;
- p.parse (ifs, argv[1]);
+ auto_ptr<semantics::cli_unit> unit (p.parse (ifs, path));
+
+ generator g;
+ g.generate (*unit, path);
+ }
+ catch (semantics::invalid_path const&)
+ {
+ cerr << "error: '" << argv[1] << "' is not a valid filesystem path"
+ << endl;
+ return 1;
}
catch (std::ios_base::failure const&)
{
- wcerr << argv[1] << ": error: read failure" << endl;
+ cerr << argv[1] << ": error: read failure" << endl;
return 1;
}
catch (parser::invalid_input const&)