summaryrefslogtreecommitdiff
path: root/cli/cli.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-05-11 11:19:04 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-05-11 11:19:04 +0200
commitb42d9a345e2b02a1b17fa61b22117fbf7b187a31 (patch)
tree9c8ea0116ae35cf8df86e958495fc46563d095dd /cli/cli.cxx
parent8062e4e9a4998cfa44002afd2435ff9083e092e8 (diff)
Add support for -I option
Now quote-included ("") option files are searched for relative to the including file while bracket-included (<>) ones are search in the directories specified with -I.
Diffstat (limited to 'cli/cli.cxx')
-rw-r--r--cli/cli.cxx19
1 files changed, 18 insertions, 1 deletions
diff --git a/cli/cli.cxx b/cli/cli.cxx
index b8314e6..c0b1142 100644
--- a/cli/cli.cxx
+++ b/cli/cli.cxx
@@ -3,6 +3,8 @@
// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
+#include <vector>
+#include <string>
#include <memory> // std::auto_ptr
#include <fstream>
#include <iostream>
@@ -65,6 +67,19 @@ main (int argc, char* argv[])
return 1;
}
+ // Extract include search paths.
+ //
+ parser::paths include_paths;
+ for (vector<string>::const_iterator i (ops.include_path ().begin ());
+ i != ops.include_path ().end (); ++i)
+ {
+ // Invalid path exception is handled below.
+ //
+ include_paths.push_back (semantics::path (*i));
+ }
+
+ // Open the input file.
+ //
file = scan.next ();
semantics::path path (file);
@@ -77,7 +92,9 @@ main (int argc, char* argv[])
ifs.exceptions (ifstream::failbit | ifstream::badbit);
- parser p;
+ // Parse and generate.
+ //
+ parser p (include_paths);
auto_ptr<semantics::cli_unit> unit (p.parse (ifs, path));
generator g;