www.pudn.com > cppcc.rar > cw_ebnf_node_builder.cc
/*
* File: cw_ebnf_node_builder.cc
* $Id: cw_ebnf_node_builder.cc,v 1.5 2003/02/01 19:34:41 alec Exp $
*
* Author: Alec Panoviciu (alecu@email.com)
*
* Comments:
*
* Revision history:
*
* $Log: cw_ebnf_node_builder.cc,v $
* Revision 1.5 2003/02/01 19:34:41 alec
* many small changes.
*
* Revision 1.4 2002/06/23 23:28:36 alec
* profile-based optimization stuff
*
* Revision 1.3 2002/06/13 11:35:53 alec
* added #line stuff
*
* Revision 1.2 2002/05/16 21:33:24 alec
* parser generation done
*
* Revision 1.1 2002/05/10 07:17:33 alec
* *** empty log message ***
*
*/
/*
Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "cw_ebnf_node_builder.h"
#include "iebnf_node_builder.hh"
#include "ebnf_node.hh"
#include "la_spec.hh"
#include "catch_clause.hh"
IEbnfNodeBuilder *cw_ebnfNodeBuilder = NULL;
CLINK void IEbnfNodeBuilder_setLookahead (void *node, void *la)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((node != NULL) && (la != NULL)),
"Bad arguments for call to IEbnfNodeBuilder_setLookahead.");
cw_ebnfNodeBuilder->setLookahead(static_cast(node),
static_cast(la));
}
CLINK void IEbnfNodeBuilder_setCatchClauses (void *node,
CwCatchClauseList cl)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((node != NULL) && (cl != NULL)),
"Bad arguments for call to IEbnfNodeBuilder_setCatchClauses.");
vector v;
for (CwCatchClauseList l = cl; l != NULL; l= l->next)
v.push_back(*static_cast(l->data));
cw_ebnfNodeBuilder->setCatchClauses(static_cast(node),
v);
}
CLINK void IEbnfNodeBuilder_setStartCode (void *node, char *startCode,
int force, int line)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((node != NULL) && (startCode != NULL)),
"Bad arguments for call to IEbnfNodeBuilder_setStartCode.");
cw_ebnfNodeBuilder->setStartCode(static_cast(node),
string(startCode), force,
Position(line));
}
CLINK void IEbnfNodeBuilder_setEndCode (void *node, char *endCode, int force,
int line)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((node != NULL) && (endCode != NULL)),
"Bad arguments for call to IEbnfNodeBuilder_setEndCode.");
cw_ebnfNodeBuilder->setEndCode(static_cast(node),
string(endCode), force, Position(line));
}
CLINK void IEbnfNodeBuilder_setTargetVar (void *node, char *targetVar,
int line)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((node != NULL) && (targetVar != NULL)),
"Bad arguments for call to IEbnfNodeBuilder_setEndCode.");
cw_ebnfNodeBuilder->setTargetVar(static_cast(node),
string(targetVar), Position(line));
}
CLINK void* IEbnfNodeBuilder_createOrNode (void *pre, void *post)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((pre != NULL) && (post != NULL)),
"Bad arguments in call to IEbnfNodeBuilder_createOrNode.");
return cw_ebnfNodeBuilder->createOrNode(static_cast(pre),
static_cast(post),
Position(yylineno));
}
CLINK void* IEbnfNodeBuilder_createCatNode (void *pre, void *post)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((pre != NULL) && (post != NULL)),
"Bad arguments in call to IEbnfNodeBuilder_createCatNode.");
return cw_ebnfNodeBuilder->createCatNode(static_cast(pre),
static_cast(post),
Position(yylineno));
}
CLINK void* IEbnfNodeBuilder_createPlusNode (void *in)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(in != NULL,
"Bad arguments in call to IEbnfNodeBuilder_createPlusNode.");
return cw_ebnfNodeBuilder->createPlusNode(static_cast(in),
Position(yylineno));
}
CLINK void* IEbnfNodeBuilder_createStarNode (void *in)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(in != NULL,
"Bad arguments in call to IEbnfNodeBuilder_createStarNode.");
return cw_ebnfNodeBuilder->createStarNode(static_cast(in),
Position(yylineno));
}
CLINK void* IEbnfNodeBuilder_createOptionalNode (void *in)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(in != NULL,
"Bad arguments in call to IEbnfNodeBuilder_createOptionalNode.");
return cw_ebnfNodeBuilder->createOptionalNode(static_cast(in),
Position(yylineno));
}
CLINK void* IEbnfNodeBuilder_createNonterminalNode (char *targetVar,
int targetVarLine,
char *nontermId,
char *actualArgs,
int actualArgsLine)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((nontermId != NULL) && (actualArgs != NULL)),
"Bad arguments in call to IEbnfNodeBuilder_createNonterminalNode.");
if (targetVar == NULL) targetVar = "";
return cw_ebnfNodeBuilder->createNonterminalNode(string(targetVar),
Position(targetVarLine),
string(nontermId),
string(actualArgs),
Position(actualArgsLine),
Position(yylineno));
}
CLINK void* IEbnfNodeBuilder_createTerminalNode (char *termId)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(termId != NULL,
"Bad arguments in call to IEbnfNodeBuilder_createTerminalNode.");
try {
return cw_ebnfNodeBuilder->createTerminalNode(string(termId),
Position(yylineno));
} catch (ParseException &ex) {
die(formatError(Position(yylineno), ex));
}
}
CLINK void* IEbnfNodeBuilder_createLaSpec (int fixedLa, void *synLa,
char *semLa)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
if (semLa == NULL) semLa = "";
return cw_ebnfNodeBuilder->createLaSpec(fixedLa,
static_cast(synLa),
string(semLa), Position(yylineno));
}
CLINK void* IEbnfNodeBuilder_createCatchClause (char *exceptionDecl,
int edLine,
char *code)
{
ASSERT(cw_ebnfNodeBuilder != NULL,
"IEbnfNodeBuilder C wrapper no initialized !");
ASSERT(((exceptionDecl != NULL) && (code != NULL)),
"Bad arguments in call to IEbnfNodeBuilder_createCatchClause.");
return cw_ebnfNodeBuilder->createCatchClause(string(exceptionDecl),
Position(edLine),
string(code),
Position(yylineno));
}