diff --git a/src/Lexer.php b/src/Lexer.php index 5a051a28..782dda66 100644 --- a/src/Lexer.php +++ b/src/Lexer.php @@ -677,7 +677,7 @@ public function parseComment() // - "SELECT */* comment */ FROM ..." // - "SELECT 2*/* comment */3 AS `six`;" $next = $this->last + 1; - if (($next < $this->len) && $this->str[$next] === '*') { + if (($next < $this->len) && $this->str[$next] === '*' && $token === '*/') { // Conflict in "*/*": first "*" was not for ending a comment. // Stop here and let other parsing method define the true behavior of that first star. $this->last = $iBak; diff --git a/tests/data/lexer/lexEmptyCStyleComment.out b/tests/data/lexer/lexEmptyCStyleComment.out index f970fe6a..09a95d1f 100644 --- a/tests/data/lexer/lexEmptyCStyleComment.out +++ b/tests/data/lexer/lexEmptyCStyleComment.out @@ -28,30 +28,12 @@ }, { "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "/", - "value": "/", - "keyword": null, - "type": 2, - "flags": 1, - "position": 7 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "*", - "value": "*", - "keyword": null, - "type": 2, - "flags": 1, - "position": 8 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "*/", - "value": "*/", + "token": "/**/", + "value": "/**/", "keyword": null, "type": 4, "flags": 2, - "position": 9 + "position": 7 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -154,39 +136,12 @@ }, { "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "/", - "value": "/", - "keyword": null, - "type": 2, - "flags": 1, - "position": 36 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "*", - "value": "*", - "keyword": null, - "type": 2, - "flags": 1, - "position": 37 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "*", - "value": "*", - "keyword": null, - "type": 2, - "flags": 1, - "position": 38 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "*/", - "value": "*/", + "token": "/***/", + "value": "/***/", "keyword": null, "type": 4, "flags": 2, - "position": 39 + "position": 36 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -235,48 +190,12 @@ }, { "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "/", - "value": "/", - "keyword": null, - "type": 2, - "flags": 1, - "position": 51 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "*", - "value": "*", - "keyword": null, - "type": 2, - "flags": 1, - "position": 52 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "*", - "value": "*", - "keyword": null, - "type": 2, - "flags": 1, - "position": 53 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": " ", - "value": " ", - "keyword": null, - "type": 3, - "flags": 0, - "position": 54 - }, - { - "@type": "PhpMyAdmin\\SqlParser\\Token", - "token": "*/", - "value": "*/", + "token": "/** */", + "value": "/** */", "keyword": null, "type": 4, "flags": 2, - "position": 55 + "position": 51 }, { "@type": "PhpMyAdmin\\SqlParser\\Token", @@ -369,7 +288,7 @@ "position": null } ], - "count": 40, + "count": 31, "idx": 0 }, "delimiter": ";",