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

cw_ebnf_node_builder.cc

Go to the documentation of this file.
00001 /*
00002  *  File:       cw_ebnf_node_builder.cc
00003  *              $Id: cw_ebnf_node_builder.cc,v 1.4 2002/06/23 23:28:36 alec Exp $
00004  *
00005  *  Author:     Alec Panoviciu (alecu@email.com)
00006  *
00007  *  Comments:
00008  *
00009  *  Revision history:
00010  *
00011  *  $Log: cw_ebnf_node_builder.cc,v $
00012  *  Revision 1.4  2002/06/23 23:28:36  alec
00013  *  profile-based optimization stuff
00014  *
00015  *  Revision 1.3  2002/06/13 11:35:53  alec
00016  *  added #line stuff
00017  *
00018  *  Revision 1.2  2002/05/16 21:33:24  alec
00019  *  parser generation done
00020  *
00021  *  Revision 1.1  2002/05/10 07:17:33  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 "cw_ebnf_node_builder.h"
00046 #include "iebnf_node_builder.hh"
00047 #include "ebnf_node.hh"
00048 #include "la_spec.hh"
00049 #include "catch_clause.hh"
00050 
00051 IEbnfNodeBuilder *cw_ebnfNodeBuilder = NULL;
00052 
00053 CLINK void IEbnfNodeBuilder_setLookahead (void *node, void *la)
00054 {
00055   ASSERT(cw_ebnfNodeBuilder != NULL,
00056          "IEbnfNodeBuilder C wrapper no initialized !");
00057   ASSERT(((node != NULL) && (la != NULL)),
00058          "Bad arguments for call to IEbnfNodeBuilder_setLookahead.");
00059   cw_ebnfNodeBuilder->setLookahead(static_cast<EbnfNode*>(node),
00060                                    static_cast<LaSpec*>(la));
00061 }
00062 
00063 
00064 CLINK void IEbnfNodeBuilder_setCatchClauses (void *node,
00065                                              CwCatchClauseList cl)
00066 {
00067   ASSERT(cw_ebnfNodeBuilder != NULL,
00068          "IEbnfNodeBuilder C wrapper no initialized !");
00069   ASSERT(((node != NULL) && (cl != NULL)),
00070          "Bad arguments for call to IEbnfNodeBuilder_setCatchClauses.");
00071   vector<CatchClause> v;
00072   for (CwCatchClauseList l = cl; l != NULL; l= l->next)
00073     v.push_back(*static_cast<CatchClause*>(l->data));
00074   cw_ebnfNodeBuilder->setCatchClauses(static_cast<EbnfNode*>(node),
00075                                       v);
00076 }
00077 
00078 
00079 CLINK void IEbnfNodeBuilder_setStartCode (void *node, char *startCode,
00080                                           int force)
00081 {
00082   ASSERT(cw_ebnfNodeBuilder != NULL,
00083          "IEbnfNodeBuilder C wrapper no initialized !");
00084   ASSERT(((node != NULL) && (startCode != NULL)),
00085          "Bad arguments for call to IEbnfNodeBuilder_setStartCode.");
00086   cw_ebnfNodeBuilder->setStartCode(static_cast<EbnfNode*>(node),
00087                                    string(startCode), force,
00088                                    Position(yylineno));
00089 }
00090 
00091 
00092 CLINK void IEbnfNodeBuilder_setEndCode (void *node, char *endCode, int force)
00093 {
00094   ASSERT(cw_ebnfNodeBuilder != NULL,
00095          "IEbnfNodeBuilder C wrapper no initialized !");
00096   ASSERT(((node != NULL) && (endCode != NULL)),
00097          "Bad arguments for call to IEbnfNodeBuilder_setEndCode.");
00098   cw_ebnfNodeBuilder->setEndCode(static_cast<EbnfNode*>(node),
00099                                  string(endCode), force, Position(yylineno));
00100 }
00101 
00102 
00103 CLINK void* IEbnfNodeBuilder_createOrNode (void *pre, void *post)
00104 {
00105   ASSERT(cw_ebnfNodeBuilder != NULL,
00106          "IEbnfNodeBuilder C wrapper no initialized !");
00107   ASSERT(((pre != NULL) && (post != NULL)),
00108          "Bad arguments in call to IEbnfNodeBuilder_createOrNode.");
00109   return cw_ebnfNodeBuilder->createOrNode(static_cast<EbnfNode*>(pre),
00110                                           static_cast<EbnfNode*>(post),
00111                                           Position(yylineno));
00112 }
00113 
00114 
00115 CLINK void* IEbnfNodeBuilder_createCatNode (void *pre, void *post)
00116 {
00117   ASSERT(cw_ebnfNodeBuilder != NULL,
00118          "IEbnfNodeBuilder C wrapper no initialized !");
00119   ASSERT(((pre != NULL) && (post != NULL)),
00120          "Bad arguments in call to IEbnfNodeBuilder_createCatNode.");
00121   return cw_ebnfNodeBuilder->createCatNode(static_cast<EbnfNode*>(pre),
00122                                           static_cast<EbnfNode*>(post),
00123                                           Position(yylineno));
00124 }
00125 
00126 
00127 CLINK void* IEbnfNodeBuilder_createPlusNode (void *in)
00128 {
00129   ASSERT(cw_ebnfNodeBuilder != NULL,
00130          "IEbnfNodeBuilder C wrapper no initialized !");
00131   ASSERT(in != NULL,
00132          "Bad arguments in call to IEbnfNodeBuilder_createPlusNode.");
00133   return cw_ebnfNodeBuilder->createPlusNode(static_cast<EbnfNode*>(in),
00134                                           Position(yylineno));
00135 }
00136 
00137 
00138 CLINK void* IEbnfNodeBuilder_createStarNode (void *in)
00139 {
00140   ASSERT(cw_ebnfNodeBuilder != NULL,
00141          "IEbnfNodeBuilder C wrapper no initialized !");
00142   ASSERT(in != NULL,
00143          "Bad arguments in call to IEbnfNodeBuilder_createStarNode.");
00144   return cw_ebnfNodeBuilder->createStarNode(static_cast<EbnfNode*>(in),
00145                                           Position(yylineno));
00146 }
00147 
00148 
00149 CLINK void* IEbnfNodeBuilder_createOptionalNode (void *in)
00150 {
00151   ASSERT(cw_ebnfNodeBuilder != NULL,
00152          "IEbnfNodeBuilder C wrapper no initialized !");
00153   ASSERT(in != NULL,
00154          "Bad arguments in call to IEbnfNodeBuilder_createOptionalNode.");
00155   return cw_ebnfNodeBuilder->createOptionalNode(static_cast<EbnfNode*>(in),
00156                                                 Position(yylineno));
00157 }
00158 
00159 
00160 CLINK void* IEbnfNodeBuilder_createNonterminalNode (char *targetVar,
00161                                                     int targetVarLine,
00162                                                     char *nontermId,
00163                                                     char *actualArgs,
00164                                                     int actualArgsLine)
00165 {
00166   ASSERT(cw_ebnfNodeBuilder != NULL,
00167          "IEbnfNodeBuilder C wrapper no initialized !");
00168   ASSERT(((nontermId != NULL) && (actualArgs != NULL)),
00169          "Bad arguments in call to IEbnfNodeBuilder_createNonterminalNode.");
00170   if (targetVar == NULL) targetVar = "";
00171   return cw_ebnfNodeBuilder->createNonterminalNode(string(targetVar),
00172                                                    Position(targetVarLine),
00173                                                    string(nontermId),
00174                                                    string(actualArgs),
00175                                                    Position(actualArgsLine),
00176                                                    Position(yylineno));
00177 }
00178 
00179 
00180 CLINK void* IEbnfNodeBuilder_createTerminalNode (char *termId)
00181 {
00182   ASSERT(cw_ebnfNodeBuilder != NULL,
00183          "IEbnfNodeBuilder C wrapper no initialized !");
00184   ASSERT(termId != NULL,
00185          "Bad arguments in call to IEbnfNodeBuilder_createTerminalNode.");
00186   try {
00187     return cw_ebnfNodeBuilder->createTerminalNode(string(termId),
00188                                                   Position(yylineno));
00189   } catch (ParseException &ex) {
00190     die(formatError(Position(yylineno), ex));
00191   }
00192 }
00193 
00194 
00195 CLINK void* IEbnfNodeBuilder_createLaSpec (int fixedLa, void *synLa,
00196                                            char *semLa)
00197 {
00198   ASSERT(cw_ebnfNodeBuilder != NULL,
00199          "IEbnfNodeBuilder C wrapper no initialized !");
00200   if (semLa == NULL) semLa = "";
00201   return cw_ebnfNodeBuilder->createLaSpec(fixedLa,
00202                                           static_cast<EbnfNode*>(synLa),
00203                                           string(semLa), Position(yylineno));
00204 }
00205 
00206 
00207 CLINK void* IEbnfNodeBuilder_createCatchClause (char *exceptionDecl,
00208                                                 int edLine,
00209                                                 char *code)
00210 {
00211   ASSERT(cw_ebnfNodeBuilder != NULL,
00212          "IEbnfNodeBuilder C wrapper no initialized !");
00213   ASSERT(((exceptionDecl != NULL) && (code != NULL)),
00214          "Bad arguments in call to IEbnfNodeBuilder_createCatchClause.");
00215   return cw_ebnfNodeBuilder->createCatchClause(string(exceptionDecl),
00216                                                Position(edLine),
00217                                                string(code),
00218                                                Position(yylineno));
00219 }

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