blob: 3e16b221b1d9f1e7d8a7d415a22e732a40ed0403 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// file : unit-tests/parser/driver.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;
}
}
|