00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef UTAP_POSITION
00023 #define UTAP_POSITION
00024
00025 #include <vector>
00026 #include <string>
00027 #include <stdint.h>
00028 #include <iostream>
00029 #include <climits>
00030
00031 namespace UTAP
00032 {
00033 struct position_t
00034 {
00035 uint32_t start, end;
00036 position_t() : start(0), end(UINT_MAX) {}
00037 position_t(uint32_t start, uint32_t end) : start(start), end(end) {}
00038 };
00039
00058 class Positions
00059 {
00060 public:
00061 struct line_t
00062 {
00063 uint32_t position;
00064 uint32_t offset;
00065 uint32_t line;
00066 std::string path;
00067 line_t(uint32_t position, uint32_t offset, uint32_t line, std::string path)
00068 : position(position), offset(offset), line(line), path(path) {}
00069 };
00070
00071 private:
00072 std::vector<line_t> elements;
00073 const line_t &find(uint32_t, uint32_t, uint32_t) const;
00074 public:
00076 void add(uint32_t position, uint32_t offset, uint32_t line, std::string path);
00077
00083 const line_t &Positions::find(uint32_t position) const;
00084
00086 void dump();
00087 };
00088
00089
00090 struct error_t
00091 {
00092 Positions::line_t start;
00093 Positions::line_t end;
00094 position_t position;
00095 std::string msg;
00096 error_t(Positions::line_t start, Positions::line_t end,
00097 position_t position, std::string msg)
00098 : start(start), end(end), position(position), msg(msg) {}
00099 };
00100 }
00101
00102 std::ostream &operator <<(std::ostream &out, const UTAP::error_t &);
00103
00104 #endif