Example #1
0
int parse (char c, struct number_reader* num_rd, struct op_reader* op_rd )
{
    num_rd->ready = op_rd->ready = 0;
    if ( !push_digit(c, num_rd) )
	read_operator(c, op_rd);

    return num_rd->ready || op_rd->ready;
}
Example #2
0
void operate(int*num, int*num2, int*num3) // NO printfs allowed here
{
  int *ptr1, *ptr2;
  
  if((ptr1 = read_address(1)) && check_address(ptr1, num, num2, num3)
    && (ptr2 = read_address(2)) && check_address(ptr2, num, num2, num3))
  {
    int operand = read_operand(); // read operand as int
    char operator = read_operator(); // read operator as char
    run_operation(ptr1, ptr2, operand, operator); // operate
  } // endif
  // done, thank god
} // operate();
Example #3
0
void operate(int *address1, int *address2, int *address3)
{
  int *ptr1, *ptr2, operand;
  char operator;
  ptr1 = read_address(1);
    // if the user inputs 2 addresses and they are both true call for operand and operator
  if (check_address(ptr1, address1, address2, address3) && (ptr2 = read_address(2)) && check_address(ptr2, address1, address2, address3))
  {
    operand = read_operand();
    operator = read_operator();
    run_operation(ptr1, ptr2, operand, operator);
  }
  return;
}//operate()
Example #4
0
void read_token(const char * str, int & p, token & tk)
{
    skip_space(str, p);
    if (str[p] == 0) {
        tk.type = R;
        tk.value.op = '#';
    } else if (isdigit(str[p])) {
        tk.type = D;
        tk.value.num = read_number(str, p);
    } else {
        int ch = read_operator(str, p);
        if (ch == -1) {
            tk.type = U;
        } else {
            tk.type = R;
            tk.value.op = (char)ch;
        }
    }
}
Example #5
0
    void operator() ()
    {
      while(1) {
	disk_stream *inflight = wq->get_work();
	if(inflight == NULL) {
	  break;
	}
	if(inflight->write_op) {
	  write_operator(inflight);
	}
	else {
	  if(inflight->compressed) {
	    read_and_decompress_operator(inflight);
	  }
	  else {
	    read_operator(inflight);
	  }
	}
      }
    }