Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Tokenizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ private function makeTokenizeRegexes(): array
)
EOD,
// User-defined variable, possibly with quoted name
Token::TOKEN_TYPE_VARIABLE => '[@:](?:[\w.$]++|(?&t_' . Token::TOKEN_TYPE_BACKTICK_QUOTE . ')|(?&t_' . Token::TOKEN_TYPE_QUOTE . '))',
Token::TOKEN_TYPE_VARIABLE => '(?:@|(?<!\w):)(?:[\w.$]++|(?&t_' . Token::TOKEN_TYPE_BACKTICK_QUOTE . ')|(?&t_' . Token::TOKEN_TYPE_QUOTE . '))',
// decimal, binary, or hex
Token::TOKEN_TYPE_NUMBER => '(?:\d+(?:\.\d+)?|0x[\da-fA-F]+|0b[01]+)(?=$|\s|"\'`|' . $regexBoundaries . ')',
// punctuation and symbols
Expand Down
16 changes: 16 additions & 0 deletions tests/TokenizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1672,6 +1672,22 @@ public static function tokenizeData(): Generator
],
'select json #> null',
];

yield 'label directly followed by LOOP is not a bind variable' => [
[
new Token(Token::TOKEN_TYPE_WORD, 'bar'),
new Token(Token::TOKEN_TYPE_BOUNDARY, ':'),
new Token(Token::TOKEN_TYPE_WORD, 'loop'),
],
'bar:loop',
];

yield 'bind variable' => [
[
new Token(Token::TOKEN_TYPE_VARIABLE, ':param'),
],
':param',
];
}

public function testTokenizeLongConcat(): void
Expand Down
6 changes: 6 additions & 0 deletions tests/clihighlight.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1214,3 +1214,9 @@ MY_NON_TOP_LEVEL_KEYWORD_FX_3();
---
SELECT
text ~* '\w+'
---
CREATE PROCEDURE `foo`() BEGIN
bar : LOOP
-- Nothing
END LOOP bar;
END
2 changes: 2 additions & 0 deletions tests/compress.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,5 @@ SELECT '{}'::json #> '{}'
SELECT vector1 <#> vector2
---
SELECT text ~* '\w+'
---
CREATE PROCEDURE `foo`() BEGIN bar:LOOP END LOOP bar; END
6 changes: 6 additions & 0 deletions tests/format-highlight.html
Original file line number Diff line number Diff line change
Expand Up @@ -1214,3 +1214,9 @@
---
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span>
<span style="color: #333;">text</span> <span >~*</span> <span style="color: blue;">'\w+'</span></pre>
---
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">CREATE</span> <span style="font-weight:bold;">PROCEDURE</span> <span style="color: purple;">`foo`</span>() <span style="font-weight:bold;">BEGIN</span>
<span style="color: #333;">bar</span> <span >:</span> <span style="color: #333;">LOOP</span>
<span style="color: #aaa;">-- Nothing</span>
<span style="font-weight:bold;">END</span> <span style="color: #333;">LOOP</span> <span style="color: #333;">bar</span><span >;</span>
<span style="font-weight:bold;">END</span></pre>
6 changes: 6 additions & 0 deletions tests/format.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1212,3 +1212,9 @@ SELECT
---
SELECT
text ~* '\w+'
---
CREATE PROCEDURE `foo`() BEGIN
bar : LOOP
-- Nothing
END LOOP bar;
END
4 changes: 4 additions & 0 deletions tests/highlight.html
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,7 @@
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #333;">vector1</span> <span >&lt;</span><span >#</span><span >&gt;</span> <span style="color: #333;">vector2</span></pre>
---
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">SELECT</span> <span style="color: #333;">text</span> <span >~*</span> <span style="color: blue;">'\w+'</span></pre>
---
<pre style="color: black; background-color: white;"><span style="font-weight:bold;">CREATE</span> <span style="font-weight:bold;">PROCEDURE</span> <span style="color: purple;">`foo`</span>() <span style="font-weight:bold;">BEGIN</span> <span style="color: #333;">bar</span><span >:</span><span style="color: #333;">LOOP</span>
<span style="color: #aaa;">-- Nothing</span>
<span style="font-weight:bold;">END</span> <span style="color: #333;">LOOP</span> <span style="color: #333;">bar</span><span >;</span> <span style="font-weight:bold;">END</span></pre>
4 changes: 4 additions & 0 deletions tests/sql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -431,3 +431,7 @@ SELECT '{}'::json #> '{}'
SELECT vector1 <#> vector2
---
SELECT text ~* '\w+'
---
CREATE PROCEDURE `foo`() BEGIN bar:LOOP
-- Nothing
END LOOP bar; END