Loading src/Calc/Formule.php +49 −15 Original line number Diff line number Diff line Loading @@ -303,13 +303,14 @@ class Formule if ($c >= $i) { $match = true; foreach ($filters as $name => $value) { if ($term[$name] !== $value) { if (!isset($term[$name]) || $term[$name] !== $value) { $match = false; } if ($match) return $c; } } } return null; } Loading @@ -317,9 +318,16 @@ class Formule private function analyseExpr(array &$expr, int $i) { while( ($i = $this->searchExpr($expr, $i, ['type' => 'function'])) !== null ){ $this->buildFunction($expr, $i); $i++; $c = $i; while (($c = $this->searchExpr($expr, $c, ['type' => 'function'])) !== null) { $this->buildFunction($expr, $c); $c++; } $c = $i; while (($c = $this->searchExpr($expr, $c, ['type' => 'sep', 'name' => '('])) !== null) { $this->buildExpr($expr, $c); $c++; } } Loading @@ -341,11 +349,9 @@ class Formule break; } elseif ($t['type'] === 'sep' && $t['name'] === ';' && $t['level'] === $level) { $currentExpr++; } else { $exprs[$currentExpr][] = $t; } // if () } for ($e = 0; $e <= $currentExpr; $e++) { Loading @@ -357,6 +363,34 @@ class Formule private function buildExpr(array &$expr, int $i) { $level = $expr[$i]['level']; $sousExpr = []; $end = count($expr); unset($expr[$i]); // on supprime la parenthèse ouvrante for ($c = $i + 1; $c < $end; $c++) { $t = $expr[$c]; unset($expr[$c]); if ($t['type'] === 'sep' && $t['name'] === ')' && $t['level'] === $level) { // fin de la fonction break; } else { $sousExpr[] = $t; } } $this->analyseExpr($sousExpr, 0); $expr[$i] = [ 'type' => 'expr', 'expr' => $sousExpr, ]; $expr = array_values($expr); } public function displayExprs() { echo '<div style="clear:both">'; Loading Loading
src/Calc/Formule.php +49 −15 Original line number Diff line number Diff line Loading @@ -303,13 +303,14 @@ class Formule if ($c >= $i) { $match = true; foreach ($filters as $name => $value) { if ($term[$name] !== $value) { if (!isset($term[$name]) || $term[$name] !== $value) { $match = false; } if ($match) return $c; } } } return null; } Loading @@ -317,9 +318,16 @@ class Formule private function analyseExpr(array &$expr, int $i) { while( ($i = $this->searchExpr($expr, $i, ['type' => 'function'])) !== null ){ $this->buildFunction($expr, $i); $i++; $c = $i; while (($c = $this->searchExpr($expr, $c, ['type' => 'function'])) !== null) { $this->buildFunction($expr, $c); $c++; } $c = $i; while (($c = $this->searchExpr($expr, $c, ['type' => 'sep', 'name' => '('])) !== null) { $this->buildExpr($expr, $c); $c++; } } Loading @@ -341,11 +349,9 @@ class Formule break; } elseif ($t['type'] === 'sep' && $t['name'] === ';' && $t['level'] === $level) { $currentExpr++; } else { $exprs[$currentExpr][] = $t; } // if () } for ($e = 0; $e <= $currentExpr; $e++) { Loading @@ -357,6 +363,34 @@ class Formule private function buildExpr(array &$expr, int $i) { $level = $expr[$i]['level']; $sousExpr = []; $end = count($expr); unset($expr[$i]); // on supprime la parenthèse ouvrante for ($c = $i + 1; $c < $end; $c++) { $t = $expr[$c]; unset($expr[$c]); if ($t['type'] === 'sep' && $t['name'] === ')' && $t['level'] === $level) { // fin de la fonction break; } else { $sousExpr[] = $t; } } $this->analyseExpr($sousExpr, 0); $expr[$i] = [ 'type' => 'expr', 'expr' => $sousExpr, ]; $expr = array_values($expr); } public function displayExprs() { echo '<div style="clear:both">'; Loading