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

cw_iscanner_spec.cc

Go to the documentation of this file.
00001 /*
00002  *  File:       cw_iscanner_spec.cc
00003  *              $Id: cw_iscanner_spec.cc,v 1.4 2002/05/08 10:34:39 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  *
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: cw_iscanner_spec.cc,v $
00012  *  Revision 1.4  2002/05/08 10:34:39  alec
00013  *  added keyword tokens support
00014  *
00015  *  Revision 1.3  2002/05/07 10:02:18  alec
00016  *  fixed some bugs & mem leaks; added MORE tokens support
00017  *
00018  *  Revision 1.2  2002/04/29 17:55:41  alec
00019  *  regexps almost done
00020  *
00021  *  Revision 1.1  2002/04/29 09:40:00  alec
00022  *  *** empty log message ***
00023  *
00024  */
00025 
00026 /* 
00027   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00028 
00029   This program is free software; you can redistribute it and/or modify
00030   it under the terms of the GNU General Public License as published by
00031   the Free Software Foundation; either version 2 of the License, or
00032   (at your option) any later version.
00033 
00034   This program is distributed in the hope that it will be useful,
00035   but WITHOUT ANY WARRANTY; without even the implied warranty of
00036   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00037   GNU General Public License for more details.
00038 
00039   You should have received a copy of the GNU General Public License
00040   along with this program; if not, write to the Free Software
00041   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00042 
00043  */
00044 
00045 #include "debug.h"
00046 #include "cw_iscanner_spec.h"
00047 #include "iscanner_spec.hh"
00048 #include "re_node.hh"
00049 
00050 IScannerSpec* cw_scannerSpec = NULL;
00051 
00052 
00053 CLINK void IScannerSpec_addRegToken (CstringList states_,
00054                                      char *name_, void *regexp_,
00055                                      char *tokenAction_)
00056 {
00057   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00058 
00059   if (tokenAction_ == NULL) tokenAction_ = "";
00060   vector<string> *states = CstringList2vector(states_);
00061   
00062   try {
00063     cw_scannerSpec->addRegToken(*states, string(name_),
00064                                 static_cast<ReNode*>(regexp_),
00065                                 string(tokenAction_), Position(yylineno));
00066   } catch (ParseException &ex) {
00067     die(formatError(Position(yylineno), ex));
00068   }
00069   delete states;
00070 }
00071 
00072 
00073 CLINK void IScannerSpec_addSkipToken (CstringList states_,
00074                                       char *name_, void *regexp_,
00075                                       char *tokenAction_)
00076 {
00077   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00078 
00079   if (tokenAction_ == NULL) tokenAction_ = "";
00080   vector<string> *states = CstringList2vector(states_);
00081   
00082   try {
00083     cw_scannerSpec->addSkipToken(*states, string(name_),
00084                                  static_cast<ReNode*>(regexp_),
00085                                  string(tokenAction_), Position(yylineno));
00086   } catch (ParseException &ex) {
00087     die(formatError(Position(yylineno), ex));
00088   }
00089   delete(states);
00090 }
00091 
00092 
00093 CLINK void IScannerSpec_addMoreToken (CstringList states_,
00094                                       char *name_, void *regexp_,
00095                                       char *tokenAction_)
00096 {
00097   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00098 
00099   if (tokenAction_ == NULL) tokenAction_ = "";
00100   vector<string> *states = CstringList2vector(states_);
00101   
00102   try {
00103     cw_scannerSpec->addMoreToken(*states, string(name_),
00104                                  static_cast<ReNode*>(regexp_),
00105                                  string(tokenAction_), Position(yylineno));
00106   } catch (ParseException &ex) {
00107     die(formatError(Position(yylineno), ex));
00108   }
00109   delete(states);
00110 }
00111 
00112 
00113 CLINK void IScannerSpec_addKeywordToken (CstringList states_,
00114                                          char *name_, void *regexp_,
00115                                          char *tokenAction_)
00116 {
00117   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00118 
00119   if (tokenAction_ == NULL) tokenAction_ = "";
00120   vector<string> *states = CstringList2vector(states_);
00121   
00122   try {
00123     cw_scannerSpec->addKeywordToken(*states, string(name_),
00124                                     static_cast<ReNode*>(regexp_),
00125                                     string(tokenAction_), Position(yylineno));
00126   } catch (ParseException &ex) {
00127     die(formatError(Position(yylineno), ex));
00128   }
00129   delete(states);
00130 }
00131 
00132 
00133 CLINK void IScannerSpec_addSpecialToken (char *name_)
00134 {
00135   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00136 
00137   try {
00138     cw_scannerSpec->addSpecialToken(string(name_), Position(yylineno));
00139   } catch (ParseException &ex) {
00140     die(formatError(Position(yylineno), ex));
00141   }
00142 }
00143 
00144 
00145 CLINK void IScannerSpec_setPreambleCode (char *block_)
00146 {
00147   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00148 
00149   cw_scannerSpec->setPreambleCode(string(block_), Position(yylineno));
00150 }
00151 
00152 CLINK void IScannerSpec_addCodeBlock (char *block_)
00153 {
00154   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00155 
00156   cw_scannerSpec->addCodeBlock(string(block_), Position(yylineno));
00157 }
00158 
00159 
00160 CLINK void IScannerSpec_setInheritance (char *inheritance_)
00161 {
00162   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00163 
00164   cw_scannerSpec->setInheritance(string(inheritance_), Position(yylineno));
00165 }
00166 
00167 
00168 CLINK void IScannerSpec_setClassName (char *className_)
00169 {
00170   ASSERT(cw_scannerSpec != NULL, "cw_scannerSpec not initialized !");
00171 
00172   cw_scannerSpec->setClassName(string(className_));
00173 }

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