bool Parser::checkEquLabel() { updateFileInfo(); const Token& start = peekToken(); if (start.type == TokenType::Identifier) { int pos = 1; if (peekToken(pos).type == TokenType::Colon) pos++; if (peekToken(pos).type == TokenType::Equ && peekToken(pos+1).type == TokenType::EquValue) { std::wstring name = peekToken(0).getStringValue(); std::wstring value = peekToken(pos+1).getStringValue(); eatTokens(pos+2); // equs are not allowed in macros if (initializingMacro) { printError(start,L"equ not allowed in macro"); return true; } if (Global.symbolTable.isValidSymbolName(name) == false) { printError(start,L"Invalid equation name %s",name); return true; } if (Global.symbolTable.symbolExists(name,Global.FileInfo.FileNum,Global.Section)) { printError(start,L"Equation name %s already defined",name); return true; } addEquation(start,name,value); return true; } } return false; }
/* Remove an Equation being managed. In this case the equation is * identified by its independent term. * * @param indterm Variable object of the equation independent term * (measurement type). * * \warning All Equations with the same independent term will be * erased. */ EquationSystem& EquationSystem::removeEquation( const Variable& indterm ) { // Create a backup list std::list<Equation> backupList; // Visit each "Equation" in "equationDescriptionList" for( std::list<Equation>::const_iterator itEq = equationDescriptionList.begin(); itEq != equationDescriptionList.end(); ++itEq ) { // If current equation has a different independent term, save it if ( (*itEq).getIndependentTerm() != indterm ) { backupList.push_back(*itEq); } } // Clear the full contents of this object clearEquations(); // Add each "Equation" in the backup equation list for( std::list<Equation>::const_iterator itEq = backupList.begin(); itEq != backupList.end(); ++itEq ) { addEquation(*itEq); } // We must "Prepare()" this EquationSystem again isPrepared = false; return (*this); } // End of method 'EquationSystem::removeEquation()'