Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

BaseParser.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2004  Anders Hedstrom
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program 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
00017 GNU General Public License for more details.
00018 
00019 You should have received a copy of the GNU General Public License
00020 along with this program; if not, write to the Free Software
00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 */
00023 #ifndef _BASEPARSER_H
00024 #define _BASEPARSER_H
00025 
00026 
00027 #define C the_str[the_ptr]
00028 #define C1 the_str[the_ptr + 1]
00029 #define C2 the_str[the_ptr + 2]
00030 #define Cx the_str[strlen(the_str) - 1]
00031 
00032 enum {
00033         NUMBER = 256,
00034         WHITESPACE,
00035         IDENTIFIER,
00036         CPP, // #preprocessor directive
00037         COMMENT,
00038         STRING, // "..."
00039         CC, // ::
00040         CHAR, // '.'
00041         LTLT, // <<
00042         GTGT, // >>
00043         DPTR, // **
00044         LTEQ, // <=
00045         NEQ, // !=
00046         GTEQ, // >=
00047         EQ, // ==
00048         OR, // ||
00049         AND, // &&
00050         PP, // ++
00051         MM, // --
00052         POINTER, // ->
00053         Class,
00054         Namespace,
00055         Using,
00056         Template,
00057         Friend,
00058         Typedef,
00059         Virtual,
00060         Public,
00061         Protected,
00062         Private,
00063         Const,
00064         Struct,
00065         Enum
00066 };
00067 
00068 
00069 class BaseParser
00070 {
00071         typedef std::map<std::string,int> stringint_m;
00072 
00073 public:
00074         BaseParser();
00075         virtual ~BaseParser();
00076 
00077         virtual void preprocessor(std::string &val);
00078         virtual void error(const std::string &str);
00079 
00080 protected:
00081         int ReadLine(FILE *fil);
00082         int GetToken(FILE *fil,std::string &val);
00083         int GetWord(const std::string &str);
00084         std::string GetFilename() { return m_filename; }
00085         int GetLine() { return m_line; }
00086         int GetPos() { return m_pos; }
00087         void EndToken(char);
00088         //
00089         int m_level; // { }
00090         int m_plevel; // ( )
00091         int m_glevel; // < >
00092 
00093 private:
00094         stringint_m m_word;
00095         std::string m_filename;
00096         int m_line;
00097         int m_pos;
00098         char the_str[5000];
00099         int the_ptr;
00100 };
00101 
00102 
00103 #endif // _BASEPARSER_H

Generated for My SDL C++ Gui by doxygen 1.3.6