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

cw_iparser_spec.cc

Go to the documentation of this file.
00001 /*
00002  *  File:       cw_iparser_spec.cc
00003  *              $Id: cw_iparser_spec.cc,v 1.3 2002/06/13 11:36:15 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  * 
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: cw_iparser_spec.cc,v $
00012  *  Revision 1.3  2002/06/13 11:36:15  alec
00013  *  added #line stuff
00014  *
00015  *  Revision 1.2  2002/05/16 22:08:26  alec
00016  *  sync
00017  *
00018  *  Revision 1.1  2002/05/08 18:16:38  alec
00019  *  *** empty log message ***
00020  *
00021  */
00022 
00023 /*
00024   Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
00025 
00026   This program is free software; you can redistribute it and/or modify
00027   it under the terms of the GNU General Public License as published by
00028   the Free Software Foundation; either version 2 of the License, or
00029   (at your option) any later version.
00030 
00031   This program is distributed in the hope that it will be useful,
00032   but WITHOUT ANY WARRANTY; without even the implied warranty of
00033   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00034   GNU General Public License for more details.
00035 
00036   You should have received a copy of the GNU General Public License
00037   along with this program; if not, write to the Free Software
00038   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00039 
00040  */
00041 
00042 #include "debug.h"
00043 #include "cw_iparser_spec.h"
00044 #include "iparser_spec.hh"
00045 
00046 class EbnfNode;
00047 
00048 IParserSpec *cw_parserSpec = NULL;
00049 
00050 CLINK void IParserSpec_addProduction (char *name,
00051                                       char *retTypeName,
00052                                       int retTypeLine,
00053                                       char *formalArgs,
00054                                       int formalArgsLine,
00055                                       char *exceptList,
00056                                       int exceptListLine,
00057                                       char *preambleCode,
00058                                       int preambleCodeLine,
00059                                       void *expansion)
00060 {
00061   ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
00062 
00063   if (retTypeName == NULL) retTypeName = "";
00064   if (formalArgs == NULL) formalArgs = "";
00065   if (exceptList == NULL) exceptList = "";
00066   if (preambleCode == NULL) preambleCode = "";
00067 
00068   try {
00069     cw_parserSpec->addProduction(string(name), string(retTypeName),
00070                                  Position(retTypeLine),
00071                                  string(formalArgs),
00072                                  Position(formalArgsLine),
00073                                  string(exceptList),
00074                                  Position(exceptListLine),
00075                                  string(preambleCode),
00076                                  Position(preambleCodeLine),
00077                                  static_cast<EbnfNode*>(expansion),
00078                                  Position(yylineno));
00079   } catch (ParseException &pex)
00080   {
00081     die(formatError(Position(yylineno), pex));
00082   }
00083 }
00084 
00085 
00086 CLINK void IParserSpec_setPreambleCode (char *block)
00087 {
00088   ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
00089 
00090   cw_parserSpec->setPreambleCode(string(block), Position(yylineno));
00091 }
00092 
00093 
00094 CLINK void IParserSpec_setClassName (char *className)
00095 {
00096   ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
00097 
00098   cw_parserSpec->setClassName(string(className));
00099 }
00100 
00101 
00102 CLINK void IParserSpec_setInheritance (char* inheritance)
00103 {
00104   ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
00105 
00106   cw_parserSpec->setInheritance(string(inheritance), Position(yylineno));
00107 }
00108 
00109 
00110 CLINK void IParserSpec_addCodeBlock (char *block)
00111 {
00112   ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
00113   
00114   cw_parserSpec->addCodeBlock(string(block), Position(yylineno));
00115 }

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