Skip to content

Commit

Permalink
Fix forgotten statement on parseNumber to move from state 10 to state…
Browse files Browse the repository at this point in the history
… 4, causing wrong lexing process.
  • Loading branch information
niconoe- committed Sep 3, 2024
1 parent 26e1b5d commit 77a8698
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 28 deletions.
4 changes: 3 additions & 1 deletion src/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,10 @@ public function parseNumber()
break;
} elseif ($state === 10) {
$flags |= Token::FLAG_NUMBER_FLOAT;
if ($this->str[$this->last] < '0' || $this->str[$this->last] > '9') {
if ($this->str[$this->last] >= '0' && $this->str[$this->last] <= '9') {
// Just digits are valid characters.
$state = 4;
} else {
break;
}
}
Expand Down
36 changes: 9 additions & 27 deletions tests/data/lexer/lexNumber.out
Original file line number Diff line number Diff line change
Expand Up @@ -217,21 +217,12 @@
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ".",
"value": ".",
"keyword": null,
"type": 2,
"flags": 16,
"position": 43
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "15",
"value": 15,
"token": ".15",
"value": 0.15,
"keyword": null,
"type": 6,
"flags": 0,
"position": 44
"flags": 2,
"position": 43
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
Expand Down Expand Up @@ -442,21 +433,12 @@
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": ".",
"value": ".",
"keyword": null,
"type": 2,
"flags": 16,
"position": 99
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
"token": "5e10",
"value": 50000000000.0,
"token": ".5e10",
"value": 5000000000.0,
"keyword": null,
"type": 6,
"flags": 4,
"position": 100
"flags": 6,
"position": 99
},
{
"@type": "PhpMyAdmin\\SqlParser\\Token",
Expand Down Expand Up @@ -747,7 +729,7 @@
"position": null
}
],
"count": 82,
"count": 80,
"idx": 0
},
"delimiter": ";",
Expand Down

0 comments on commit 77a8698

Please sign in to comment.