Formula * FractionParser::partitionFirstFractionAndOtherSymbols(vector<Formula *>& formulae) { Formula::WidthComparator comp; sort(formulae.rbegin(), formulae.rend(), comp); Formula * fraction = NULL; vector<Formula *> * other = new vector<Formula *>; bool found = false; for (vector<Formula *>::iterator i = formulae.begin(); i != formulae.end(); i++) { Formula * currentFormula = *i; if ((isFracBarSymbol(currentFormula) || isMinusSymbol(currentFormula)) && found == false) { fraction = currentFormula; found = true; } else { other->push_back(currentFormula); } } formulae = *other; delete (other); return fraction; }
bool simpleExpression(char s[], int &position) { if (s[position] == '(') { int current = position + 1; if (sumExpression(s, current)) { position = current; if (s[position] == ')') { position++; return true; } else { return false; } } else return false; } else if (isNumberSymbol(s[position]) || isMinusSymbol(s[position])) { return correctNumber(s,position); } else { return false; } }