Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ParserBase.h

Go to the documentation of this file.
00001 #ifndef PARSER_BASE_H
00002 #define PARSER_BASE_H
00003 
00004 /*
00005  * Base class for parsers
00006  * 
00007  * Copyright (C) 2003  Enrico Zini <enrico@debian.org>
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Lesser General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public
00020  * License along with this library; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
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 // vim:set ts=4 sw=4:
00087 #endif

Generated on Tue Oct 26 19:45:57 2004 for libtagcoll by  doxygen 1.3.9.1