@tbela99/css-parser 1.8.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +66 -0
- package/README.md +129 -31
- package/dist/index-umd-web.js +27382 -24086
- package/dist/index.d.ts +2737 -2200
- package/dist/package.json.js +2 -2
- package/dist/src/data/properties.json.js +1 -1
- package/dist/src/data/validation.json.js +1 -1
- package/dist/src/lib/ast/arena-node.js +548 -0
- package/dist/src/lib/ast/arena.js +3198 -0
- package/dist/src/lib/ast/features/calc.js +85 -76
- package/dist/src/lib/ast/features/if.js +155 -115
- package/dist/src/lib/ast/features/index.js +1 -1
- package/dist/src/lib/ast/features/inlinecssvariables.js +77 -84
- package/dist/src/lib/ast/features/prefix.js +184 -183
- package/dist/src/lib/ast/features/shorthand.js +40 -46
- package/dist/src/lib/ast/features/transform.js +24 -24
- package/dist/src/lib/ast/features/type.js +1 -1
- package/dist/src/lib/ast/fingerprint.js +333 -0
- package/dist/src/lib/ast/math/expression.js +458 -543
- package/dist/src/lib/ast/math/math.js +19 -41
- package/dist/src/lib/ast/minify.js +590 -647
- package/dist/src/lib/ast/transform/compute.js +82 -85
- package/dist/src/lib/ast/transform/matrix.js +21 -38
- package/dist/src/lib/ast/transform/minify.js +82 -193
- package/dist/src/lib/ast/transform/perspective.js +2 -3
- package/dist/src/lib/ast/transform/rotate.js +1 -1
- package/dist/src/lib/ast/transform/scale.js +1 -1
- package/dist/src/lib/ast/transform/skew.js +1 -1
- package/dist/src/lib/ast/transform/translate.js +1 -1
- package/dist/src/lib/ast/transform/utils.js +2 -2
- package/dist/src/lib/ast/types.js +263 -258
- package/dist/src/lib/ast/walk.js +246 -610
- package/dist/src/lib/fs/resolve.js +1 -1
- package/dist/src/lib/parser/declaration/list.js +223 -139
- package/dist/src/lib/parser/declaration/map.js +251 -238
- package/dist/src/lib/parser/declaration/set.js +74 -66
- package/dist/src/lib/parser/linesmap.js +1 -1
- package/dist/src/lib/parser/parse.js +1379 -1662
- package/dist/src/lib/parser/source.js +7 -4
- package/dist/src/lib/parser/tokenize.js +406 -199
- package/dist/src/lib/parser/utils/angle.js +11 -13
- package/dist/src/lib/parser/utils/at-rule-container.js +183 -168
- package/dist/src/lib/parser/utils/at-rule-font-feature-values.js +5 -5
- package/dist/src/lib/parser/utils/at-rule-generic.js +31 -24
- package/dist/src/lib/parser/utils/at-rule-import.js +44 -44
- package/dist/src/lib/parser/utils/at-rule-media.js +216 -205
- package/dist/src/lib/parser/utils/at-rule-support.js +83 -88
- package/dist/src/lib/parser/utils/at-rule-when-else.js +47 -47
- package/dist/src/lib/parser/utils/at-rule.js +5 -5
- package/dist/src/lib/parser/utils/base64.js +2 -2
- package/dist/src/lib/parser/utils/cache.js +1 -1
- package/dist/src/lib/parser/utils/config.js +1 -1
- package/dist/src/lib/parser/utils/declaration.js +233 -234
- package/dist/src/lib/parser/utils/eq.js +50 -3
- package/dist/src/lib/parser/utils/hash.js +2 -35
- package/dist/src/lib/parser/utils/selector.js +309 -387
- package/dist/src/lib/parser/utils/text.js +18 -4
- package/dist/src/lib/parser/utils/token.js +16 -69
- package/dist/src/lib/parser/utils/type.js +37 -24
- package/dist/src/lib/printer/render.js +965 -511
- package/dist/src/lib/printer/sourcemap/lib/codec.js +1 -1
- package/dist/src/lib/printer/sourcemap/sourcemap.js +1 -1
- package/dist/src/lib/syntax/color/a98rgb.js +1 -1
- package/dist/src/lib/syntax/color/alpha.js +36 -37
- package/dist/src/lib/syntax/color/cmyk.js +35 -52
- package/dist/src/lib/syntax/color/color-mix.js +96 -132
- package/dist/src/lib/syntax/color/color.js +222 -231
- package/dist/src/lib/syntax/color/hex.js +45 -55
- package/dist/src/lib/syntax/color/hsl.js +54 -62
- package/dist/src/lib/syntax/color/hwb.js +60 -68
- package/dist/src/lib/syntax/color/lab.js +59 -67
- package/dist/src/lib/syntax/color/lch.js +59 -67
- package/dist/src/lib/syntax/color/oklab.js +60 -68
- package/dist/src/lib/syntax/color/oklch.js +60 -67
- package/dist/src/lib/syntax/color/p3.js +1 -1
- package/dist/src/lib/syntax/color/prophotorgb.js +1 -1
- package/dist/src/lib/syntax/color/rec2020.js +1 -1
- package/dist/src/lib/syntax/color/relative-color.js +94 -144
- package/dist/src/lib/syntax/color/rgb.js +54 -57
- package/dist/src/lib/syntax/color/srgb.js +55 -53
- package/dist/src/lib/syntax/color/utils/color-type.js +13 -10
- package/dist/src/lib/syntax/color/utils/colorspace.js +11 -11
- package/dist/src/lib/syntax/color/utils/components.js +19 -20
- package/dist/src/lib/syntax/color/utils/distance.js +15 -13
- package/dist/src/lib/syntax/color/utils/make-color.js +15 -19
- package/dist/src/lib/syntax/color/utils/matrix.js +2 -2
- package/dist/src/lib/syntax/color/xyz.js +1 -1
- package/dist/src/lib/syntax/color/xyzd50.js +1 -1
- package/dist/src/lib/syntax/constants.js +2 -16
- package/dist/src/lib/syntax/syntax.js +301 -407
- package/dist/src/lib/validation/config.js +1 -1
- package/dist/src/lib/validation/match.js +959 -723
- package/dist/src/lib/validation/parser/parse.js +230 -112
- package/dist/src/lib/validation/parser/typedef.js +1 -1
- package/dist/src/lib/validation/utils/list.js +27 -12
- package/dist/src/node.js +12 -72
- package/dist/src/types.js +1 -1
- package/dist/src/utils/sync.js +9 -6
- package/dist/src/web.js +11 -73
- package/package.json +9 -10
- package/dist/index.cjs +0 -35874
- package/dist/src/lib/ast/clone.js +0 -51
- package/dist/src/lib/ast/expand.js +0 -311
- package/dist/src/lib/ast/find.js +0 -192
- package/dist/src/lib/ast/node.js +0 -59
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
CSS parser, minifier and validator for node and the browser
|
|
3
3
|
|
|
4
4
|
Author(s): Thierry Bela
|
|
5
|
-
Version:
|
|
5
|
+
Version: 2.0.0
|
|
6
6
|
License: MIT
|
|
7
7
|
*/
|
|
8
8
|
import { EnumToken, ColorType } from '../ast/types.js';
|
|
9
|
-
import {
|
|
10
|
-
import { isWhiteSpace, isNewLine, isDigit, isLetter, isIdentStart, isIdentCodepoint, isNonPrintable,
|
|
9
|
+
import { pseudoElements, containerFunc, urlFunc, gridTemplateFunc, imageFunc, timelineFunc, supportFunc, timingFunc, colorsFunc, mathFuncs, transformFunctions, whenElseFunc, wildCardFuncs } from '../syntax/constants.js';
|
|
10
|
+
import { isWhiteSpace, isNewLine, isDigit, isLetter, isIdentStart, isIdentCodepoint, isNonPrintable, flexUnits, dimensionUnits, resolutionUnits, angleUnits, timeUnits, frequencyUnits } from '../syntax/syntax.js';
|
|
11
11
|
import { SourceFile } from './source.js';
|
|
12
12
|
|
|
13
13
|
const SymbolsMapTokens = Object.create(null);
|
|
@@ -38,11 +38,161 @@ function decodeEscapeSequences(value) {
|
|
|
38
38
|
return String.fromCodePoint(codepoint);
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* hash table of ascii strings, looked up by a range of the css source without allocating a string.
|
|
43
|
+
* the keys are lowercase, the lookups ignore the case of ascii letters
|
|
44
|
+
*/
|
|
45
|
+
class RangeTable {
|
|
46
|
+
keys = [];
|
|
47
|
+
values = [];
|
|
48
|
+
slots = new Int32Array(1024).fill(-1);
|
|
49
|
+
/**
|
|
50
|
+
* hash of a range of a string, ascii letters are lowercased. -1 when the range contains a non ascii character
|
|
51
|
+
* @param str
|
|
52
|
+
* @param start
|
|
53
|
+
* @param end
|
|
54
|
+
*/
|
|
55
|
+
static hash(str, start, end) {
|
|
56
|
+
let hash = 0x811c9dc5;
|
|
57
|
+
for (let i = start; i < end; i++) {
|
|
58
|
+
let code = str.charCodeAt(i);
|
|
59
|
+
if (code > 0x7f) {
|
|
60
|
+
return -1;
|
|
61
|
+
}
|
|
62
|
+
if (code >= 65 && code <= 90) {
|
|
63
|
+
code += 32;
|
|
64
|
+
}
|
|
65
|
+
hash = Math.imul(hash ^ code, 0x01000193);
|
|
66
|
+
}
|
|
67
|
+
return hash >>> 0;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* slot of a key. the table is never full: it is sized for the static tables of the tokenizer
|
|
71
|
+
* @param str
|
|
72
|
+
* @param start
|
|
73
|
+
* @param end
|
|
74
|
+
* @param hash
|
|
75
|
+
*/
|
|
76
|
+
find(str, start, end, hash) {
|
|
77
|
+
const mask = this.slots.length - 1;
|
|
78
|
+
const length = end - start;
|
|
79
|
+
let slot = hash & mask;
|
|
80
|
+
for (;;) {
|
|
81
|
+
const index = this.slots[slot];
|
|
82
|
+
if (index == -1) {
|
|
83
|
+
return slot;
|
|
84
|
+
}
|
|
85
|
+
const key = this.keys[index];
|
|
86
|
+
if (key.length == length) {
|
|
87
|
+
let k = 0;
|
|
88
|
+
while (k < length) {
|
|
89
|
+
let code = str.charCodeAt(start + k);
|
|
90
|
+
if (code >= 65 && code <= 90) {
|
|
91
|
+
code += 32;
|
|
92
|
+
}
|
|
93
|
+
if (code != key.charCodeAt(k)) {
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
k++;
|
|
97
|
+
}
|
|
98
|
+
if (k == length) {
|
|
99
|
+
return slot;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
slot = (slot + 1) & mask;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
get(str, start, end) {
|
|
106
|
+
const hash = RangeTable.hash(str, start, end);
|
|
107
|
+
if (hash == -1) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
const index = this.slots[this.find(str, start, end, hash)];
|
|
111
|
+
return index == -1 ? undefined : this.values[index];
|
|
112
|
+
}
|
|
113
|
+
set(key, value) {
|
|
114
|
+
const slot = this.find(key, 0, key.length, RangeTable.hash(key, 0, key.length));
|
|
115
|
+
if (this.slots[slot] == -1) {
|
|
116
|
+
this.slots[slot] = this.keys.length;
|
|
117
|
+
this.keys.push(key);
|
|
118
|
+
this.values.push(value);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.values[this.slots[slot]] = value;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* value of a number: the digits are read from the source without creating a string when the result is exact
|
|
127
|
+
* (at most 15 significant digits, no exponent), parseFloat() otherwise
|
|
128
|
+
* @param stream
|
|
129
|
+
* @param start
|
|
130
|
+
* @param end
|
|
131
|
+
*/
|
|
132
|
+
function parseNumber(stream, start, end) {
|
|
133
|
+
let i = start;
|
|
134
|
+
let code = stream.charCodeAt(i);
|
|
135
|
+
let negative = false;
|
|
136
|
+
if (code == 0x2d || code == 0x2b) {
|
|
137
|
+
negative = code == 0x2d;
|
|
138
|
+
code = stream.charCodeAt(++i);
|
|
139
|
+
}
|
|
140
|
+
let mantissa = 0;
|
|
141
|
+
let count = 0;
|
|
142
|
+
let digits = 0;
|
|
143
|
+
let decimals = -1;
|
|
144
|
+
for (; i < end; code = stream.charCodeAt(++i)) {
|
|
145
|
+
if (code >= 0x30 && code <= 0x39) {
|
|
146
|
+
mantissa = mantissa * 10 + (code - 0x30);
|
|
147
|
+
count++;
|
|
148
|
+
if (mantissa > 0) {
|
|
149
|
+
digits++;
|
|
150
|
+
}
|
|
151
|
+
if (decimals >= 0) {
|
|
152
|
+
decimals++;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else if (code == 0x2e && decimals == -1) {
|
|
156
|
+
decimals = 0;
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// exponent, too many digits or not a number: the (correctly rounded) result of parseFloat()
|
|
163
|
+
if (i != end || count == 0 || digits > 15 || decimals > 22 || decimals == 0) {
|
|
164
|
+
return parseFloat(stream.slice(start, end));
|
|
165
|
+
}
|
|
166
|
+
// mantissa and 10^decimals are exact: the division is correctly rounded like parseFloat()
|
|
167
|
+
const value = decimals > 0 ? mantissa / powersOf10[decimals] : mantissa;
|
|
168
|
+
return negative ? -value : value;
|
|
169
|
+
}
|
|
170
|
+
const powersOf10 = [
|
|
171
|
+
1, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, 1e20,
|
|
172
|
+
1e21, 1e22,
|
|
173
|
+
];
|
|
174
|
+
/**
|
|
175
|
+
* token type of a symbol, unit or function name (the name followed by `(`), ignoring the case
|
|
176
|
+
*/
|
|
177
|
+
const symbolTable = new RangeTable();
|
|
178
|
+
/**
|
|
179
|
+
* units and function names of each token type, by lowercase name: the spelling of the first matching item
|
|
180
|
+
*/
|
|
181
|
+
const itemTable = new RangeTable();
|
|
41
182
|
function assignTokenMap(entries, tokenType, suffix = "", lowercase = false) {
|
|
42
183
|
for (const entry of entries) {
|
|
43
184
|
const key = (lowercase ? entry.toLowerCase() : entry) + suffix;
|
|
44
185
|
SymbolsMapTokens[key] = tokenType;
|
|
45
186
|
SymbolsMapTokensLower[key.toLowerCase()] = tokenType;
|
|
187
|
+
let items = itemTable.get(entry, 0, entry.length);
|
|
188
|
+
if (items == null) {
|
|
189
|
+
items = new Map();
|
|
190
|
+
itemTable.set(entry.toLowerCase(), items);
|
|
191
|
+
}
|
|
192
|
+
// the first item wins, like a search of the array
|
|
193
|
+
if (!items.has(tokenType)) {
|
|
194
|
+
items.set(tokenType, entry);
|
|
195
|
+
}
|
|
46
196
|
}
|
|
47
197
|
}
|
|
48
198
|
SymbolsMapTokens["+"] = EnumToken.Plus;
|
|
@@ -94,7 +244,9 @@ assignTokenMap(mathFuncs, EnumToken.MathFunctionTokenDefType, "(");
|
|
|
94
244
|
assignTokenMap(transformFunctions, EnumToken.TransformFunctionTokenDefType, "(", true);
|
|
95
245
|
assignTokenMap(whenElseFunc, EnumToken.WhenElseFunctionTokenDefType, "(");
|
|
96
246
|
assignTokenMap(wildCardFuncs, EnumToken.WildCardFunctionTokenDefType, "(");
|
|
97
|
-
const
|
|
247
|
+
for (const key of Object.keys(SymbolsMapTokens)) {
|
|
248
|
+
symbolTable.set(key.toLowerCase(), SymbolsMapTokens[key]);
|
|
249
|
+
}
|
|
98
250
|
// do not capture the value
|
|
99
251
|
const hintsEnum = new Set([
|
|
100
252
|
EnumToken.CommaTokenType,
|
|
@@ -140,68 +292,39 @@ var TokenMap;
|
|
|
140
292
|
TokenMap[TokenMap["PERCENTAGE"] = 37] = "PERCENTAGE";
|
|
141
293
|
})(TokenMap || (TokenMap = {}));
|
|
142
294
|
function getSymbolHint(parseInfo, start, end) {
|
|
143
|
-
const
|
|
144
|
-
if (
|
|
295
|
+
const stream = parseInfo.stream;
|
|
296
|
+
if (end > stream.length) {
|
|
297
|
+
end = stream.length;
|
|
298
|
+
}
|
|
299
|
+
if (end - start <= 0) {
|
|
145
300
|
return null;
|
|
146
|
-
const value = parseInfo.stream.slice(start, end);
|
|
147
|
-
// Direct lookup handles the hottest punctuation and keyword cases without
|
|
148
|
-
// scanning the entire symbol table on every token.
|
|
149
|
-
const match = SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()];
|
|
150
|
-
if (match != null) {
|
|
151
|
-
return match;
|
|
152
301
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
ca += 32;
|
|
164
|
-
if (cb >= 65 && cb <= 90)
|
|
165
|
-
cb += 32;
|
|
166
|
-
if (ca !== cb) {
|
|
167
|
-
match = false;
|
|
168
|
-
break;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
if (match) {
|
|
172
|
-
return SymbolsMapTokens[key];
|
|
302
|
+
// ascii names are looked up without allocating a string
|
|
303
|
+
const type = symbolTable.get(stream, start, end);
|
|
304
|
+
if (type !== undefined) {
|
|
305
|
+
return type;
|
|
306
|
+
}
|
|
307
|
+
for (let i = start; i < end; i++) {
|
|
308
|
+
// the unicode case mapping of toLowerCase() may produce ascii letters
|
|
309
|
+
if (stream.charCodeAt(i) > 0x7f) {
|
|
310
|
+
const value = stream.slice(start, end);
|
|
311
|
+
return SymbolsMapTokens[value] ?? SymbolsMapTokensLower[value.toLowerCase()] ?? null;
|
|
173
312
|
}
|
|
174
313
|
}
|
|
175
314
|
return null;
|
|
176
315
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
316
|
+
/**
|
|
317
|
+
* spelling of a unit or a function name of the given token type, ignoring the case
|
|
318
|
+
* @param type
|
|
319
|
+
* @param parseInfo
|
|
320
|
+
* @param start
|
|
321
|
+
* @param end
|
|
322
|
+
*/
|
|
323
|
+
function findItem(type, parseInfo, start, end) {
|
|
324
|
+
if (end - start <= 0) {
|
|
180
325
|
return null;
|
|
181
|
-
let match;
|
|
182
|
-
let item;
|
|
183
|
-
for (let i = 0; i < array.length; i++) {
|
|
184
|
-
item = array[i];
|
|
185
|
-
if (item.length !== len)
|
|
186
|
-
continue;
|
|
187
|
-
match = true;
|
|
188
|
-
for (let j = 0; j < len; j++) {
|
|
189
|
-
let ca = parseInfo.stream.charCodeAt(start + j);
|
|
190
|
-
let cb = item.charCodeAt(j);
|
|
191
|
-
if (ca >= 65 && ca <= 90)
|
|
192
|
-
ca += 32;
|
|
193
|
-
if (cb >= 65 && cb <= 90)
|
|
194
|
-
cb += 32;
|
|
195
|
-
if (ca !== cb) {
|
|
196
|
-
match = false;
|
|
197
|
-
break;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
if (match) {
|
|
201
|
-
return item;
|
|
202
|
-
}
|
|
203
326
|
}
|
|
204
|
-
return null;
|
|
327
|
+
return itemTable.get(parseInfo.stream, start, end)?.get(type) ?? null;
|
|
205
328
|
}
|
|
206
329
|
/**
|
|
207
330
|
* tokenizer class
|
|
@@ -213,6 +336,11 @@ class Tokenizer {
|
|
|
213
336
|
* token type
|
|
214
337
|
*/
|
|
215
338
|
typ = null;
|
|
339
|
+
/**
|
|
340
|
+
* the identifier read by the last call of consumeIdentToken() has non ascii characters: they may be new lines
|
|
341
|
+
* (U+2028, U+2029)
|
|
342
|
+
*/
|
|
343
|
+
identNonAscii = false;
|
|
216
344
|
/**
|
|
217
345
|
* token kind
|
|
218
346
|
*/
|
|
@@ -262,6 +390,19 @@ class Tokenizer {
|
|
|
262
390
|
*/
|
|
263
391
|
hint = null;
|
|
264
392
|
state = null;
|
|
393
|
+
/**
|
|
394
|
+
* id of the source file being tokenized
|
|
395
|
+
*/
|
|
396
|
+
get sourceId() {
|
|
397
|
+
return this.parseInfo.source.id;
|
|
398
|
+
}
|
|
399
|
+
/**
|
|
400
|
+
* length of the css input. 0 when the input is a stream
|
|
401
|
+
*/
|
|
402
|
+
get streamLength() {
|
|
403
|
+
const stream = this.parseInfo.stream;
|
|
404
|
+
return typeof stream == "string" ? stream.length : 0;
|
|
405
|
+
}
|
|
265
406
|
constructor(parseInfo, input = null) {
|
|
266
407
|
this.parseInfo = parseInfo;
|
|
267
408
|
this.input = input;
|
|
@@ -283,7 +424,7 @@ class Tokenizer {
|
|
|
283
424
|
* @returns
|
|
284
425
|
*/
|
|
285
426
|
consumeString(parseInfo) {
|
|
286
|
-
const quote = this.
|
|
427
|
+
const quote = this.advanceCode(parseInfo);
|
|
287
428
|
let charCode;
|
|
288
429
|
let decodeSegments = false;
|
|
289
430
|
while ((charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset)) == charCode) {
|
|
@@ -325,7 +466,7 @@ class Tokenizer {
|
|
|
325
466
|
if (escapeSequence.trimEnd().length > 0) {
|
|
326
467
|
const length = escapeSequence.length +
|
|
327
468
|
1 +
|
|
328
|
-
(isWhiteSpace(parseInfo.stream.
|
|
469
|
+
(isWhiteSpace(parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset))
|
|
329
470
|
? 1
|
|
330
471
|
: 0);
|
|
331
472
|
decodeSegments = true;
|
|
@@ -336,18 +477,18 @@ class Tokenizer {
|
|
|
336
477
|
continue;
|
|
337
478
|
}
|
|
338
479
|
if (charCode == quote) {
|
|
339
|
-
this.
|
|
480
|
+
this.advanceCode(parseInfo);
|
|
340
481
|
return this.makeToken(parseInfo,
|
|
341
|
-
/* hasNewLine ? EnumToken.BadStringTokenType : */ EnumToken.StringTokenType,
|
|
482
|
+
/* hasNewLine ? EnumToken.BadStringTokenType : */ EnumToken.StringTokenType, null, decodeSegments);
|
|
342
483
|
}
|
|
343
484
|
if (isNewLine(charCode)) {
|
|
344
|
-
this.
|
|
485
|
+
this.advanceCode(parseInfo);
|
|
345
486
|
return this.makeToken(parseInfo, EnumToken.BadStringTokenType);
|
|
346
487
|
}
|
|
347
|
-
this.
|
|
488
|
+
this.advanceCode(parseInfo);
|
|
348
489
|
}
|
|
349
490
|
// EOF - 'Unclosed-string' fixed
|
|
350
|
-
return this.makeToken(parseInfo, EnumToken.StringTokenType,
|
|
491
|
+
return this.makeToken(parseInfo, EnumToken.StringTokenType, null, decodeSegments);
|
|
351
492
|
// return result;
|
|
352
493
|
}
|
|
353
494
|
/**
|
|
@@ -356,7 +497,7 @@ class Tokenizer {
|
|
|
356
497
|
* @returns
|
|
357
498
|
*/
|
|
358
499
|
consumeStringAsURLToken(parseInfo) {
|
|
359
|
-
const quote = this.
|
|
500
|
+
const quote = this.advanceCode(parseInfo);
|
|
360
501
|
let charCode;
|
|
361
502
|
let decodeSegments = false;
|
|
362
503
|
while ((charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset)) == charCode) {
|
|
@@ -386,7 +527,7 @@ class Tokenizer {
|
|
|
386
527
|
if (escapeSequence.trimEnd().length > 0) {
|
|
387
528
|
const length = escapeSequence.length +
|
|
388
529
|
1 +
|
|
389
|
-
(isWhiteSpace(parseInfo.stream.
|
|
530
|
+
(isWhiteSpace(parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset))
|
|
390
531
|
? 1
|
|
391
532
|
: 0);
|
|
392
533
|
decodeSegments = true;
|
|
@@ -397,7 +538,7 @@ class Tokenizer {
|
|
|
397
538
|
continue;
|
|
398
539
|
}
|
|
399
540
|
if (charCode == quote) {
|
|
400
|
-
this.
|
|
541
|
+
this.advanceCode(parseInfo);
|
|
401
542
|
let k = 1;
|
|
402
543
|
let end = parseInfo.stream.length - parseInfo.offset;
|
|
403
544
|
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
@@ -421,12 +562,12 @@ class Tokenizer {
|
|
|
421
562
|
}
|
|
422
563
|
// consume until the ')'
|
|
423
564
|
return this.makeToken(parseInfo,
|
|
424
|
-
/* hasNewLine ? EnumToken.BadStringTokenType : */ EnumToken.StringTokenType,
|
|
565
|
+
/* hasNewLine ? EnumToken.BadStringTokenType : */ EnumToken.StringTokenType, null, decodeSegments);
|
|
425
566
|
// return result;
|
|
426
567
|
}
|
|
427
568
|
if (isNewLine(charCode)) {
|
|
428
569
|
// bad string
|
|
429
|
-
this.
|
|
570
|
+
this.advanceCode(parseInfo);
|
|
430
571
|
while ((charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset)) == charCode) {
|
|
431
572
|
if (charCode == 92 /* TokenMap.REVERSE_SOLIDUS */) {
|
|
432
573
|
this.advance(parseInfo, 2);
|
|
@@ -435,11 +576,11 @@ class Tokenizer {
|
|
|
435
576
|
if (charCode == 41 /* TokenMap.RIGHT_PARENTHESIS */) {
|
|
436
577
|
return this.makeToken(parseInfo, EnumToken.BadUrlTokenType);
|
|
437
578
|
}
|
|
438
|
-
this.
|
|
579
|
+
this.advanceCode(parseInfo);
|
|
439
580
|
}
|
|
440
581
|
return this.makeToken(parseInfo, EnumToken.BadStringTokenType);
|
|
441
582
|
}
|
|
442
|
-
this.
|
|
583
|
+
this.advanceCode(parseInfo);
|
|
443
584
|
}
|
|
444
585
|
// EOF - bad url token
|
|
445
586
|
return this.makeToken(parseInfo, EnumToken.BadUrlTokenType);
|
|
@@ -709,6 +850,7 @@ class Tokenizer {
|
|
|
709
850
|
consumeIdentToken(parseInfo) {
|
|
710
851
|
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
711
852
|
let offset = position;
|
|
853
|
+
this.identNonAscii = false;
|
|
712
854
|
let codepoint = parseInfo.stream.charCodeAt(position);
|
|
713
855
|
if (!isIdentStart(codepoint) && codepoint != 45 /* TokenMap.MINUS */) {
|
|
714
856
|
return 0;
|
|
@@ -739,6 +881,9 @@ class Tokenizer {
|
|
|
739
881
|
continue;
|
|
740
882
|
}
|
|
741
883
|
if (codepoint == 0x2d || isIdentCodepoint(codepoint)) {
|
|
884
|
+
if (codepoint > 0x7f) {
|
|
885
|
+
this.identNonAscii = true;
|
|
886
|
+
}
|
|
742
887
|
position++;
|
|
743
888
|
}
|
|
744
889
|
else {
|
|
@@ -817,16 +962,19 @@ class Tokenizer {
|
|
|
817
962
|
consumeURLToken(parseInfo, endPosition) {
|
|
818
963
|
let charCode;
|
|
819
964
|
// consume an <url>
|
|
820
|
-
|
|
821
|
-
|
|
965
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
966
|
+
while (isWhiteSpace(parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset))) {
|
|
967
|
+
this.advanceCode(parseInfo);
|
|
822
968
|
}
|
|
823
|
-
|
|
969
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
970
|
+
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
824
971
|
if (charCode == 34 /* TokenMap.DOUBLE_QUOTE */ || charCode == 39 /* TokenMap.SINGLE_QUOTE */) {
|
|
825
972
|
return this.consumeStringAsURLToken(parseInfo);
|
|
826
973
|
}
|
|
827
974
|
do {
|
|
828
|
-
this.
|
|
829
|
-
|
|
975
|
+
this.advanceCode(parseInfo);
|
|
976
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
977
|
+
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
830
978
|
} while (
|
|
831
979
|
// !(value === "/" && this.match(parseInfo, "/*") &&
|
|
832
980
|
charCode !== 41 /* TokenMap.RIGHT_PARENTHESIS */ &&
|
|
@@ -849,7 +997,8 @@ class Tokenizer {
|
|
|
849
997
|
}
|
|
850
998
|
return this.makeToken(parseInfo,
|
|
851
999
|
// parseInfo.position < parseInfo.currentPosition
|
|
852
|
-
|
|
1000
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
1001
|
+
(charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset)) != charCode || !this.isURLToken(parseInfo)
|
|
853
1002
|
? EnumToken.BadUrlTokenType
|
|
854
1003
|
: EnumToken.UrlTokenTokenType);
|
|
855
1004
|
}
|
|
@@ -860,7 +1009,7 @@ class Tokenizer {
|
|
|
860
1009
|
* @param options
|
|
861
1010
|
* @returns
|
|
862
1011
|
*/
|
|
863
|
-
makeToken(parseInfo, hint,
|
|
1012
|
+
makeToken(parseInfo, hint, slice, decodeSegments) {
|
|
864
1013
|
let val = null;
|
|
865
1014
|
this.typ = null;
|
|
866
1015
|
this.nam = null;
|
|
@@ -870,99 +1019,102 @@ class Tokenizer {
|
|
|
870
1019
|
this.decodeString = null;
|
|
871
1020
|
this.slice = null;
|
|
872
1021
|
this.hint = null;
|
|
873
|
-
if (
|
|
874
|
-
this.slice =
|
|
1022
|
+
if (slice) {
|
|
1023
|
+
this.slice = slice;
|
|
875
1024
|
}
|
|
876
|
-
if (
|
|
1025
|
+
if (decodeSegments) {
|
|
877
1026
|
this.decodeString = true;
|
|
878
1027
|
}
|
|
879
1028
|
if (hint != null) {
|
|
880
|
-
|
|
1029
|
+
// the spelling of units and function names is looked up in the tables
|
|
1030
|
+
let isList = false;
|
|
881
1031
|
let hasUnit = false;
|
|
882
1032
|
switch (hint) {
|
|
883
1033
|
case EnumToken.TransformFunctionTokenDefType:
|
|
884
|
-
|
|
1034
|
+
isList = true;
|
|
885
1035
|
break;
|
|
886
1036
|
case EnumToken.ColorFunctionTokenDefType:
|
|
887
|
-
|
|
1037
|
+
isList = true;
|
|
888
1038
|
break;
|
|
889
1039
|
case EnumToken.ContainerFunctionTokenDefType:
|
|
890
|
-
|
|
1040
|
+
isList = true;
|
|
891
1041
|
break;
|
|
892
1042
|
case EnumToken.UrlFunctionTokenDefType:
|
|
893
|
-
|
|
1043
|
+
isList = true;
|
|
894
1044
|
break;
|
|
895
1045
|
case EnumToken.GridTemplateFuncTokenDefType:
|
|
896
|
-
|
|
1046
|
+
isList = true;
|
|
897
1047
|
break;
|
|
898
1048
|
case EnumToken.ImageFunctionTokenDefType:
|
|
899
|
-
|
|
1049
|
+
isList = true;
|
|
900
1050
|
break;
|
|
901
1051
|
case EnumToken.TimelineFunctionTokenDefType:
|
|
902
|
-
|
|
1052
|
+
isList = true;
|
|
903
1053
|
break;
|
|
904
1054
|
// case EnumToken.GeneralEnclosedFunctionTokenDefType:
|
|
905
1055
|
// searchArray = generalEnclosedFunc;
|
|
906
1056
|
// break;
|
|
907
1057
|
case EnumToken.SupportsFunctionTokenDefType:
|
|
908
|
-
|
|
1058
|
+
isList = true;
|
|
909
1059
|
break;
|
|
910
1060
|
case EnumToken.TimingFunctionTokenDefType:
|
|
911
|
-
|
|
1061
|
+
isList = true;
|
|
912
1062
|
break;
|
|
913
1063
|
case EnumToken.MathFunctionTokenDefType:
|
|
914
|
-
|
|
1064
|
+
isList = true;
|
|
915
1065
|
break;
|
|
916
1066
|
case EnumToken.WhenElseFunctionTokenDefType:
|
|
917
|
-
|
|
1067
|
+
isList = true;
|
|
918
1068
|
break;
|
|
919
1069
|
case EnumToken.WildCardFunctionTokenDefType:
|
|
920
|
-
|
|
1070
|
+
isList = true;
|
|
921
1071
|
break;
|
|
922
1072
|
case EnumToken.FrequencyTokenType:
|
|
923
|
-
|
|
1073
|
+
isList = true;
|
|
924
1074
|
hasUnit = true;
|
|
925
1075
|
break;
|
|
926
1076
|
case EnumToken.ResolutionTokenType:
|
|
927
|
-
|
|
1077
|
+
isList = true;
|
|
928
1078
|
hasUnit = true;
|
|
929
1079
|
break;
|
|
930
1080
|
case EnumToken.LengthTokenType:
|
|
931
|
-
|
|
1081
|
+
isList = true;
|
|
932
1082
|
hasUnit = true;
|
|
933
1083
|
break;
|
|
934
1084
|
case EnumToken.FlexTokenType:
|
|
935
|
-
|
|
1085
|
+
isList = true;
|
|
936
1086
|
hasUnit = true;
|
|
937
1087
|
break;
|
|
938
1088
|
case EnumToken.AngleTokenType:
|
|
939
|
-
|
|
1089
|
+
isList = true;
|
|
940
1090
|
hasUnit = true;
|
|
941
1091
|
break;
|
|
942
1092
|
case EnumToken.TimeTokenType:
|
|
943
|
-
|
|
1093
|
+
isList = true;
|
|
944
1094
|
hasUnit = true;
|
|
945
1095
|
break;
|
|
946
1096
|
case EnumToken.DimensionTokenType:
|
|
947
1097
|
hasUnit = true;
|
|
948
1098
|
break;
|
|
949
1099
|
}
|
|
950
|
-
|
|
951
|
-
|
|
1100
|
+
const isHint = hintsEnum.has(hint);
|
|
1101
|
+
if (isList) {
|
|
1102
|
+
val = findItem(hint, parseInfo, hasUnit ? slice : parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset);
|
|
952
1103
|
}
|
|
953
|
-
else if (
|
|
954
|
-
|
|
1104
|
+
else if (hint == EnumToken.NumberTokenType || hint == EnumToken.WhitespaceTokenType) ;
|
|
1105
|
+
else if (!isHint) {
|
|
1106
|
+
val = parseInfo.stream.slice(slice ?? parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset);
|
|
955
1107
|
}
|
|
956
1108
|
if (this.decodeString) {
|
|
957
1109
|
val = decodeEscapeSequences(val);
|
|
958
1110
|
}
|
|
959
|
-
if (
|
|
1111
|
+
if (isHint) {
|
|
960
1112
|
this.typ = hint;
|
|
961
1113
|
}
|
|
962
1114
|
else {
|
|
963
1115
|
this.typ = hint;
|
|
964
1116
|
if (hasUnit || hint == EnumToken.PercentageTokenType || hint == EnumToken.DimensionTokenType) {
|
|
965
|
-
this.val =
|
|
1117
|
+
this.val = parseNumber(parseInfo.stream, parseInfo.position - parseInfo.offset, slice);
|
|
966
1118
|
if (hint != EnumToken.PercentageTokenType) {
|
|
967
1119
|
this.unit = val;
|
|
968
1120
|
if (val.startsWith("--")) {
|
|
@@ -971,7 +1123,7 @@ class Tokenizer {
|
|
|
971
1123
|
}
|
|
972
1124
|
}
|
|
973
1125
|
else if (hint == EnumToken.NumberTokenType) {
|
|
974
|
-
this.val =
|
|
1126
|
+
this.val = parseNumber(parseInfo.stream, slice ?? parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset);
|
|
975
1127
|
}
|
|
976
1128
|
else if (hint == EnumToken.AtRuleTokenType) {
|
|
977
1129
|
this.nam = val;
|
|
@@ -991,7 +1143,7 @@ class Tokenizer {
|
|
|
991
1143
|
}
|
|
992
1144
|
if (this.typ == null) {
|
|
993
1145
|
val = parseInfo.stream.slice(parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset);
|
|
994
|
-
if (
|
|
1146
|
+
if (decodeSegments) {
|
|
995
1147
|
val = decodeEscapeSequences(val);
|
|
996
1148
|
this.decodeString = true;
|
|
997
1149
|
}
|
|
@@ -1037,8 +1189,9 @@ class Tokenizer {
|
|
|
1037
1189
|
*/
|
|
1038
1190
|
match(parseInfo, input) {
|
|
1039
1191
|
let position = parseInfo.currentPosition - parseInfo.offset;
|
|
1192
|
+
// compare the character codes: no single character strings
|
|
1040
1193
|
for (let i = 0; i < input.length; i++) {
|
|
1041
|
-
if (parseInfo.stream
|
|
1194
|
+
if (parseInfo.stream.charCodeAt(position + i) != input.charCodeAt(i)) {
|
|
1042
1195
|
return false;
|
|
1043
1196
|
}
|
|
1044
1197
|
}
|
|
@@ -1066,19 +1219,20 @@ class Tokenizer {
|
|
|
1066
1219
|
return parseInfo.stream.slice(position, position + count);
|
|
1067
1220
|
}
|
|
1068
1221
|
/**
|
|
1069
|
-
*
|
|
1222
|
+
* move forward by count characters (at most to the end of the stream) and record the new lines. the characters
|
|
1223
|
+
* are read from the stream: no string is created
|
|
1070
1224
|
* @param parseInfo
|
|
1071
1225
|
* @param count
|
|
1072
|
-
* @returns
|
|
1073
1226
|
*/
|
|
1074
1227
|
advance(parseInfo, count = 1) {
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1228
|
+
const stream = parseInfo.stream;
|
|
1229
|
+
const position = parseInfo.currentPosition - parseInfo.offset;
|
|
1230
|
+
const remaining = stream.length - position;
|
|
1231
|
+
const length = count < remaining ? (count > 0 ? count : 0) : remaining > 0 ? remaining : 0;
|
|
1079
1232
|
const lineStarts = parseInfo.source.lineStarts.lineStarts;
|
|
1080
|
-
|
|
1081
|
-
|
|
1233
|
+
let codepoint;
|
|
1234
|
+
for (let i = 0; i < length; i++) {
|
|
1235
|
+
codepoint = stream.charCodeAt(position + i);
|
|
1082
1236
|
if (codepoint == 0xa || // \n
|
|
1083
1237
|
codepoint == 0xb || // \v
|
|
1084
1238
|
codepoint == 0xc || // \f
|
|
@@ -1086,15 +1240,60 @@ class Tokenizer {
|
|
|
1086
1240
|
codepoint == 0x2028 || // \u2028
|
|
1087
1241
|
codepoint == 0x2029 // \u2029
|
|
1088
1242
|
) {
|
|
1089
|
-
// \r\n
|
|
1090
|
-
if (codepoint == 0xa && i > 0 &&
|
|
1243
|
+
// \r\n: a single line start
|
|
1244
|
+
if (codepoint == 0xa && i > 0 && stream.charCodeAt(position + i - 1) == 0xd) ;
|
|
1091
1245
|
else {
|
|
1092
1246
|
lineStarts.push(position + parseInfo.offset + i);
|
|
1093
1247
|
}
|
|
1094
1248
|
}
|
|
1095
1249
|
}
|
|
1096
|
-
parseInfo.currentPosition +=
|
|
1097
|
-
|
|
1250
|
+
parseInfo.currentPosition += length;
|
|
1251
|
+
}
|
|
1252
|
+
/**
|
|
1253
|
+
* move forward over characters that are not new lines (ascii identifiers, numbers, colors, punctuation):
|
|
1254
|
+
* no string is created and the characters are not read again. see {@link advance}
|
|
1255
|
+
* @param parseInfo
|
|
1256
|
+
* @param count
|
|
1257
|
+
*/
|
|
1258
|
+
skip(parseInfo, count) {
|
|
1259
|
+
const remaining = parseInfo.stream.length - (parseInfo.currentPosition - parseInfo.offset);
|
|
1260
|
+
parseInfo.currentPosition += count < remaining ? count : remaining > 0 ? remaining : 0;
|
|
1261
|
+
}
|
|
1262
|
+
/**
|
|
1263
|
+
* move forward over the identifier read by consumeIdentToken(): the new lines are recorded when it has non ascii
|
|
1264
|
+
* characters, see {@link advance}
|
|
1265
|
+
* @param parseInfo
|
|
1266
|
+
* @param count
|
|
1267
|
+
*/
|
|
1268
|
+
skipIdent(parseInfo, count) {
|
|
1269
|
+
if (this.identNonAscii) {
|
|
1270
|
+
this.advance(parseInfo, count);
|
|
1271
|
+
}
|
|
1272
|
+
else {
|
|
1273
|
+
this.skip(parseInfo, count);
|
|
1274
|
+
}
|
|
1275
|
+
}
|
|
1276
|
+
/**
|
|
1277
|
+
* move forward by one character and return its code (NaN at the end of the stream). new lines are recorded
|
|
1278
|
+
* like {@link advance}
|
|
1279
|
+
* @param parseInfo
|
|
1280
|
+
*/
|
|
1281
|
+
advanceCode(parseInfo) {
|
|
1282
|
+
const position = parseInfo.currentPosition - parseInfo.offset;
|
|
1283
|
+
const codepoint = parseInfo.stream.charCodeAt(position);
|
|
1284
|
+
if (codepoint != codepoint) {
|
|
1285
|
+
return codepoint;
|
|
1286
|
+
}
|
|
1287
|
+
if (codepoint == 0xa || // \n
|
|
1288
|
+
codepoint == 0xb || // \v
|
|
1289
|
+
codepoint == 0xc || // \f
|
|
1290
|
+
codepoint == 0xd || // \r
|
|
1291
|
+
codepoint == 0x2028 ||
|
|
1292
|
+
codepoint == 0x2029) {
|
|
1293
|
+
parseInfo.source.lineStarts.lineStarts.push(position + parseInfo.offset);
|
|
1294
|
+
}
|
|
1295
|
+
parseInfo.currentPosition++;
|
|
1296
|
+
return codepoint;
|
|
1098
1297
|
}
|
|
1099
1298
|
/**
|
|
1100
1299
|
*
|
|
@@ -1165,8 +1364,9 @@ class Tokenizer {
|
|
|
1165
1364
|
startsWith(parseInfo, input) {
|
|
1166
1365
|
let i = 0;
|
|
1167
1366
|
let j = input.length;
|
|
1367
|
+
// compare the character codes: no single character strings
|
|
1168
1368
|
while (i < j) {
|
|
1169
|
-
if (parseInfo.stream.
|
|
1369
|
+
if (parseInfo.stream.charCodeAt(parseInfo.position - parseInfo.offset + i) != input.charCodeAt(i)) {
|
|
1170
1370
|
return false;
|
|
1171
1371
|
}
|
|
1172
1372
|
i++;
|
|
@@ -1223,7 +1423,8 @@ class Tokenizer {
|
|
|
1223
1423
|
const endPosition = parseInfo.stream.length - 1; // yieldEOFToken ? parseInfo.stream.length - 1 : parseInfo.stream.length - 10;
|
|
1224
1424
|
let tokensCount;
|
|
1225
1425
|
// NaN is not equal to NaN
|
|
1226
|
-
|
|
1426
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
1427
|
+
while ((charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset)) == charCode) {
|
|
1227
1428
|
if (this.state === EnumToken.UrlFunctionTokenDefType) {
|
|
1228
1429
|
this.state = null;
|
|
1229
1430
|
return this.consumeURLToken(parseInfo, endPosition);
|
|
@@ -1235,18 +1436,17 @@ class Tokenizer {
|
|
|
1235
1436
|
isDigit(charCode)) {
|
|
1236
1437
|
tokensCount = this.consumeNumericToken(parseInfo);
|
|
1237
1438
|
if (tokensCount > 0) {
|
|
1439
|
+
// the range of an invalid exponent may contain new lines
|
|
1238
1440
|
this.advance(parseInfo, tokensCount);
|
|
1239
|
-
return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType,
|
|
1240
|
-
slice: this.slice,
|
|
1241
|
-
sign: charCode == 45 /* TokenMap.MINUS */ ? "-" : charCode == 43 /* TokenMap.PLUS */ ? "+" : null,
|
|
1242
|
-
});
|
|
1441
|
+
return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, this.slice);
|
|
1243
1442
|
}
|
|
1244
1443
|
}
|
|
1245
1444
|
if (isIdentStart(charCode) || charCode == 45 /* TokenMap.MINUS */) {
|
|
1246
1445
|
tokensCount = this.consumeIdentToken(parseInfo);
|
|
1247
1446
|
if (tokensCount > 0) {
|
|
1248
|
-
this.
|
|
1249
|
-
|
|
1447
|
+
this.skipIdent(parseInfo, tokensCount);
|
|
1448
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
1449
|
+
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
1250
1450
|
// do not match function
|
|
1251
1451
|
if (40 /* TokenMap.LEFT_PARENTHESIS */ != charCode) {
|
|
1252
1452
|
return this.makeToken(parseInfo, this.startsWith(parseInfo, "--")
|
|
@@ -1256,15 +1456,17 @@ class Tokenizer {
|
|
|
1256
1456
|
}
|
|
1257
1457
|
}
|
|
1258
1458
|
if (charCode == 64 /* TokenMap.AT */) {
|
|
1259
|
-
this.
|
|
1260
|
-
|
|
1459
|
+
this.skip(parseInfo, 1);
|
|
1460
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
1461
|
+
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
1261
1462
|
// match at-rule
|
|
1262
|
-
|
|
1463
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
1464
|
+
if (charCode == 45 /* TokenMap.MINUS */ || isIdentStart(parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset))) {
|
|
1263
1465
|
// consume '@'
|
|
1264
1466
|
parseInfo.position = parseInfo.currentPosition;
|
|
1265
1467
|
tokensCount = this.consumeIdentToken(parseInfo);
|
|
1266
1468
|
if (tokensCount > 0) {
|
|
1267
|
-
this.
|
|
1469
|
+
this.skipIdent(parseInfo, tokensCount);
|
|
1268
1470
|
return this.makeToken(parseInfo, EnumToken.AtRuleTokenType);
|
|
1269
1471
|
}
|
|
1270
1472
|
}
|
|
@@ -1272,13 +1474,13 @@ class Tokenizer {
|
|
|
1272
1474
|
if (charCode == 35 /* TokenMap.HASH */) {
|
|
1273
1475
|
tokensCount = this.consumeColor(parseInfo);
|
|
1274
1476
|
if (tokensCount > 0) {
|
|
1275
|
-
this.
|
|
1477
|
+
this.skip(parseInfo, tokensCount);
|
|
1276
1478
|
return this.makeToken(parseInfo, EnumToken.ColorTokenType);
|
|
1277
1479
|
}
|
|
1278
|
-
this.
|
|
1480
|
+
this.skip(parseInfo, 1);
|
|
1279
1481
|
tokensCount = this.consumeIdentToken(parseInfo);
|
|
1280
1482
|
if (tokensCount > 0) {
|
|
1281
|
-
this.
|
|
1483
|
+
this.skipIdent(parseInfo, tokensCount);
|
|
1282
1484
|
return this.makeToken(parseInfo, EnumToken.HashTokenType);
|
|
1283
1485
|
}
|
|
1284
1486
|
}
|
|
@@ -1289,19 +1491,19 @@ class Tokenizer {
|
|
|
1289
1491
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1290
1492
|
// return this.makeToken(parseInfo);
|
|
1291
1493
|
// }
|
|
1292
|
-
this.
|
|
1494
|
+
this.skip(parseInfo, 1);
|
|
1293
1495
|
return this.makeToken(parseInfo, EnumToken.DelimTokenType);
|
|
1294
1496
|
// '+' or '-'
|
|
1295
1497
|
case 43 /* TokenMap.PLUS */:
|
|
1296
1498
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1297
1499
|
// return this.makeToken(parseInfo);
|
|
1298
1500
|
// }
|
|
1299
|
-
this.
|
|
1501
|
+
this.skip(parseInfo, 1);
|
|
1300
1502
|
charCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
1301
1503
|
// if (isDigit(charCode)) {
|
|
1302
1504
|
// tokensCount = this.consumeNumericToken(parseInfo);
|
|
1303
1505
|
// if (tokensCount > 0) {
|
|
1304
|
-
// this.
|
|
1506
|
+
// this.skip(parseInfo, tokensCount);
|
|
1305
1507
|
// return this.makeToken(parseInfo, this.hint ?? EnumToken.NumberTokenType, {
|
|
1306
1508
|
// slice: this.slice,
|
|
1307
1509
|
// sign: "+",
|
|
@@ -1314,36 +1516,36 @@ class Tokenizer {
|
|
|
1314
1516
|
nextCharCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset + 1);
|
|
1315
1517
|
// not a number
|
|
1316
1518
|
if (isWhiteSpace(nextCharCode)) {
|
|
1317
|
-
this.
|
|
1519
|
+
this.skip(parseInfo, 1);
|
|
1318
1520
|
return this.makeToken(parseInfo, EnumToken.Sub);
|
|
1319
1521
|
}
|
|
1320
1522
|
// if (
|
|
1321
1523
|
// charCode == TokenMap.MINUS &&
|
|
1322
1524
|
// (nextCharCode == TokenMap.MINUS || isIdentStart(nextCharCode))
|
|
1323
|
-
//
|
|
1324
|
-
// this.
|
|
1525
|
+
//) {
|
|
1526
|
+
// this.skip(parseInfo, 1);
|
|
1325
1527
|
// tokensCount = this.consumeIdentToken(parseInfo);
|
|
1326
1528
|
// if (tokensCount > 0) {
|
|
1327
|
-
// this.
|
|
1529
|
+
// this.skip(parseInfo, tokensCount);
|
|
1328
1530
|
// return this.makeToken(parseInfo, EnumToken.IdenTokenType);
|
|
1329
1531
|
// }
|
|
1330
1532
|
// }
|
|
1331
1533
|
}
|
|
1332
|
-
this.
|
|
1534
|
+
this.skip(parseInfo, 1);
|
|
1333
1535
|
break;
|
|
1334
1536
|
// '{'
|
|
1335
1537
|
case 123 /* TokenMap.LEFT_BRACE */:
|
|
1336
1538
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1337
1539
|
return this.makeToken(parseInfo);
|
|
1338
1540
|
}
|
|
1339
|
-
this.
|
|
1541
|
+
this.skip(parseInfo, 1);
|
|
1340
1542
|
return this.makeToken(parseInfo, EnumToken.BlockStartTokenType);
|
|
1341
1543
|
// '}'
|
|
1342
1544
|
case 125 /* TokenMap.RIGHT_BRACE */:
|
|
1343
1545
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1344
1546
|
return this.makeToken(parseInfo);
|
|
1345
1547
|
}
|
|
1346
|
-
this.
|
|
1548
|
+
this.skip(parseInfo, 1);
|
|
1347
1549
|
return this.makeToken(parseInfo, EnumToken.BlockEndTokenType);
|
|
1348
1550
|
// '('
|
|
1349
1551
|
case 40 /* TokenMap.LEFT_PARENTHESIS */:
|
|
@@ -1351,8 +1553,8 @@ class Tokenizer {
|
|
|
1351
1553
|
// if (
|
|
1352
1554
|
// parseInfo.stream[parseInfo.position - parseInfo.offset] === ":" &&
|
|
1353
1555
|
// this.isPseudo(parseInfo)
|
|
1354
|
-
//
|
|
1355
|
-
// this.
|
|
1556
|
+
//) {
|
|
1557
|
+
// this.skip(parseInfo, 1);
|
|
1356
1558
|
// return this.makeToken(parseInfo, EnumToken.PseudoClassFunctionTokenDefType);
|
|
1357
1559
|
// } else
|
|
1358
1560
|
if (this.isIdentToken(parseInfo)) {
|
|
@@ -1360,7 +1562,7 @@ class Tokenizer {
|
|
|
1360
1562
|
? EnumToken.CustomFunctionTokenDefType
|
|
1361
1563
|
: (getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset + 1) ?? EnumToken.FunctionTokenDefType);
|
|
1362
1564
|
this.makeToken(parseInfo, hint);
|
|
1363
|
-
this.
|
|
1565
|
+
this.skip(parseInfo, 1);
|
|
1364
1566
|
// consume '('
|
|
1365
1567
|
parseInfo.position = parseInfo.currentPosition;
|
|
1366
1568
|
if (hint === EnumToken.UrlFunctionTokenDefType) {
|
|
@@ -1369,42 +1571,43 @@ class Tokenizer {
|
|
|
1369
1571
|
return this;
|
|
1370
1572
|
}
|
|
1371
1573
|
}
|
|
1372
|
-
this.
|
|
1574
|
+
this.skip(parseInfo, 1);
|
|
1373
1575
|
return this.makeToken(parseInfo, EnumToken.StartParensTokenType);
|
|
1374
1576
|
// ')'
|
|
1375
1577
|
case 41 /* TokenMap.RIGHT_PARENTHESIS */:
|
|
1376
1578
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1377
1579
|
return this.makeToken(parseInfo);
|
|
1378
1580
|
}
|
|
1379
|
-
this.
|
|
1581
|
+
this.skip(parseInfo, 1);
|
|
1380
1582
|
return this.makeToken(parseInfo, EnumToken.EndParensTokenType);
|
|
1381
1583
|
// '['
|
|
1382
1584
|
case 91 /* TokenMap.LEFT_BRACKETS */:
|
|
1383
1585
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1384
1586
|
// return this.makeToken(parseInfo);
|
|
1385
1587
|
// }
|
|
1386
|
-
this.
|
|
1588
|
+
this.skip(parseInfo, 1);
|
|
1387
1589
|
return this.makeToken(parseInfo, EnumToken.AttrStartTokenType);
|
|
1388
1590
|
// ']'
|
|
1389
1591
|
case 93 /* TokenMap.RIGHT_BRACKETS */:
|
|
1390
1592
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1391
1593
|
// return this.makeToken(parseInfo);
|
|
1392
1594
|
// }
|
|
1393
|
-
this.
|
|
1595
|
+
this.skip(parseInfo, 1);
|
|
1394
1596
|
return this.makeToken(parseInfo, EnumToken.AttrEndTokenType);
|
|
1395
1597
|
case 59 /* TokenMap.SEMICOLON */:
|
|
1396
1598
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1397
1599
|
// return this.makeToken(parseInfo);
|
|
1398
1600
|
// }
|
|
1399
|
-
this.
|
|
1601
|
+
this.skip(parseInfo, 1);
|
|
1400
1602
|
return this.makeToken(parseInfo, EnumToken.SemiColonTokenType);
|
|
1401
1603
|
case 58 /* TokenMap.COLON */:
|
|
1402
1604
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1403
1605
|
// return this.makeToken(parseInfo);
|
|
1404
1606
|
// }
|
|
1405
|
-
this.
|
|
1406
|
-
|
|
1407
|
-
|
|
1607
|
+
this.skip(parseInfo, 1);
|
|
1608
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
1609
|
+
if (parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset) == 58 /* TokenMap.COLON */) {
|
|
1610
|
+
this.skip(parseInfo, 1);
|
|
1408
1611
|
return this.makeToken(parseInfo, EnumToken.DoubleColonTokenType);
|
|
1409
1612
|
}
|
|
1410
1613
|
return this.makeToken(parseInfo, EnumToken.ColonTokenType);
|
|
@@ -1420,43 +1623,43 @@ class Tokenizer {
|
|
|
1420
1623
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1421
1624
|
return this.makeToken(parseInfo);
|
|
1422
1625
|
}
|
|
1423
|
-
this.
|
|
1424
|
-
|
|
1626
|
+
this.advanceCode(parseInfo);
|
|
1627
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
1628
|
+
nextCharCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
1425
1629
|
while (nextCharCode == 0x20 ||
|
|
1426
1630
|
(nextCharCode >= 0x9 && nextCharCode <= 0xd) ||
|
|
1427
1631
|
nextCharCode == 0x2028 ||
|
|
1428
1632
|
nextCharCode == 0x2029) {
|
|
1429
|
-
this.
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
.charCodeAt(0);
|
|
1633
|
+
this.advanceCode(parseInfo);
|
|
1634
|
+
// inlined: this.peekCharCode(parseInfo)
|
|
1635
|
+
nextCharCode = parseInfo.stream.charCodeAt(parseInfo.currentPosition - parseInfo.offset);
|
|
1433
1636
|
}
|
|
1434
1637
|
return this.makeToken(parseInfo, EnumToken.WhitespaceTokenType);
|
|
1435
1638
|
case 44 /* TokenMap.COMMA */:
|
|
1436
1639
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1437
1640
|
// return this.makeToken(parseInfo);
|
|
1438
1641
|
// }
|
|
1439
|
-
this.
|
|
1642
|
+
this.skip(parseInfo, 1);
|
|
1440
1643
|
return this.makeToken(parseInfo, EnumToken.CommaTokenType);
|
|
1441
1644
|
case 36 /* TokenMap.DOLLAR */:
|
|
1442
1645
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1443
1646
|
// return this.makeToken(parseInfo);
|
|
1444
1647
|
// }
|
|
1445
1648
|
if (this.match(parseInfo, "$=")) {
|
|
1446
|
-
this.
|
|
1649
|
+
this.skip(parseInfo, 2);
|
|
1447
1650
|
return this.makeToken(parseInfo, EnumToken.EndMatchTokenType);
|
|
1448
1651
|
}
|
|
1449
|
-
this.
|
|
1652
|
+
this.skip(parseInfo, 1);
|
|
1450
1653
|
break;
|
|
1451
1654
|
case 126 /* TokenMap.TILDA */:
|
|
1452
1655
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1453
1656
|
// return this.makeToken(parseInfo);
|
|
1454
1657
|
// }
|
|
1455
1658
|
if (this.match(parseInfo, "~=")) {
|
|
1456
|
-
this.
|
|
1659
|
+
this.skip(parseInfo, 2);
|
|
1457
1660
|
return this.makeToken(parseInfo, EnumToken.IncludeMatchTokenType);
|
|
1458
1661
|
}
|
|
1459
|
-
this.
|
|
1662
|
+
this.skip(parseInfo, 1);
|
|
1460
1663
|
return this.makeToken(parseInfo, EnumToken.Tilda);
|
|
1461
1664
|
// case '^':
|
|
1462
1665
|
case 94 /* TokenMap.CARET */:
|
|
@@ -1464,26 +1667,26 @@ class Tokenizer {
|
|
|
1464
1667
|
// return this.makeToken(parseInfo);
|
|
1465
1668
|
// }
|
|
1466
1669
|
if (this.match(parseInfo, "^=")) {
|
|
1467
|
-
this.
|
|
1670
|
+
this.skip(parseInfo, 2);
|
|
1468
1671
|
return this.makeToken(parseInfo, EnumToken.StartMatchTokenType);
|
|
1469
1672
|
}
|
|
1470
|
-
this.
|
|
1673
|
+
this.skip(parseInfo, 1);
|
|
1471
1674
|
break;
|
|
1472
1675
|
case 42 /* TokenMap.STAR */:
|
|
1473
1676
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1474
1677
|
// return this.makeToken(parseInfo);
|
|
1475
1678
|
// }
|
|
1476
1679
|
if (this.match(parseInfo, "*=")) {
|
|
1477
|
-
this.
|
|
1680
|
+
this.skip(parseInfo, 2);
|
|
1478
1681
|
return this.makeToken(parseInfo, EnumToken.ContainMatchTokenType);
|
|
1479
1682
|
}
|
|
1480
|
-
this.
|
|
1683
|
+
this.skip(parseInfo, 1);
|
|
1481
1684
|
return this.makeToken(parseInfo, EnumToken.Star);
|
|
1482
1685
|
case 38 /* TokenMap.AMPERSAND */:
|
|
1483
1686
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1484
1687
|
return this.makeToken(parseInfo);
|
|
1485
1688
|
}
|
|
1486
|
-
this.
|
|
1689
|
+
this.skip(parseInfo, 1);
|
|
1487
1690
|
return this.makeToken(parseInfo, EnumToken.NestingSelectorTokenType);
|
|
1488
1691
|
case 124 /* TokenMap.PIPE */:
|
|
1489
1692
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
@@ -1491,38 +1694,38 @@ class Tokenizer {
|
|
|
1491
1694
|
// }
|
|
1492
1695
|
// '||'
|
|
1493
1696
|
if (this.match(parseInfo, "||")) {
|
|
1494
|
-
this.
|
|
1697
|
+
this.skip(parseInfo, 2);
|
|
1495
1698
|
return this.makeToken(parseInfo, EnumToken.ColumnCombinatorTokenType);
|
|
1496
1699
|
}
|
|
1497
1700
|
else if (this.match(parseInfo, "|=")) {
|
|
1498
|
-
this.
|
|
1701
|
+
this.skip(parseInfo, 2);
|
|
1499
1702
|
return this.makeToken(parseInfo, EnumToken.DashMatchTokenType);
|
|
1500
1703
|
}
|
|
1501
|
-
this.
|
|
1704
|
+
this.skip(parseInfo, 1);
|
|
1502
1705
|
return this.makeToken(parseInfo, EnumToken.PipeTokenType);
|
|
1503
1706
|
case 33 /* TokenMap.EXCLAMATION */:
|
|
1504
1707
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1505
1708
|
return this.makeToken(parseInfo);
|
|
1506
1709
|
}
|
|
1507
1710
|
if (this.match(parseInfo, "!important")) {
|
|
1508
|
-
this.
|
|
1711
|
+
this.skip(parseInfo, 10);
|
|
1509
1712
|
return this.makeToken(parseInfo, EnumToken.ImportantTokenType);
|
|
1510
1713
|
}
|
|
1511
|
-
this.
|
|
1714
|
+
this.skip(parseInfo, 1);
|
|
1512
1715
|
break;
|
|
1513
1716
|
case 47 /* TokenMap.SLASH */:
|
|
1514
1717
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1515
1718
|
// return this.makeToken(parseInfo);
|
|
1516
1719
|
// }
|
|
1517
1720
|
if (!this.match(parseInfo, "/*")) {
|
|
1518
|
-
this.
|
|
1721
|
+
this.skip(parseInfo, 1);
|
|
1519
1722
|
return this.makeToken(parseInfo, getSymbolHint(parseInfo, parseInfo.position - parseInfo.offset, parseInfo.currentPosition - parseInfo.offset));
|
|
1520
1723
|
}
|
|
1521
|
-
this.
|
|
1522
|
-
while ((charCode = this.
|
|
1724
|
+
this.skip(parseInfo, 2);
|
|
1725
|
+
while ((charCode = this.advanceCode(parseInfo)) == charCode) {
|
|
1523
1726
|
if (charCode == 42 /* TokenMap.STAR */) {
|
|
1524
1727
|
if (this.match(parseInfo, "/")) {
|
|
1525
|
-
this.
|
|
1728
|
+
this.skip(parseInfo, 1);
|
|
1526
1729
|
return this.makeToken(parseInfo, EnumToken.CommentTokenType);
|
|
1527
1730
|
}
|
|
1528
1731
|
}
|
|
@@ -1536,23 +1739,23 @@ class Tokenizer {
|
|
|
1536
1739
|
// return this.makeToken(parseInfo);
|
|
1537
1740
|
// }
|
|
1538
1741
|
if (this.match(parseInfo, ">=")) {
|
|
1539
|
-
this.
|
|
1742
|
+
this.skip(parseInfo, 2);
|
|
1540
1743
|
return this.makeToken(parseInfo, EnumToken.GteTokenType);
|
|
1541
1744
|
}
|
|
1542
|
-
this.
|
|
1745
|
+
this.skip(parseInfo, 1);
|
|
1543
1746
|
return this.makeToken(parseInfo, EnumToken.GtTokenType);
|
|
1544
1747
|
case 60 /* TokenMap.LOWERTHAN */:
|
|
1545
1748
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1546
1749
|
return this.makeToken(parseInfo);
|
|
1547
1750
|
}
|
|
1548
1751
|
if (this.match(parseInfo, "<=")) {
|
|
1549
|
-
this.
|
|
1752
|
+
this.skip(parseInfo, 2);
|
|
1550
1753
|
return this.makeToken(parseInfo, EnumToken.LteTokenType);
|
|
1551
1754
|
}
|
|
1552
|
-
this.
|
|
1755
|
+
this.skip(parseInfo, 1);
|
|
1553
1756
|
if (this.match(parseInfo, "!--")) {
|
|
1554
|
-
this.
|
|
1555
|
-
while ((charCode = this.
|
|
1757
|
+
this.skip(parseInfo, 3);
|
|
1758
|
+
while ((charCode = this.advanceCode(parseInfo)) == charCode) {
|
|
1556
1759
|
if (charCode == 45 /* TokenMap.MINUS */ && this.match(parseInfo, "->")) {
|
|
1557
1760
|
break;
|
|
1558
1761
|
}
|
|
@@ -1561,7 +1764,7 @@ class Tokenizer {
|
|
|
1561
1764
|
return this.makeToken(parseInfo, EnumToken.BadCdoTokenType);
|
|
1562
1765
|
}
|
|
1563
1766
|
else {
|
|
1564
|
-
this.
|
|
1767
|
+
this.skip(parseInfo, 2);
|
|
1565
1768
|
return this.makeToken(parseInfo, EnumToken.CDOCOMMTokenType);
|
|
1566
1769
|
}
|
|
1567
1770
|
}
|
|
@@ -1575,7 +1778,7 @@ class Tokenizer {
|
|
|
1575
1778
|
charCode = parseInfo.stream.charCodeAt(++offset + startPosition);
|
|
1576
1779
|
}
|
|
1577
1780
|
if (offset > 1 && charCode == 62 /* TokenMap.GREATERTHAN */) {
|
|
1578
|
-
this.
|
|
1781
|
+
this.skip(parseInfo, offset);
|
|
1579
1782
|
return this.makeToken(parseInfo, EnumToken.CssTypeTokenType);
|
|
1580
1783
|
}
|
|
1581
1784
|
}
|
|
@@ -1585,9 +1788,10 @@ class Tokenizer {
|
|
|
1585
1788
|
if (parseInfo.position < parseInfo.currentPosition) {
|
|
1586
1789
|
return this.makeToken(parseInfo);
|
|
1587
1790
|
}
|
|
1588
|
-
this.
|
|
1791
|
+
this.skip(parseInfo, 1);
|
|
1589
1792
|
break;
|
|
1590
1793
|
case 92 /* TokenMap.REVERSE_SOLIDUS */:
|
|
1794
|
+
// a new line may follow the backslash
|
|
1591
1795
|
this.advance(parseInfo);
|
|
1592
1796
|
// EOF
|
|
1593
1797
|
// end of stream ignore \\
|
|
@@ -1608,22 +1812,23 @@ class Tokenizer {
|
|
|
1608
1812
|
// if (parseInfo.position < parseInfo.currentPosition) {
|
|
1609
1813
|
// return this.makeToken(parseInfo);
|
|
1610
1814
|
// }
|
|
1611
|
-
this.
|
|
1815
|
+
this.skip(parseInfo, 1);
|
|
1612
1816
|
let tokensCount = this.consumeIdentToken(parseInfo);
|
|
1613
1817
|
if (tokensCount > 0) {
|
|
1614
|
-
this.
|
|
1818
|
+
this.skipIdent(parseInfo, tokensCount);
|
|
1615
1819
|
return this.makeToken(parseInfo, EnumToken.ClassSelectorTokenType);
|
|
1616
1820
|
}
|
|
1617
1821
|
}
|
|
1618
1822
|
// if (!isDigit(codepoint) && parseInfo.position !== parseInfo.currentPosition) {
|
|
1619
1823
|
// this.makeToken(parseInfo);
|
|
1620
|
-
// this.
|
|
1824
|
+
// this.skip(parseInfo, 2);
|
|
1621
1825
|
// return this;
|
|
1622
1826
|
// }
|
|
1623
|
-
|
|
1827
|
+
// the dot, or the character that follows it (U+2028 / U+2029 are identifier characters)
|
|
1828
|
+
this.advanceCode(parseInfo);
|
|
1624
1829
|
break;
|
|
1625
1830
|
default:
|
|
1626
|
-
this.
|
|
1831
|
+
this.skip(parseInfo, 1);
|
|
1627
1832
|
break;
|
|
1628
1833
|
}
|
|
1629
1834
|
}
|
|
@@ -1644,13 +1849,15 @@ class Tokenizer {
|
|
|
1644
1849
|
const { done, value } = await reader.read();
|
|
1645
1850
|
const stream = ArrayBuffer.isView(value) ? decoder.decode(value, { stream: true }) : value;
|
|
1646
1851
|
if (!done) {
|
|
1647
|
-
parseInfo.source.append(stream)
|
|
1852
|
+
// inlined: parseInfo.source.append(stream as string)
|
|
1853
|
+
parseInfo.source.content += stream;
|
|
1648
1854
|
}
|
|
1649
1855
|
else {
|
|
1650
1856
|
break;
|
|
1651
1857
|
}
|
|
1652
1858
|
}
|
|
1653
|
-
|
|
1859
|
+
// inlined: parseInfo.source.getContent()
|
|
1860
|
+
parseInfo.stream = parseInfo.source.content;
|
|
1654
1861
|
return this; // .next();
|
|
1655
1862
|
}
|
|
1656
1863
|
}
|