00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
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 }