-
Notifications
You must be signed in to change notification settings - Fork 4
/
main.cpp
57 lines (44 loc) · 1.17 KB
/
main.cpp
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
47
48
49
50
51
52
53
54
55
56
57
// This is the main C++ program file of the ITIP CLI frontend.
#include <iostream> // cin/cerr etc ...
#include <string> // getline
#include <vector> // vector
#include <iterator> // back_inserter
#include "citip.hpp"
#include "common.hpp"
using util::quoted;
using util::line_iterator;
int main (int argc, char *argv[])
try
{
using namespace std;
vector<string> expr;
bool use_stdin = argc == 1;
if (string(argv[argc-1]) == "-") {
--argc;
use_stdin = true;
}
copy(argv+1, argv+argc, back_inserter(expr));
if (use_stdin) {
copy(line_iterator(cin), line_iterator(), back_inserter(expr));
}
bool success = check(parse(expr));
if (success) {
cerr << "The information expression is TRUE." << endl;
return 0;
}
cerr << "The information expression is either:\n"
<< " 1. FALSE, or\n"
<< " 2. a non-Shannon type inequality" << endl;
return 1;
}
catch (std::exception& e)
{
std::cerr << "ERROR: " << e.what() << std::endl;
return 2;
}
// force stack unwinding
catch (...)
{
std::cerr << "UNKNOWN ERROR - aborting." << std::endl;
return 3;
}