www.pudn.com > cppcc.rar > cw_iparser_spec.cc
/*
* File: cw_iparser_spec.cc
* $Id: cw_iparser_spec.cc,v 1.3 2002/06/13 11:36:15 alec Exp $
*
* Author: Alec Panoviciu (alecu@email.com)
*
* Comments:
*
* Revision history:
*
* $Log: cw_iparser_spec.cc,v $
* Revision 1.3 2002/06/13 11:36:15 alec
* added #line stuff
*
* Revision 1.2 2002/05/16 22:08:26 alec
* sync
*
* Revision 1.1 2002/05/08 18:16:38 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 "debug.h"
#include "cw_iparser_spec.h"
#include "iparser_spec.hh"
class EbnfNode;
IParserSpec *cw_parserSpec = NULL;
CLINK void IParserSpec_addProduction (char *name,
char *retTypeName,
int retTypeLine,
char *formalArgs,
int formalArgsLine,
char *exceptList,
int exceptListLine,
char *preambleCode,
int preambleCodeLine,
void *expansion)
{
ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
if (retTypeName == NULL) retTypeName = "";
if (formalArgs == NULL) formalArgs = "";
if (exceptList == NULL) exceptList = "";
if (preambleCode == NULL) preambleCode = "";
try {
cw_parserSpec->addProduction(string(name), string(retTypeName),
Position(retTypeLine),
string(formalArgs),
Position(formalArgsLine),
string(exceptList),
Position(exceptListLine),
string(preambleCode),
Position(preambleCodeLine),
static_cast(expansion),
Position(yylineno));
} catch (ParseException &pex)
{
die(formatError(Position(yylineno), pex));
}
}
CLINK void IParserSpec_setPreambleCode (char *block)
{
ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
cw_parserSpec->setPreambleCode(string(block), Position(yylineno));
}
CLINK void IParserSpec_setClassName (char *className)
{
ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
cw_parserSpec->setClassName(string(className));
}
CLINK void IParserSpec_setInheritance (char* inheritance)
{
ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
cw_parserSpec->setInheritance(string(inheritance), Position(yylineno));
}
CLINK void IParserSpec_addCodeBlock (char *block)
{
ASSERT(cw_parserSpec != NULL, "Parser spec wrapper not initialized.");
cw_parserSpec->addCodeBlock(string(block), Position(yylineno));
}