/*************************************************************************** PFunctionHandler.cpp Author: Andreas Suter e-mail: andreas.suter@psi.ch $Id$ ***************************************************************************/ /*************************************************************************** * Copyright (C) 2007 by Andreas Suter * * andreas.suter@psi.c * * * * 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 #include #include #include #include #include "PFunctionHandler.h" //------------------------------------------------------------- // Constructor //------------------------------------------------------------- /** *

* * \param fln */ PFunctionHandler::PFunctionHandler(char *fln, bool debug) : fDebug(debug) { fValid = true; fFileName = QString(fln); cout << endl << "in PFunctionHandler(char *fln)"; cout << endl << "fFileName = " << fFileName.latin1(); fValid = ReadFile(); if (fValid) fValid = MapsAreValid(); } //------------------------------------------------------------- // Constructor //------------------------------------------------------------- /** *

* * \param lines */ PFunctionHandler::PFunctionHandler(vector lines) { fValid = true; fFileName = ""; cout << endl << "in PFunctionHandler(vector lines)"; if (lines.size() == 0) { fValid = false; return; } // analyze input bool done = false; int status; int val[10]; double dval[10]; bool inFcnBlock = false; for (unsigned int i=0; i * */ PFunctionHandler::~PFunctionHandler() { cout << endl << "in ~PFunctionHandler()" << endl << endl; fParam.clear(); fMap.clear(); fLines.clear(); fFuncs.clear(); } //------------------------------------------------------------- // DoParse (public) //------------------------------------------------------------- /** *

* */ bool PFunctionHandler::DoParse() { cout << endl << "in PFunctionHandler::DoParse() ..."; bool success = true; PFunctionGrammar function; for (unsigned int i=0; i info = ast_parse(fLines[i].latin1(), function, space_p); if (info.full) { cout << endl << "parse successfull ..." << endl; PFunction func(info, fParam, fMap, fDebug); fFuncs.push_back(func); } else { cout << endl << "parse failed ... (" << i << ")" << endl; success = false; break; } } // check that all functions are valid. It could be that parsing was fine but // the parameter index, or map index was out of range if (success) { for (unsigned int i=0; i * */ bool PFunctionHandler::MapsAreValid() { bool success = true; int maxParam = fParam.size(); for (unsigned int i=0; i maxParam) success = false; if (!success) cout << endl << "invalid MAP found ..."; return success; } //------------------------------------------------------------- // GetFuncIndex (private) //------------------------------------------------------------- /** *

* * \param funcNo */ int PFunctionHandler::GetFuncIndex(int funcNo) { int index = -1; for (unsigned int i=0; i