double RecursiveCalculator::factor() { double value = 0; if (accept(Number) || (accept(Plus) && accept(Number))) { value = getValueFromBuffer(); } else if (accept(Minus) && accept(Number)) { value = -getValueFromBuffer(); } else if (accept(LParenthesis)) { value = expression(); expect(RParenthesis); } else { error("Factor: Syntax error."); symbol = getSymbol(); } return value; }
/** * Verifies answer on the CMGL command * @param buffer pointer to the buffer * @param answerSize size of the answer * @param position position of the SMS in modem storage * @param size of the SMS * @return error number */ int ATCommandManager::verifyCMGL(char* buffer,int answerSize,int& position,int& size) { int commandSize=strlen(ANS_CMGL); bool bResult=compareBuffer(buffer,commandSize,ANS_CMGL); if(bResult==false) { return Undefined_modem_answer; } int firstCommaPosition=0; bool found=false; for(int i=commandSize;i<answerSize;i++) { if(buffer[i]==',') { found =true; firstCommaPosition=i; break; } } if(found==false) { return Undefined_modem_answer; } int valueSize=firstCommaPosition-commandSize; int value=getValueFromBuffer(&buffer[commandSize],valueSize); if(value<0) { return value; } else { position=value; } found=false; int lastCommaPossition=0; for(int i=answerSize-1;i>commandSize;i--) { if(buffer[i]==',') { lastCommaPossition=i; break; } } valueSize=answerSize-lastCommaPossition-1; value=getValueFromBuffer(&buffer[lastCommaPossition+1],valueSize); if(value<0) { return value; } else { size=value; } return 1; }