-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages.hpp
71 lines (60 loc) · 1.75 KB
/
messages.hpp
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// (c) Jaco van de Pol
// Aarhus University
#ifndef MESSAGES_H
#define MESSAGES_H
#include <string>
#include <exception>
using std::string;
using std::to_string;
using std::exception;
//void assertThrow(bool assrt, exception excpt);
#define assertThrow(assrt, excpt) { if (!(assrt)) { throw excpt; }}
class QBFexception : public exception {
protected:
string input;
int line;
public:
QBFexception(string input, int line) {
this->input = input;
this->line = line;
}
virtual string what() {
return "Error line " + to_string(line) + ": ";
}
};
class VarDefined : public QBFexception {
public:
VarDefined(string input, int line): QBFexception(input, line) {}
string what() {
return QBFexception::what() + "Variable \"" + input + "\" is already defined";
}
};
class InputUndefined : public QBFexception {
public:
InputUndefined(string input, int line) : QBFexception(input, line) {}
string what() {
return QBFexception::what() + "Literal \"" + input + "\" is undefined";
}
};
class ConnectiveError : public QBFexception {
public:
ConnectiveError(string input, int line): QBFexception(input, line) {}
string what() {
return QBFexception::what() + "Expected a connective, but got: \"" + input + "\"";
}
};
class ParseError : public QBFexception {
public:
ParseError(string input, int line): QBFexception(input, line) {}
string what() {
return QBFexception::what() + "Expecting quantifier, connective or output, but got \"" + input + "\"";
}
};
class OutputMissing : public QBFexception {
public:
OutputMissing(int line): QBFexception("", line) {}
string what() {
return QBFexception::what() + "The \"output(...)\" gate is missing";
}
};
#endif