Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

itoken_spec.hh

Go to the documentation of this file.
00001 /*
00002  *  File:       itoken_spec.hh
00003  *              $Id: itoken_spec.hh,v 1.7 2002/06/26 20:48:10 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  *
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: itoken_spec.hh,v $
00012  *  Revision 1.7  2002/06/26 20:48:10  alec
00013  *  g++ 3.x happy
00014  *
00015  *  Revision 1.6  2002/06/13 11:38:08  alec
00016  *  added #line stuff
00017  *
00018  *  Revision 1.5  2002/05/27 03:00:43  alec
00019  *  doc update
00020  *
00021  *  Revision 1.4  2002/05/10 07:15:10  alec
00022  *  parser parse tree ok
00023  *
00024  *  Revision 1.3  2002/05/08 10:35:23  alec
00025  *  added keyword tokens support
00026  *
00027  *  Revision 1.2  2002/05/04 18:51:16  alec
00028  *  sync
00029  *
00030  *  Revision 1.1  2002/05/04 17:46:53  alec
00031  *  *** empty log message ***
00032  *
00033  */
00034 
00035 
00036 /* 
00037   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00038 
00039   This program is free software; you can redistribute it and/or modify
00040   it under the terms of the GNU General Public License as published by
00041   the Free Software Foundation; either version 2 of the License, or
00042   (at your option) any later version.
00043 
00044   This program is distributed in the hope that it will be useful,
00045   but WITHOUT ANY WARRANTY; without even the implied warranty of
00046   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00047   GNU General Public License for more details.
00048 
00049   You should have received a copy of the GNU General Public License
00050   along with this program; if not, write to the Free Software
00051   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00052 
00053  */
00054 
00055 #ifndef __ITOKEN_SPEC_HH__
00056 #define __ITOKEN_SPEC_HH__
00057 
00058 #include <string>
00059 #include <vector>
00060 using namespace std;
00061 
00062 
00063 #include "parse_util.hh"
00064 
00065 class ITokenDesc;
00066 class ReNode;
00067 
00074 class ITokenSpec
00075 {
00076 public:
00077 
00078   typedef enum t_Tkinds {regular, skip, more, keyword, special} Tkinds;
00079   
00088   virtual void setClassName (const string &className) = 0;
00089 
00093   virtual void setInheritance (const string &inheritance,
00094                                const Position &pos) = 0;
00095 
00099   virtual void setPreambleCode (const string &preambleCode,
00100                                 const Position &pos) = 0;
00101 
00105   virtual void addCodeBlock (const string &block, const Position &pos) = 0;
00106 
00107   /* @} */
00108 
00127   virtual void addToken (const string &tokName, Tkinds tokKind,
00128                          ReNode *regexp, const string &tokAction,
00129                          const Position &pos) throw (ParseException) = 0;
00130 
00137   virtual void addToken (const string &tokname, const Position &pos)
00138     throw (ParseException) = 0;
00139 
00143   virtual bool isToken (const string &tokName) = 0;
00144 
00149   virtual int getTokenId (const string &tokName) = 0;
00150 
00151 
00158   virtual ITokenDesc& operator [] (int tokid) = 0;
00159 
00160   ITokenDesc& operator [] (const string &tokName)
00161   {
00162     return (*this)[getTokenId(tokName)];
00163   }
00164 
00168   virtual int count () = 0;
00169 
00170   /* @} */
00171 
00175   virtual ~ITokenSpec () {}
00176 
00177 #ifdef DEBUG
00178   
00183   virtual void dump (ostream &os) const = 0;
00184   
00185 #endif
00186 
00187 public:
00188 
00189   string className;
00190 
00191   CodeChunk preambleCode;
00192 
00193   vector<CodeChunk> userCode;
00194 
00195   CodeChunk inheritance;
00196 };
00197 
00198 class ITokenDesc
00199 {
00200 public:
00201   
00202   virtual const string &name() const = 0;
00203 
00204   virtual int id () const = 0;
00205 
00206   virtual ITokenSpec::Tkinds kind() const = 0;
00207   
00208   virtual const Position& pos () const = 0;
00209 
00210   virtual const CodeChunk& tokAction() const = 0;
00211 
00212 #ifdef DEBUG
00213   
00218   virtual void dump (ostream &os) const = 0;
00219   
00220 #endif
00221 };
00222 
00223 
00224 #endif /* #ifndef __ITOKEN_SPEC_HH__ */

Generated at Tue Jul 9 21:05:44 2002 for CppCC by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001