Skip to content

Commit cb867a2

Browse files
committed
Keywords and co must not be preceded or followed by letters or digits
1 parent a975a9c commit cb867a2

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

examples/keyword-disambiguation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
letters = 'ABC';
2+
returnif = 'neither return nor if';

examples/keyword-disambiguation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
$letters = 'ABC';
2+
$returnif = 'neither return nor if';

src/JsPhpize/Lexer/Lexer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public function next()
107107
'===|!==|>=|<=|<>|!=|==|>|<' => 'operator',
108108
'[\\|\\^&%\\/\\*\\+\\-]=' => 'operator',
109109
'[\\[\\]\\{\\}\\(\\)\\:\\.\\/\\*~\\!\\^\\|&%\\?,;\\+\\-]' => 'operator',
110-
'as|async|await|break|case|catch|class|const|continue|debugger|default|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|of|package|private|protected|public|return|set|static|super|switch|throw|try|var|while|with|yield\*?' => 'keyword',
111-
'null|undefined|Infinity|NaN|true|false|Math\.[A-Z][A-Z0-9_]*|[A-Z][A-Z0-9\\\\_\\x7f-\\xff]*|[\\\\\\x7f-\\xff_][A-Z0-9\\\\_\\x7f-\\xff]*[A-Z][A-Z0-9\\\\_\\x7f-\\xff]*' => 'constant',
112-
'[a-zA-Z\\\\\\x7f-\\xff_][a-zA-Z0-9\\\\_\\x7f-\\xff]*' => 'variable',
110+
'(?<![a-zA-Z0-9\\\\_\\x7f-\\xff])(as|async|await|break|case|catch|class|const|continue|debugger|default|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|of|package|private|protected|public|return|set|static|super|switch|throw|try|var|while|with|yield\*?)(?![a-zA-Z0-9\\\\_\\x7f-\\xff])' => 'keyword',
111+
'(?<![a-zA-Z0-9\\\\_\\x7f-\\xff])(null|undefined|Infinity|NaN|true|false|Math\.[A-Z][A-Z0-9_]*|[A-Z][A-Z0-9\\\\_\\x7f-\\xff]*|[\\\\\\x7f-\\xff_][A-Z0-9\\\\_\\x7f-\\xff]*[A-Z][A-Z0-9\\\\_\\x7f-\\xff]*)(?![a-zA-Z0-9\\\\_\\x7f-\\xff])' => 'constant',
112+
'(?<![a-zA-Z0-9\\\\_\\x7f-\\xff])[a-zA-Z\\\\\\x7f-\\xff_][a-zA-Z0-9\\\\_\\x7f-\\xff]*(?![a-zA-Z0-9\\\\_\\x7f-\\xff])' => 'variable',
113113
'[\\s\\S]' => 'operator',
114114
);
115115

0 commit comments

Comments
 (0)