diff options
author | WWDillingham WesleyDillingham <wwdillingham@sugarlabs.org> | 2009-07-01 17:07:38 (GMT) |
---|---|---|
committer | WWDillingham WesleyDillingham <wwdillingham@sugarlabs.org> | 2009-07-01 17:07:38 (GMT) |
commit | c00029c0a7b098ee769af0a2af96d46084e4ee94 (patch) | |
tree | 9d62640befe6f57a1054154a0c589c480a333072 | |
parent | 77b4931c3c7e27a3ca27d8f2dbb56727af0d71a3 (diff) |
Compound equation testing method determined.
-rw-r--r-- | order_of_operations_parser.php | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/order_of_operations_parser.php b/order_of_operations_parser.php index 63e5fa6..ebb0f5f 100644 --- a/order_of_operations_parser.php +++ b/order_of_operations_parser.php @@ -64,11 +64,9 @@ for (i=0;i<=$numRecords;i++) $tok = strtok($lines, " "); while ($tok !== false) - { - - - + { $equation = $tok[2]; + // ` ********************************ADDITION************************* @@ -178,10 +176,27 @@ for (i=0;i<=$numRecords;i++) } - //need to cycle through each operation again to check for compound-operation equations - $regexp="+"; //we will start with addition - - if(preg_match($regexp, $equation) && (preg_match("+", $equation), preg_match("/", $equation), && preg_match("-", $equation))) + //**********************************************COMPOUND EQUATIONS********************************* + + // can simply not use regexp but replace with a literal reg expression + if(preg_match($regexp, $equation) && (preg_match("-", $equation) || preg_match("*", $equation) || preg_match("/", $equation))) + { + + } + elseif( (preg_match($regexp, $equation)) && (preg_match("", $equation) || preg_match("", $equation) || preg_match("", $equation))) + { + + } + elseif(preg_match($regexp, $equation) && (preg_match("-", $equation) || preg_match("*", $equation) || preg_match("/", $equation))) + { + + } + elseif( (preg_match($regexp, $equation)) && (preg_match("", $equation) || preg_match("", $equation) || preg_match("", $equation))) + { + + } + + /* #Determine if it is a compound operation if so increment by one, this requires 4 if's as we have to check if each of them exists in # conjuntion with another. |