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

scanner_spec.hh

Go to the documentation of this file.
00001 /*
00002  *  File:       scanner_spec.hh
00003  *              $Id: scanner_spec.hh,v 1.8 2002/06/13 11:42:35 alec Exp $
00004  *
00005  *  Author:     Alec Panovici (alecu@email.com)
00006  * 
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: scanner_spec.hh,v $
00012  *  Revision 1.8  2002/06/13 11:42:35  alec
00013  *  added #line stuff
00014  *
00015  *  Revision 1.7  2002/05/22 01:43:12  alec
00016  *  *** empty log message ***
00017  *
00018  *  Revision 1.6  2002/05/08 10:37:11  alec
00019  *  added keyword tokens support
00020  *
00021  *  Revision 1.5  2002/05/07 10:02:18  alec
00022  *  fixed some bugs & mem leaks; added MORE tokens support
00023  *
00024  *  Revision 1.4  2002/05/04 17:39:22  alec
00025  *  the scanner works (slightly tested)
00026  *
00027  *  Revision 1.3  2002/04/30 16:24:38  alec
00028  *  tested the scanner ptree & vBitVector implementation -> ok
00029  *
00030  *  Revision 1.2  2002/04/29 09:34:10  alec
00031  *  scanner ptree building compiles
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 __SCANNER_SPEC_HH__
00056 #define __SCANNER_SPEC_HH__
00057 
00058 #include <map>
00059 #include <set>
00060 
00061 #include "debug.h"
00062 #include "iscanner_spec.hh"
00063 #include "dfa_source_re.hh"
00064 
00065 class DfaReNodeBuilder;
00066 class ITokenSpec;
00067 class PropRegistry;
00068 
00074 class LexicalStateSpec
00075 {
00076 public:
00077   
00078   string name;
00079   DfaSourceRe *regexp;
00080 
00081   LexicalStateSpec (string name_, DfaSourceRe *regexp_ = NULL) :
00082     name(name_),
00083     regexp(regexp_)
00084   {}
00085   
00086 
00087 #ifdef DEBUG
00088 
00092   void dump (ostream &os) const;
00093 #endif
00094   
00095 };
00096 
00097 
00098 class ScannerSpec : public IScannerSpec
00099 {
00100 
00101 public:
00102 
00103   ScannerSpec (ITokenSpec &tokens_, PropRegistry &registry);
00104 
00105   virtual ~ScannerSpec ();
00106   
00107   virtual IReNodeBuilder& getReNodeBuilder ();
00108 
00109   virtual void addRegToken (const vector<string> &states,
00110                             const string &name, ReNode *regexp,
00111                             const string &tokenAction,
00112                             const Position &pos)
00113     throw (ParseException);
00114 
00115   virtual void addSkipToken (const vector<string> &states,
00116                              const string &name, ReNode *regexp,
00117                              const string &tokenAction,
00118                              const Position &pos)
00119     throw (ParseException);
00120 
00121   virtual void addMoreToken (const vector<string> &states,
00122                              const string &name, ReNode *regexp,
00123                              const string &tokenAction,
00124                              const Position &pos)
00125     throw (ParseException);
00126 
00127   virtual void addKeywordToken (const vector<string> &states,
00128                                 const string &name, ReNode *regexp,
00129                                 const string &tokenAction,
00130                                 const Position &pos)
00131     throw (ParseException);
00132 
00133   virtual void addSpecialToken (const string &name, const Position &pos)
00134     throw (ParseException);
00135 
00136   virtual void setPreambleCode (const string &block, const Position &pos);
00137 
00138   virtual void addCodeBlock (const string &block, const Position &pos);
00139 
00140   virtual void setInheritance (const string &inheritance,
00141                                const Position &pos);
00142 
00143   virtual void setClassName (const string &className_);
00144   
00145 #ifdef DEBUG
00146   virtual void dump (ostream &os) const; 
00147 #endif
00148 
00149 private:
00150 
00155   void updateStates (const vector<string> &tokStates, DfaSourceRe *regexp);
00156   
00161   DfaReNodeBuilder &nodeBuilder;
00162 
00163 
00168   DfaSourceRe *starRe;
00169 
00170 
00171 public:
00172 
00173 
00177   string className;
00178 
00179 
00185   vector<LexicalStateSpec> states;
00186 
00187 
00191   CodeChunk preambleCode;
00192 
00197   vector<CodeChunk> userCode;
00198 
00203   CodeChunk inheritance;
00204 
00209   ITokenSpec &tokens;
00210 };
00211 
00212 #endif /* #ifndef __SCANNER_SPEC_HH__ */

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