diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2020-04-08 14:51:57 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2020-04-27 11:38:53 +0300 |
commit | 720c5a33b6a49cf328fdd7611f49153cf8f60247 (patch) | |
tree | 9725f3d1f42ec90fde84520f49647edea013ce5e /cli/cli/parser.test.cxx | |
parent | 3183f3bb927a90783ae0aeaf190a0919377aabe4 (diff) |
Separate tests and examples into individual packages
Also make cli module to be explicitly enabled via the config.cli configuration
variable.
Diffstat (limited to 'cli/cli/parser.test.cxx')
-rw-r--r-- | cli/cli/parser.test.cxx | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cli/cli/parser.test.cxx b/cli/cli/parser.test.cxx new file mode 100644 index 0000000..6ef0d11 --- /dev/null +++ b/cli/cli/parser.test.cxx @@ -0,0 +1,45 @@ +// file : cli/parser.test.cxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// license : MIT; see accompanying LICENSE file + +#include <fstream> +#include <iostream> + +#include <cli/parser.hxx> +#include <cli/semantics.hxx> +#include <cli/traversal.hxx> + +using namespace std; + +int +main (int argc, char* argv[]) +{ + if (argc != 2) + { + cerr << "usage: " << argv[0] << " file.cli" << endl; + return 1; + } + + try + { + semantics::path path (argv[1]); + + ifstream ifs; + ifs.exceptions (ifstream::failbit | ifstream::badbit); + ifs.open (path.string ().c_str ()); + + parser::paths include_paths; + parser p (include_paths); + p.parse (ifs, path); + } + catch (semantics::invalid_path const& e) + { + cerr << "error: '" << e.path () << "' is not a valid filesystem path" + << endl; + return 1; + } + catch (parser::invalid_input const&) + { + return 1; + } +} |