function _stringtoarray () {
$temp _operator = null;
$temp _value = null;
$this->_input = Str_replace ("", "", $this->_input);
for ($i = 0; $i < strlen ($this->_input); $i + +) {
if ($this->_input[$i] = = ") {
if ($temp _operator! = null) {
Array_push ($this->_input_array, $temp _operator);
$temp _operator = null;
}
if ($temp _value! = null) {
Array_push ($this->_input_array, $temp _value);
$temp _value = null;
}
} elseif (($temp _value = = null) && $temp _operator! = ') ' &&
(!array_key_exists ($temp _operator, $this->_operation) | |
!array_key_exists (2, $this->_operation[$temp _operator]) | |
$this->_operation[$temp _operator][2]>0) && ($this->_input[$i] = = '-')) {
if ($temp _operator! = null) {
Array_push ($this->_input_array, $temp _operator);
$temp _operator = null;
}
Array_push ($this->_input_array, '-1 ');
Array_push ($this->_input_array, ' * ');
} ElseIf ((Is_numeric ($this->_input[$i)) | | ($this->_input[$i] = = '. ')) {
} ElseIf ((Is_numeric ($this->_input[$i)) | | ($this->_input[$i] = = '. ') ||
($this->_input[$i] = = ' F ')) {
if ($temp _operator! = null) {
Array_push ($this->_input_array, $temp _operator);
$temp _operator = null;
}
$temp _value. = $this->_input[$i];
} else {
if ($this->_keyexists ($temp _operator, $this->_operation, 1)) {
Array_push ($this->_input_array, $temp _operator);
$temp _operator = null;
}
if ($temp _value! = null) {
Array_push ($this->_input_array, $temp _value);
$temp _value = null;
}
$temp _operator. = $this->_input[$i];
}
}
if ($temp _operator! = null && $temp _operator! = ") {
Array_push ($this->_input_array, $temp _operator);
} elseif ($temp _value! = null && $temp _value! = ") {
Array_push ($this->_input_array, $temp _value);
}
$this->_testinput ();
Print_r ($this->_expression_value);
Print_r ($this->_input_array);
return $this->_input_array;
}
function _arraytorpn () {
if ($this->_error <> null) {
$this->_output = Array ();
return $this->_output;
}
for ($i = 0; $i < count ($this->_input_array); $i + +) {
$temp = $this->_input_array[$i];
if (Is_numeric ($temp)) {
$this->_outputadd ($temp);
} else if ($this->_keyexists ($temp, $this->_expression_value, 0)) {
$this->_outputadd ($this->_expression_value[$temp]);
} else {
if ($temp = = ') ') {
while (! $this->_stackempty () && ($this->_stackpriority () >= 1)) {
$this->_outputadd ($this->_stackdelete ());
}
if (! $this->_stackempty ()) {
$this->_stackdelete ();
}
} elseif ($temp = = ' (') {
$this->_stackadd ($temp);
} elseif (($this->_stackempty ()) | | (($this->_priority ($temp) >
$this->_stackpriority ()))) {
$this-_stackadd ($temp);
} else {
while (! $this->_stackempty () && ($this->_priority ($temp)
<= $this->_stackpriority ())) {
$this->_outputadd ($this->_stackdelete ());
}
$this->_stackadd ($temp);
}
}
}
while (! $this->_stackempty ()) {
$this->_outputadd ($this->_stackdelete ());
}
return $this->_output;
}
function _rpntovalue () {
$time 1 = $this->_getmicrotime ();
if ($this->_error <> null) {
$this->_value = null;
return $this->_value;
}
$this->_value = 0;
$temp = $this->_output;
do {
$pos = $this->_nextoperator ($temp);
if ($pos = =-1) {
$this->_error = $this->_raiseerror (' Syntax error ');
$this->_value = null;
return $this->_value;
}
$operator = $this->_operation[$temp [$pos]];
$arg = $operator [2];
$function = $operator [3];
if ($arg ==2) && (!isset ($temp [$pos-1]) | |!is_numeric ($temp [$pos-1]) | |
!isset ($temp [$pos-2]) | | !is_numeric ($temp [$pos-2]))) {
$this->_error = $this->_raiseerror (' Syntax error ');
$this->_value = null;
return $this->_value;
} elseif (($arg ==1) && (!isset ($temp [$pos-1]) | |!is_numeric ($temp [$pos-1])) {
$this->_error = $this->_raiseerror (' Syntax error ');
$this->_value = null;
return $this->_value;
}
if (Is_array ($function)) {
if ($arg ==2) $arg _array = Array ($temp [$pos-2], $temp [$pos-1]);
ElseIf ($arg ==1) $arg _array = Array ($temp [$pos-1]);
else $arg _array = Array ();
if ($function [' type '] = = ' Userfunction ') {
$this->_value = Call_user_func_array ($function [' function '], $arg _array);
} else {
$function _array = Array (& $function [' class '], $function [' method ']);
$this->_value = Call_user_func_array ($function _array, $arg _array);
}
} else {
$this->_value = $this $function ($temp, $pos);
}
if ($this->_isnan ($this->_value)) {
$this->_error = $this->_raiseerror (' NAN value ');
$this->_value = null;
return $this->_value;
} elseif ($this->_isinfinite ($this->_value)) {
$this->_error = $this->_raiseerror (' Infinite value ');
$this->_value = null;
return $this->_value;
} elseif (Is_null ($this->_value)) {
return $this->_value;
}
$temp = $this->_refresh ($temp, $pos, $arg, $this->_value);
} while (count ($temp) > 1);
$this->_value = $temp [0];
$time 2 = $this->_getmicrotime ();
$this->_timer = $time 2-$time 1;
return $this->_value;
}