Skip to content

Commit 3060cf5

Browse files
committed
Fix lexing /** comment start
Signed-off-by: Maximilian Krög <[email protected]>
1 parent 8426c68 commit 3060cf5

File tree

2 files changed

+11
-92
lines changed

2 files changed

+11
-92
lines changed

src/Lexer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ public function parseComment()
677677
// - "SELECT */* comment */ FROM ..."
678678
// - "SELECT 2*/* comment */3 AS `six`;"
679679
$next = $this->last + 1;
680-
if (($next < $this->len) && $this->str[$next] === '*') {
680+
if (($next < $this->len) && $this->str[$next] === '*' && $token === '*/') {
681681
// Conflict in "*/*": first "*" was not for ending a comment.
682682
// Stop here and let other parsing method define the true behavior of that first star.
683683
$this->last = $iBak;

tests/data/lexer/lexEmptyCStyleComment.out

Lines changed: 10 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -28,30 +28,12 @@
2828
},
2929
{
3030
"@type": "PhpMyAdmin\\SqlParser\\Token",
31-
"token": "/",
32-
"value": "/",
33-
"keyword": null,
34-
"type": 2,
35-
"flags": 1,
36-
"position": 7
37-
},
38-
{
39-
"@type": "PhpMyAdmin\\SqlParser\\Token",
40-
"token": "*",
41-
"value": "*",
42-
"keyword": null,
43-
"type": 2,
44-
"flags": 1,
45-
"position": 8
46-
},
47-
{
48-
"@type": "PhpMyAdmin\\SqlParser\\Token",
49-
"token": "*/",
50-
"value": "*/",
31+
"token": "/**/",
32+
"value": "/**/",
5133
"keyword": null,
5234
"type": 4,
5335
"flags": 2,
54-
"position": 9
36+
"position": 7
5537
},
5638
{
5739
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -154,39 +136,12 @@
154136
},
155137
{
156138
"@type": "PhpMyAdmin\\SqlParser\\Token",
157-
"token": "/",
158-
"value": "/",
159-
"keyword": null,
160-
"type": 2,
161-
"flags": 1,
162-
"position": 36
163-
},
164-
{
165-
"@type": "PhpMyAdmin\\SqlParser\\Token",
166-
"token": "*",
167-
"value": "*",
168-
"keyword": null,
169-
"type": 2,
170-
"flags": 1,
171-
"position": 37
172-
},
173-
{
174-
"@type": "PhpMyAdmin\\SqlParser\\Token",
175-
"token": "*",
176-
"value": "*",
177-
"keyword": null,
178-
"type": 2,
179-
"flags": 1,
180-
"position": 38
181-
},
182-
{
183-
"@type": "PhpMyAdmin\\SqlParser\\Token",
184-
"token": "*/",
185-
"value": "*/",
139+
"token": "/***/",
140+
"value": "/***/",
186141
"keyword": null,
187142
"type": 4,
188143
"flags": 2,
189-
"position": 39
144+
"position": 36
190145
},
191146
{
192147
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -235,48 +190,12 @@
235190
},
236191
{
237192
"@type": "PhpMyAdmin\\SqlParser\\Token",
238-
"token": "/",
239-
"value": "/",
240-
"keyword": null,
241-
"type": 2,
242-
"flags": 1,
243-
"position": 51
244-
},
245-
{
246-
"@type": "PhpMyAdmin\\SqlParser\\Token",
247-
"token": "*",
248-
"value": "*",
249-
"keyword": null,
250-
"type": 2,
251-
"flags": 1,
252-
"position": 52
253-
},
254-
{
255-
"@type": "PhpMyAdmin\\SqlParser\\Token",
256-
"token": "*",
257-
"value": "*",
258-
"keyword": null,
259-
"type": 2,
260-
"flags": 1,
261-
"position": 53
262-
},
263-
{
264-
"@type": "PhpMyAdmin\\SqlParser\\Token",
265-
"token": " ",
266-
"value": " ",
267-
"keyword": null,
268-
"type": 3,
269-
"flags": 0,
270-
"position": 54
271-
},
272-
{
273-
"@type": "PhpMyAdmin\\SqlParser\\Token",
274-
"token": "*/",
275-
"value": "*/",
193+
"token": "/** */",
194+
"value": "/** */",
276195
"keyword": null,
277196
"type": 4,
278197
"flags": 2,
279-
"position": 55
198+
"position": 51
280199
},
281200
{
282201
"@type": "PhpMyAdmin\\SqlParser\\Token",
@@ -369,7 +288,7 @@
369288
"position": null
370289
}
371290
],
372-
"count": 40,
291+
"count": 31,
373292
"idx": 0
374293
},
375294
"delimiter": ";",

0 commit comments

Comments
 (0)