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 ~XPath() {};
00040 virtual std::string get() const = 0;
00041 };
00042
00043 struct position_t
00044 {
00045 int32_t first_line, first_column, last_line, last_column;
00046 position_t() {}
00047 position_t(int fl, int fc, int ll, int lc)
00048 : first_line(fl), first_column(fc), last_line(ll), last_column(lc)
00049 {}
00050 };
00051
00052 class ErrorHandler
00053 {
00054 public:
00055 struct error_t
00056 {
00057 int32_t fline, fcolumn, lline, lcolumn;
00058
00059 std::string xpath;
00060 std::string msg;
00061
00062 error_t(int32_t fl, int32_t fc, int32_t ll, int32_t lc)
00063 : fline(fl), fcolumn(fc), lline(ll), lcolumn(lc)
00064 {}
00065
00066 error_t(const error_t &err)
00067 : fline(err.fline), fcolumn(err.fcolumn),
00068 lline(err.lline), lcolumn(err.lcolumn),
00069 xpath(err.xpath), msg(err.msg) {}
00070
00071 void setPath(std::string path) { xpath = path; }
00072 void setMessage(std::string value) { msg = value; }
00073 };
00074 private:
00075 std::vector<error_t> errors;
00076 std::vector<error_t> warnings;
00077 const XPath *currentPath;
00078 int first_line, first_column, last_line, last_column;
00079 public:
00080 ErrorHandler();
00081
00082
00083
00084 void setCurrentPath(const XPath *path);
00085
00086
00087
00088 void setCurrentPosition(int first_line, int first_column, int last_line, int last_column);
00089
00090
00091
00092 void setCurrentPosition(const position_t &);
00093
00094
00095 void handleError(const char *, ...);
00096
00097
00098 void handleWarning(const char *, ...);
00099
00100
00101 const std::vector<error_t> &getErrors() const;
00102
00103
00104 const std::vector<error_t> &getWarnings() const;
00105
00106
00107 bool hasErrors() const;
00108
00109
00110 bool hasWarnings() const;
00111
00112
00113 void clear();
00114 };
00115
00116 namespace Constants
00117 {
00118 enum kind_t
00119 {
00120 PLUS = 0,
00121 MINUS = 1,
00122 MULT = 2,
00123 DIV = 3,
00124 MOD = 4,
00125 BIT_AND = 5,
00126 BIT_OR = 6,
00127 BIT_XOR = 7,
00128 BIT_LSHIFT = 8,
00129 BIT_RSHIFT = 9,
00130 AND = 10,
00131 OR = 11,
00132 MIN = 12,
00133 MAX = 13,
00134 RATE = 14,
00135
00136
00137
00138
00139 LT = 20,
00140 LE = 21,
00141 EQ = 22,
00142 NEQ = 23,
00143 GE = 24,
00144 GT = 25,
00145
00146
00147
00148
00149 NOT = 30,
00150 FORALL = 31,
00151
00152
00153
00154
00155 ASSIGN = 40,
00156 ASSPLUS = 41,
00157 ASSMINUS = 42,
00158 ASSDIV = 43,
00159 ASSMOD = 44,
00160 ASSMULT = 45,
00161 ASSAND = 46,
00162 ASSOR = 47,
00163 ASSXOR = 48,
00164 ASSLSHIFT = 49,
00165 ASSRSHIFT = 50,
00166
00167
00168
00169
00170 EF = 60,
00171 EG = 61,
00172 AF = 62,
00173 AG = 63,
00174 LEADSTO = 64,
00175
00176
00177
00178
00179
00180
00181 IDENTIFIER = 512,
00182 CONSTANT = 513,
00183 ARRAY = 514,
00184 POSTINCREMENT = 515,
00185 PREINCREMENT = 516,
00186 POSTDECREMENT = 517,
00187 PREDECREMENT = 518,
00188 UNARY_MINUS = 519,
00189 LIST = 520,
00190 DOT = 521,
00191 INLINEIF = 522,
00192 COMMA = 523,
00193 SYNC = 525,
00194 DEADLOCK = 526,
00195 FUNCALL = 527
00196 };
00197
00198
00199
00200
00201 enum synchronisation_t
00202 {
00203 SYNC_QUE = 0,
00204 SYNC_BANG = 1
00205 };
00206 }
00207
00209 typedef enum
00210 {
00211 S_XTA,
00212 S_DECLARATION, S_LOCAL_DECL, S_INST, S_SYSTEM, S_PARAMETERS,
00213 S_INVARIANT, S_SELECT, S_GUARD, S_SYNC, S_ASSIGN,
00214 S_EXPRESSION, S_PROPERTY
00215 } xta_part_t;
00216
00217 }
00218
00219 std::ostream &operator <<(std::ostream &out, const UTAP::ErrorHandler::error_t &e);
00220
00221 #endif