Exemplo n.º 1
0
int jumpZero(){
	long int matchingBracketPosition = findClosingBracket();
	if(matchingBracketPosition == -1){
		fatalError(UNMATCHED_BRACKET_ERROR_MSG);
		return 1;
	}else{
		if(data[dataIndex] == 0){
			fseek(pSourceCodeFile, matchingBracketPosition, SEEK_SET);
		}
	}
	return 0;
}
Exemplo n.º 2
0
// removes an @{} sequence form colDef
void LatexTables::simplifyColDefs(QStringList &colDefs) {
	for (int i=0; i<colDefs.count(); i++) {
		QString colDef = colDefs.at(i);
		colDef.remove('|');
		if (colDef.startsWith('@')) {
			if (colDef.at(1) == '{') {
				int start=1;
				int cb = findClosingBracket(colDef, start);
				if (cb >= 0 && colDef.at(cb) == '}' && cb+1 < colDef.length()) colDef=colDef.mid(cb+1);
				else colDef="l"; // fall back
			} else {
				colDef="l"; // fall back
			}
		}
		colDefs.replace(i, colDef);
	}
}
Exemplo n.º 3
0
bool InputOutputMaster::convertToPrintable (int cStart, int cEnd, Printable ** ppOutput ) {
    cRead=cStart;
    //for (cRead=cStart;cRead<MAXSIZE;cRead++){
    if (findLastOperator (cStart,cEnd,ppOutput)) return true;
    Expression ** peProduct=new Expression *;
    Expression ** peMultiplyBy=new Expression *;
    bool bFirst=true;
    for (; cRead<cEnd; cRead++) {
        int cAscii=(int) hTest [cRead];
        if (! (cAscii==41) ) {//ignore close brackets
            if (cAscii==40) {
                int cCloseBracket=findClosingBracket(cRead,cEnd);//(
                Printable ** ppBracket=new Printable *;
                if(  ! (convertToPrintable (cRead+1,cCloseBracket,ppBracket) )) return false;//if (hTest[cRead]== '(') deal with brackets
                *peMultiplyBy=static_cast<Expression*> (*ppBracket);
                cRead=cCloseBracket;
            }
            else if (cAscii==91) checkNamedConstant (peMultiplyBy,cEnd);//[
            else if (cAscii>47&&cAscii<58) checkConstant (peMultiplyBy);//0-9
            else if(checkFunction (peMultiplyBy,cEnd)) ;
            else if(cAscii==45) {
                checkMinus (peMultiplyBy,cEnd);   //-
            }
            else if (cAscii==105) {
                checkImaginary (peMultiplyBy);   //i
            }
            else checkVariable(cAscii, peMultiplyBy);
            checkForPostFunctions(peMultiplyBy);
            if (bFirst) {
                *peProduct = *peMultiplyBy;
                bFirst = false;
            } else {
                *peProduct = createOperator(MULTIPLY, *peProduct, *peMultiplyBy);
            }
        }
    }
    *ppOutput = static_cast<Printable*> (*peProduct);
    //delete peProduct;delete peMultiplyBy; //? I get an error with this in, but should it not be there?
    return true;
}
Exemplo n.º 4
0
bool InputOutputMaster::findLastOperator(int cStart, int cEnd, Printable** ppOutput) {
    int cPos, coName, cOrder;
    int bLeading = false;
    int cEndStore = cEnd;
    if (hTest[cStart] == '-' || hTest[cStart] == '+')bLeading = true;
    int last;
    //do{
    last = 0;
    cPos = cStart;
    cOrder = 0; //higher signifies would be done after in BODMAS order
    for (int cIter = cStart; cIter < cEndStore; cIter++) {
        int cAscii = (int) hTest [cIter];
        if (cAscii == 40) cIter = findClosingBracket(cIter, cEnd); //if (hTest[cIter]== '(') ignore brackets
        else if (checkOperator(cAscii, &coName, &cOrder)) cPos = cIter;
    }
    if ((cPos == cStart && !bLeading) || cPos == cEnd - 1) return false;
    cEndStore = cPos;
    //}
    if (cPos!=cStart&&checkOperator(hTest[cPos - 1], &coName, &last)) {
        cPos--;
    };

    Expression * peInput1;
    Expression * peInput2;
    peInput1 = NULL;
    if (cPos != cStart) {
        if (!(convertToPrintable(cStart, cPos, ppOutput)))
            return false;
        peInput1 = static_cast<Expression*> (*ppOutput);
    }
    if (!(convertToPrintable(cPos + 1, cEnd, ppOutput)))
        return false;
    peInput2 = static_cast<Expression*> (*ppOutput);
    *ppOutput = createBiInput(coName, peInput1, peInput2);
    if (*ppOutput == NULL)
        return false;
    return true;
}