00001 #ifndef PARSER_BASE_H
00002 #define PARSER_BASE_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #pragma interface
00025
00026 #include <string>
00027 #include <tagcoll/Exception.h>
00028
00029 class ParserInput;
00030
00031 class ParserException: public ContextException
00032 {
00033 protected:
00034 std::string _file;
00035 int _line;
00036
00037 public:
00038 ParserException(const ParserInput& input, const std::string& message) throw ();
00039 ParserException(const std::string& file, int line, const std::string& message) throw ()
00040 : ContextException(message), _file(file), _line(line) {}
00041 ParserException(int line, const std::string& message) throw ()
00042 : ContextException(message), _line(line) {}
00043 ParserException(const std::string& message) throw ()
00044 : ContextException(message), _line(-1) {}
00045 ~ParserException() throw () {}
00046
00047 int line() const throw () { return _line; }
00048 int line(int line) throw () { return _line = line; }
00049
00050 const std::string& file() const throw () { return _file; }
00051 std::string file() throw () { return _file; }
00052 std::string file(const std::string file) throw () { return _file = file; }
00053
00054 virtual const char* type() const throw ()
00055 {
00056 return "ParserException";
00057 }
00058
00059 virtual std::string desc() const throw ();
00060 };
00061
00062 class ParserInputException : public ParserException
00063 {
00064 public:
00065 ParserInputException(const ParserInput& input, const std::string& message) throw ()
00066 : ParserException(input, message) {}
00067
00068 virtual const char* type() const throw ()
00069 {
00070 return "ParserInputException";
00071 }
00072
00073 };
00074
00075 class ParserInput
00076 {
00077 public:
00078 static const int Eof = -1;
00079
00080 virtual const std::string& fileName() const throw () = 0;
00081 virtual int lineNumber() const throw () = 0;
00082 virtual int nextChar() throw (ParserInputException) = 0;
00083 virtual void pushChar(int c) throw (ParserInputException) = 0;
00084 };
00085
00086
00087 #endif