-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptions.h
More file actions
95 lines (80 loc) · 2.67 KB
/
Exceptions.h
File metadata and controls
95 lines (80 loc) · 2.67 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* Copyright 2010 by Benjamin J. Land (a.k.a. BenLand100)
*
* This file is part of CPascal.
*
* CPascal is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CPascal is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CPascal. If not, see <http://www.gnu.org/licenses/>.
*/
class InterpEx;
#ifndef _EXCEPTIONS_H
#define _EXCEPTIONS_H
//Runtime Exceptions
#define E_RUNTIME 0
#define E_DIV_ZERO E_RUNTIME + 0
#define E_NOT_INTEGER E_RUNTIME + 1
#define E_NOT_REAL E_RUNTIME + 2
#define E_NOT_CHAR E_RUNTIME + 3
#define E_NOT_STRING E_RUNTIME + 4
#define E_NOT_BOOLEAN E_RUNTIME + 5
#define E_NOT_RECORD E_RUNTIME + 6
#define E_NOT_ARRAY E_RUNTIME + 7
#define E_NOT_POINTER E_RUNTIME + 8
#define E_NULL_VAL E_RUNTIME + 9
#define E_NON_NUMERIC E_RUNTIME + 10
#define E_INDEX_BOUNDS E_RUNTIME + 11
#define E_NO_FIELD E_RUNTIME + 12
#define E_UNRESOLVABLE E_RUNTIME + 13
#define E_STATIC_ARRAY E_RUNTIME + 14
#define E_NOT_METHOD E_RUNTIME + 15
#define E_WRONG_NUM_ARG E_RUNTIME + 16
#define E_REF_TYPE E_RUNTIME + 17
#define E_NO_EQUIV_VAL E_RUNTIME + 18
//Non-catchable exceptions
#define E_NOCATCH 100
#define E_EXIT E_NOCATCH + 0
#define E_BREAK E_NOCATCH + 1
//Parser exceptions
#define E_PARSER 200
#define E_INVALID_CHAR E_PARSER + 0
#define E_EOF E_PARSER + 1
#define E_BAD_PRECOMP E_PARSER + 2
#define E_EXPECTED E_PARSER + 3
#include <exception>
#include <list>
typedef void(*ErrorHandeler_Callback)(int line, int pos, const char* err, bool runtime) __attribute__((stdcall));
class InterpEx : public std::exception {
public:
static int getType(int cause);
InterpEx(int cause);
virtual ~InterpEx() throw ();
void getData(char* ppg, int &line, int &pos, const char* &err);
void addTrace(int pos);
int getType();
int getCause();
std::list<int> getTrace();
virtual const char* what() const throw();
void printStackTrace(char *ppg);
protected:
std::list<int> trace;
int cause;
};
class ParserEx : public InterpEx {
public:
ParserEx(char* error);
virtual ~ParserEx() throw ();
virtual const char* what() const throw();
protected:
const char* error;
};
#endif /* _EXCEPTIONS_H */