private void unravelCalculationStack(Stack<CalculationToken> calculationStack,OperationToken endOperationToken){
  OperationToken operationToken;
  Double doubleTokenNumber;
  Double calculation=readNextNumber(calculationStack);
  while (!calculationStack.isEmpty()) {
    operationToken=(OperationToken)calculationStack.pop();
    if (operationToken.getPriority() == OperationToken.BRACKET_PRIORITY) {
      break;
    }
    if (operationToken.getPriority() == endOperationToken.getPriority()) {
      calculationStack.push(operationToken);
      break;
    }
    doubleTokenNumber=readNextNumber(calculationStack);
    calculation=completeOperation(calculation,doubleTokenNumber,operationToken.getOperation());
  }
  calculationStack.push(new DoubleToken(calculation));
  if (cIsArithmetic(endOperationToken.getOperation())) {
    calculationStack.push(endOperationToken);
  }
}

private void unravelCalculationStack ( Stack < CalculationToken > calculationStack , OperationToken endOperationToken ) { OperationToken operationToken ; Double doubleTokenNumber ; Double calculation = readNextNumber ( calculationStack ) ; while ( ! calculationStack . isEmpty ( ) ) { operationToken = ( OperationToken ) calculationStack . pop ( ) ; if ( operationToken . getPriority ( ) == OperationToken . BRACKET_PRIORITY ) { break ; } if ( operationToken . getPriority ( ) == endOperationToken . getPriority ( ) ) { calculationStack . push ( operationToken ) ; break ; } doubleTokenNumber = readNextNumber ( calculationStack ) ; calculation = completeOperation ( calculation , doubleTokenNumber , operationToken . getOperation ( ) ) ; } calculationStack . push ( new DoubleToken ( calculation ) ) ; if ( cIsArithmetic ( endOperationToken . getOperation ( ) ) ) { calculationStack . push ( endOperationToken ) ; } }
unravel the stack for a block of equal - priority operations and replace the block with the result of the operations ( shorten [ x ] [ + ] [ y ] . . . [ - ] [ z ] to [ x + y . . . - z ] for example )
