blob: b07091369b9a5de427e6962b461c421a4c30ffc9 (
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
46
|
// file : cli/cli.cxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2009 Code Synthesis Tools CC
// license : MIT; see accompanying LICENSE file
#include <fstream>
#include <iostream>
#include "parser.hxx"
using namespace std;
int main (int argc, char* argv[])
{
if (argc != 2)
{
cerr << "usage: " << argv[0] << " file.cli" << endl;
return 1;
}
try
{
ifstream ifs (argv[1]);
if (!ifs.is_open ())
{
wcerr << argv[1] << ": error: unable to open in read mode" << endl;
return 1;
}
ifs.exceptions (ifstream::failbit | ifstream::badbit);
Parser parser;
parser.parse (ifs, argv[1]);
}
catch (std::ios_base::failure const&)
{
wcerr << argv[1] << ": error: read failure" << endl;
return 1;
}
catch (Parser::InvalidInput const&)
{
// Diagnostics has already been issued by the parser.
//
return 1;
}
}
|