mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 01:48:18 +00:00
use better regex for string literals
This commit is contained in:
@@ -210,7 +210,7 @@ function parse2(source) {
|
|||||||
*/
|
*/
|
||||||
function tokenize(source) {
|
function tokenize(source) {
|
||||||
const blocks = [];
|
const blocks = [];
|
||||||
const re = /(\/\*[\d\D]*?\*\/)|(\/\/.*)|(\s+)|([a-zA-Z_]\w*)|(".*?")|('\\?.')|(\d\w*)|(::|\.{3}|[(){}\[\];,.@])|([=!~*/%^]=?|[?:]|>>?>?=?|<<?<?=?|[&][&=]?|[|][|=]?|\+[+=]?|-[-=>]?)|(.)|$/g;
|
const re = /(\/\*[\d\D]*?\*\/)|(\/\/.*)|(\s+)|([a-zA-Z_]\w*)|("[^\r\n\\"]*(?:\\.[^\r\n\\"]*)*")|('\\?.')|(\d\w*)|(::|\.{3}|[(){}\[\];,.@])|([=!~*/%^]=?|[?:]|>>?>?=?|<<?<?=?|[&][&=]?|[|][|=]?|\+[+=]?|-[-=>]?)|(.)|$/g;
|
||||||
let lastIndex = 0;
|
let lastIndex = 0;
|
||||||
for (let m; m = re.exec(source);) {
|
for (let m; m = re.exec(source);) {
|
||||||
if (m.index > lastIndex) {
|
if (m.index > lastIndex) {
|
||||||
|
|||||||
Reference in New Issue
Block a user