Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 76150ae

Browse files
rvanvelzenondrejmirtes
authored andcommitted
Optimize generated regex
1 parent 5aaeb83 commit 76150ae

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

‎src/Lexer/Lexer.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,12 @@ public function tokenize(string $s): array
121121
private function initialize(): void
122122
{
123123
$patterns = [
124+
self::TOKEN_HORIZONTAL_WS => '[\\x09\\x20]++',
125+
126+
self::TOKEN_IDENTIFIER => '(?:[\\\\]?+[a-z_\\x80-\\xFF][0-9a-z_\\x80-\\xFF-]*+)++',
127+
self::TOKEN_THIS_VARIABLE => '\\$this(?![0-9a-z_\\x80-\\xFF])',
128+
self::TOKEN_VARIABLE => '\\$[a-z_\\x80-\\xFF][0-9a-z_\\x80-\\xFF]*+',
129+
124130
// '&' followed by TOKEN_VARIADIC, TOKEN_VARIABLE, TOKEN_EQUAL, TOKEN_EQUAL or TOKEN_CLOSE_PARENTHESES
125131
self::TOKEN_REFERENCE => '&(?=\\s*+(?:[.,=)]|(?:\\$(?!this(?![0-9a-z_\\x80-\\xFF])))))',
126132
self::TOKEN_UNION => '\\|',
@@ -154,12 +160,6 @@ private function initialize(): void
154160
self::TOKEN_SINGLE_QUOTED_STRING => '\'(?:\\\\[^\\r\\n]|[^\'\\r\\n\\\\])*+\'',
155161
self::TOKEN_DOUBLE_QUOTED_STRING => '"(?:\\\\[^\\r\\n]|[^"\\r\\n\\\\])*+"',
156162

157-
self::TOKEN_IDENTIFIER => '(?:[\\\\]?+[a-z_\\x80-\\xFF][0-9a-z_\\x80-\\xFF-]*+)++',
158-
self::TOKEN_THIS_VARIABLE => '\\$this(?![0-9a-z_\\x80-\\xFF])',
159-
self::TOKEN_VARIABLE => '\\$[a-z_\\x80-\\xFF][0-9a-z_\\x80-\\xFF]*+',
160-
161-
self::TOKEN_HORIZONTAL_WS => '[\\x09\\x20]++',
162-
163163
self::TOKEN_WILDCARD => '\\*',
164164

165165
// anything but TOKEN_CLOSE_PHPDOC or TOKEN_HORIZONTAL_WS or TOKEN_EOL

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /