common.hh
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
#ifndef UTAP_COMMON_HH
00023
#define UTAP_COMMON_HH
00024
00025
#ifdef __MINGW32__
00026
#include <stdint.h>
00027
#else
00028
#include <inttypes.h>
00029
#endif
00030
#include <string>
00031
#include <iostream>
00032
#include <vector>
00033
00034
namespace UTAP
00035 {
00036 class XPath
00037 {
00038
public:
00039
virtual char *
get()
const = 0;
00040 };
00041
00042 struct position_t {
00043 int32_t
first_line,
first_column,
last_line,
last_column;
00044 position_t() {}
00045 position_t(
int fl,
int fc,
int ll,
int lc)
00046 :
first_line(fl),
first_column(fc),
last_line(ll),
last_column(lc)
00047 {}
00048 };
00049
00050 class ErrorHandler
00051 {
00052
public:
00053 struct error_t
00054 {
00055 int32_t
fline,
fcolumn,
lline,
lcolumn;
00056
00057 char*
xpath;
00058 char*
msg;
00059
00060 error_t(int32_t fl, int32_t fc, int32_t ll, int32_t lc)
00061 :
fline(fl),
fcolumn(fc),
lline(ll),
lcolumn(lc),
00062
xpath(NULL),
msg(NULL){}
00063
00064 error_t(
const error_t &err)
00065 :
fline(err.
fline),
fcolumn(err.
fcolumn),
00066
lline(err.
lline),
lcolumn(err.
lcolumn),
00067
xpath(
copy(err.
xpath)),
msg(
copy(err.
msg)) {}
00068
00069 ~error_t() {
delete []
xpath;
delete[]
msg; }
00070
00071 char *
copy(
const char *s) {
00072
return (s ? strcpy(
new char[strlen(s) + 1], s) : NULL);
00073 }
00074
00075 void setPath(
char *path) {
00076
delete[]
xpath;
00077
xpath = path;
00078 };
00079
00080 void setMessage(
const char *value) {
00081
delete[]
msg;
00082
msg = copy(value);
00083 }
00084 };
00085
private:
00086 std::vector<error_t> errors;
00087 std::vector<error_t> warnings;
00088
const XPath *currentPath;
00089
int first_line, first_column, last_line, last_column;
00090
public:
00091
ErrorHandler();
00092
00093
00094
00095
void setCurrentPath(
const XPath *path);
00096
00097
00098
00099
void setCurrentPosition(
int first_line,
int first_column,
int last_line,
int last_column);
00100
00101
00102
00103
void setCurrentPosition(
const position_t &);
00104
00105
00106
void handleError(
const char *, ...);
00107
00108
00109
void handleWarning(
const char *, ...);
00110
00111
00112
const std::vector<error_t> &
getErrors() const;
00113
00114
00115 const std::vector<error_t> &getWarnings() const;
00116
00117
00118
bool hasErrors() const;
00119
00120
00121
bool hasWarnings() const;
00122
00123
00124
void clear();
00125 };
00126
00127 namespace Constants
00128 {
00129 enum kind_t {
00130
PLUS = 0,
00131
MINUS = 1,
00132
MULT = 2,
00133
DIV = 3,
00134
MOD = 4,
00135
BIT_AND = 5,
00136
BIT_OR = 6,
00137
BIT_XOR = 7,
00138
BIT_LSHIFT = 8,
00139
BIT_RSHIFT = 9,
00140
AND = 10,
00141
OR = 11,
00142
MIN = 12,
00143
MAX = 13,
00144
00145
00146
00147
00148
LT = 20,
00149
LE = 21,
00150
EQ = 22,
00151
NEQ = 23,
00152
GE = 24,
00153
GT = 25,
00154
00155
00156
00157
00158
NOT = 30,
00159
00160
00161
00162
00163
ASSIGN = 40,
00164
ASSPLUS = 41,
00165
ASSMINUS = 42,
00166
ASSDIV = 43,
00167
ASSMOD = 44,
00168
ASSMULT = 45,
00169
ASSAND = 46,
00170
ASSOR = 47,
00171
ASSXOR = 48,
00172
ASSLSHIFT = 49,
00173
ASSRSHIFT = 50,
00174
00175
00176
00177
00178
EF = 60,
00179
EG = 61,
00180
AF = 62,
00181
AG = 63,
00182
LEADSTO = 64,
00183
00184
00185
00186
00187
00188
00189
IDENTIFIER = 512,
00190
CONSTANT = 513,
00191
ARRAY = 514,
00192
POSTINCREMENT = 515,
00193
PREINCREMENT = 516,
00194
POSTDECREMENT = 517,
00195
PREDECREMENT = 518,
00196
UNARY_MINUS = 519,
00197
LIST = 520,
00198
DOT = 521,
00199
INLINEIF = 522,
00200
COMMA = 523,
00201
SYNC = 525,
00202
DEADLOCK = 526,
00203
FUNCALL = 527
00204 };
00205
00206
00207
00208
00209 enum synchronisation_t {
00210
SYNC_QUE = 0,
00211
SYNC_BANG = 1
00212 };
00213 }
00214 }
00215
00216 std::ostream &
operator <<(std::ostream &out,
const UTAP::ErrorHandler::error_t &e);
00217
00218
#endif
Generated on Sat May 15 12:33:41 2004 for libutap by
1.3.7