Commit db23237f authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Plein de petits bugs...

parent bd7bd3c3
Loading
Loading
Loading
Loading
Loading
+23 −3
Original line number Diff line number Diff line
@@ -46,7 +46,13 @@ class Formule
    public function analyse(): array
    {
        $this->terms = [];
        for ($i = 4; $i < strlen($this->formule); $i++) {

        $start = 0;
        if (str_starts_with($this->formule, 'of:=')){
            $start = 4;
        }

        for ($i = $start; $i < strlen($this->formule); $i++) {
            $this->terms[] = [
                'type' => null,
                'v'    => $this->formule[$i],
@@ -211,6 +217,20 @@ class Formule
            $next = $this->t($i + 1);
            if ($next['type'] === null && $next['v'] === '>') {
                $this->tw(['type' => 'op', 'name' => '<>'], $i, 2);

                return;
            }
            if ($next['type'] === null && $next['v'] === '=') {
                $this->tw(['type' => 'op', 'name' => '<='], $i, 2);

                return;
            }
        }elseif ($t['v'] === '>') {
            $next = $this->t($i + 1);
            if ($next['type'] === null && $next['v'] === '=') {
                $this->tw(['type' => 'op', 'name' => '>='], $i, 2);

                return;
            }
        }

@@ -244,14 +264,14 @@ class Formule

        /* Détection de nombres */
        if ($v === '0') {
            $this->tw(['type' => 'number', 'value' => 0], $i);
            $this->tw(['type' => 'number', 'value' => 0], $i, $length);

            return;
        } else {
            $vt = str_replace([',', ' '], ['.', ''], $v);
            $vf = (float)$vt;
            if ((string)$vf === $vt) {
                $this->tw(['type' => 'number', 'value' => $vf], $i);
                $this->tw(['type' => 'number', 'value' => $vf], $i, $length);

                return;
            }