@tbela99/css-parser 1.4.7 → 1.4.9
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 +33 -2
- package/dist/index-umd-web.js +12953 -13248
- package/dist/index.cjs +10358 -10655
- package/dist/index.d.ts +820 -89
- package/dist/lib/ast/features/calc.js +3 -1
- package/dist/lib/ast/features/if.js +2 -96
- package/dist/lib/ast/features/prefix.js +7 -2
- package/dist/lib/ast/features/shorthand.js +1 -1
- package/dist/lib/ast/features/transform.js +1 -1
- package/dist/lib/ast/find.js +6 -6
- package/dist/lib/ast/math/expression.js +30 -12
- package/dist/lib/ast/minify.js +34 -5
- package/dist/lib/ast/transform/perspective.js +1 -1
- package/dist/lib/ast/transform/utils.js +29 -21
- package/dist/lib/ast/types.js +12 -0
- package/dist/lib/fs/resolve.js +2 -17
- package/dist/lib/parser/declaration/list.js +6 -1
- package/dist/lib/parser/linesmap.js +78 -0
- package/dist/lib/parser/parse.js +1264 -151
- package/dist/lib/parser/source.js +103 -0
- package/dist/lib/parser/tokenize.js +112 -133
- package/dist/lib/parser/utils/at-rule-container.js +12 -44
- package/dist/lib/parser/utils/at-rule-generic.js +12 -24
- package/dist/lib/parser/utils/at-rule-import.js +4 -172
- package/dist/lib/parser/utils/at-rule-media.js +27 -263
- package/dist/lib/parser/utils/at-rule-support.js +8 -258
- package/dist/lib/parser/utils/at-rule-when-else.js +4 -214
- package/dist/lib/parser/utils/declaration.js +5 -95
- package/dist/lib/parser/utils/hash.js +54 -1
- package/dist/lib/parser/utils/selector.js +1 -1
- package/dist/lib/parser/utils/token.js +1 -0
- package/dist/lib/renderer/render.js +79 -45
- package/dist/lib/renderer/sourcemap/sourcemap.js +47 -43
- package/dist/lib/syntax/color/cmyk.js +3 -3
- package/dist/lib/syntax/color/color-mix.js +15 -8
- package/dist/lib/syntax/color/color.js +19 -11
- package/dist/lib/syntax/color/hex.js +1 -1
- package/dist/lib/syntax/color/hsl.js +6 -6
- package/dist/lib/syntax/color/hwb.js +6 -6
- package/dist/lib/syntax/color/lab.js +5 -5
- package/dist/lib/syntax/color/lch.js +6 -6
- package/dist/lib/syntax/color/oklab.js +5 -5
- package/dist/lib/syntax/color/oklch.js +5 -5
- package/dist/lib/syntax/color/p3.js +9 -1
- package/dist/lib/syntax/color/{relativecolor.js → relative-color.js} +8 -1
- package/dist/lib/syntax/color/utils/distance.js +7 -2
- package/dist/lib/syntax/constants.js +5 -1
- package/dist/lib/syntax/syntax.js +12 -21
- package/dist/lib/validation/config.json.js +27 -6
- package/dist/lib/validation/match.js +42 -845
- package/dist/node.js +136 -11
- package/dist/web.js +135 -8
- package/llms.txt +73 -0
- package/package.json +14 -17
|
@@ -58,19 +58,6 @@ function isMFValue(featureName, tokens, isMFRange) {
|
|
|
58
58
|
}
|
|
59
59
|
// @ts-expect-error
|
|
60
60
|
const mediaFeature = config.mediaFeatures[featureName];
|
|
61
|
-
// if (
|
|
62
|
-
// tokens.length === 1 &&
|
|
63
|
-
// tokens[0].typ === EnumToken.MathFunctionTokenType &&
|
|
64
|
-
// (tokens[0] as FunctionToken).val === "calc"
|
|
65
|
-
// ) {
|
|
66
|
-
// // todo: check calc tokens are of compatible types : resolution, ratio, length, integer, number?
|
|
67
|
-
// // https://github.com/web-platform-tests/wpt/blob/master/css/mediaqueries/mq-calc-sign-function-003.html
|
|
68
|
-
// return {
|
|
69
|
-
// valid: true,
|
|
70
|
-
// success:
|
|
71
|
-
// mediaFeature.type !== MediaFeatureType.KeywordType && mediaFeature.type !== MediaFeatureType.StringType,
|
|
72
|
-
// };
|
|
73
|
-
// }
|
|
74
61
|
switch (mediaFeature.type) {
|
|
75
62
|
case MediaFeatureType.BooleanType:
|
|
76
63
|
return {
|
|
@@ -128,16 +115,6 @@ function isMFValue(featureName, tokens, isMFRange) {
|
|
|
128
115
|
success: true,
|
|
129
116
|
};
|
|
130
117
|
}
|
|
131
|
-
// export function isStyleRangeValue(tokens: Token[]): { success: boolean; errors: ErrorDescription[] } {
|
|
132
|
-
// const filtered: Token[] = tokens.filter(
|
|
133
|
-
// (token) => token.typ !== EnumToken.WhitespaceTokenType && token.typ !== EnumToken.CommentTokenType,
|
|
134
|
-
// );
|
|
135
|
-
// const result = isDeclarationValue(tokens);
|
|
136
|
-
// if (result.success) {
|
|
137
|
-
// result.success = filtered.length > 0;
|
|
138
|
-
// }
|
|
139
|
-
// return result;
|
|
140
|
-
// }
|
|
141
118
|
function createValidationContext(tokens) {
|
|
142
119
|
tokens = trimArray(tokens.filter((t) => t.typ !== EnumToken.CommentTokenType));
|
|
143
120
|
if (tokens.at(-1)?.typ === EnumToken.ImportantTokenType) {
|
|
@@ -151,31 +128,11 @@ function createValidationContext(tokens) {
|
|
|
151
128
|
if (this.index < 0) {
|
|
152
129
|
return null;
|
|
153
130
|
}
|
|
154
|
-
// while (
|
|
155
|
-
// this.tokens[this.index]?.typ == EnumToken.WhitespaceTokenType ||
|
|
156
|
-
// this.tokens[this.index]?.typ == EnumToken.CommentTokenType ||
|
|
157
|
-
// this.tokens[this.index]?.typ == EnumToken.CDOCOMMTokenType
|
|
158
|
-
// ) {
|
|
159
|
-
// this.index++;
|
|
160
|
-
// }
|
|
161
131
|
return this.tokens[this.index];
|
|
162
132
|
},
|
|
163
133
|
peek(offset = 0) {
|
|
164
134
|
let index = this.index;
|
|
165
135
|
let token = this.tokens[++index];
|
|
166
|
-
// if (!skipWhitespace) {
|
|
167
|
-
// while (offset >= 0 && index < this.tokens.length) {
|
|
168
|
-
// while (token != null && token.typ === EnumToken.CommentTokenType) {
|
|
169
|
-
// token = this.tokens[++index];
|
|
170
|
-
// }
|
|
171
|
-
// if (offset === 0 || token == null) {
|
|
172
|
-
// return token;
|
|
173
|
-
// }
|
|
174
|
-
// offset--;
|
|
175
|
-
// token = this.tokens[++index];
|
|
176
|
-
// }
|
|
177
|
-
// return token;
|
|
178
|
-
// }
|
|
179
136
|
while (offset >= 0 && index < this.tokens.length) {
|
|
180
137
|
while (token?.typ == EnumToken.WhitespaceTokenType ||
|
|
181
138
|
token?.typ == EnumToken.CommentTokenType ||
|
|
@@ -220,17 +177,11 @@ function createValidationContext(tokens) {
|
|
|
220
177
|
if (close !== EnumToken.EndParensTokenType && token?.typ === close) {
|
|
221
178
|
counter--;
|
|
222
179
|
}
|
|
223
|
-
// else if (open !== EnumToken.StartParensTokenType && token?.typ === open) {
|
|
224
|
-
// counter++;
|
|
225
|
-
// }
|
|
226
180
|
}
|
|
227
181
|
if (matchCount <= 0 && counter <= 0) {
|
|
228
182
|
break;
|
|
229
183
|
}
|
|
230
184
|
}
|
|
231
|
-
// if (tokens[0]?.typ === EnumToken.WhitespaceTokenType) {
|
|
232
|
-
// tokens.shift();
|
|
233
|
-
// }
|
|
234
185
|
return tokens;
|
|
235
186
|
},
|
|
236
187
|
// 2
|
|
@@ -365,9 +316,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
365
316
|
errors: [
|
|
366
317
|
{
|
|
367
318
|
action: "drop",
|
|
368
|
-
message: `Unexpected token ${EnumToken[stream[i].typ]}
|
|
319
|
+
message: `Unexpected token ${EnumToken[stream[i].typ]}`,
|
|
369
320
|
node: stream[i],
|
|
370
|
-
|
|
321
|
+
// @ts-expect-error
|
|
322
|
+
location: options.source.getSourceLocation(stream[i][LOC].sta),
|
|
371
323
|
},
|
|
372
324
|
],
|
|
373
325
|
};
|
|
@@ -376,9 +328,6 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
376
328
|
}
|
|
377
329
|
for (; i < stream.length; i++) {
|
|
378
330
|
token = stream[i];
|
|
379
|
-
// if (token.typ === EnumToken.EOF) {
|
|
380
|
-
// break;
|
|
381
|
-
// }
|
|
382
331
|
if (token.typ === EnumToken.Star) {
|
|
383
332
|
token.typ = EnumToken.UniversalSelectorTokenType;
|
|
384
333
|
}
|
|
@@ -398,15 +347,7 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
398
347
|
token.typ !== EnumToken.CDOCOMMTokenType) {
|
|
399
348
|
stack.pop();
|
|
400
349
|
}
|
|
401
|
-
// if (token.typ === EnumToken.LiteralTokenType && "+" === (token as LiteralToken).val) {
|
|
402
|
-
// Object.assign(token, { typ: EnumToken.NextSiblingCombinatorTokenType });
|
|
403
|
-
// continue;
|
|
404
|
-
// }
|
|
405
350
|
switch (token.typ) {
|
|
406
|
-
// case EnumToken.InvalidCommentTokenType:
|
|
407
|
-
// case EnumToken.BadCommentTokenType:
|
|
408
|
-
// case EnumToken.BadStringTokenType:
|
|
409
|
-
// break;
|
|
410
351
|
case EnumToken.PseudoClassFuncTokenType:
|
|
411
352
|
{
|
|
412
353
|
const result = matchAllSyntaxes(getParsedSyntax(ValidationSyntaxGroupEnum.Selectors, token.val + "()")?.[0]?.chi ?? [], createValidationContext(token.chi), options);
|
|
@@ -429,9 +370,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
429
370
|
errors: [
|
|
430
371
|
{
|
|
431
372
|
action: "drop",
|
|
432
|
-
message: `Nesting selector is not allowed
|
|
373
|
+
message: `Nesting selector is not allowed`,
|
|
433
374
|
node: token,
|
|
434
|
-
|
|
375
|
+
// @ts-expect-error
|
|
376
|
+
location: options.source.getSourceLocation(token[LOC].sta),
|
|
435
377
|
},
|
|
436
378
|
],
|
|
437
379
|
};
|
|
@@ -439,21 +381,6 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
439
381
|
break;
|
|
440
382
|
case EnumToken.Plus:
|
|
441
383
|
Object.assign(token, { typ: EnumToken.NextSiblingCombinatorTokenType });
|
|
442
|
-
// if (stack.length > 0 && nodes.includes(stack.at(-1)?.typ)) {
|
|
443
|
-
// return {
|
|
444
|
-
// success: false,
|
|
445
|
-
// errors: [
|
|
446
|
-
// {
|
|
447
|
-
// action: "drop",
|
|
448
|
-
// message: `Unexpected combinator ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOC]!.sta.lin}:${
|
|
449
|
-
// token[LOC]!.sta.col
|
|
450
|
-
// }`,
|
|
451
|
-
// node: token,
|
|
452
|
-
// location: token[LOC],
|
|
453
|
-
// },
|
|
454
|
-
// ],
|
|
455
|
-
// };
|
|
456
|
-
// }
|
|
457
384
|
stack.push(token);
|
|
458
385
|
break;
|
|
459
386
|
case EnumToken.Tilda:
|
|
@@ -465,9 +392,6 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
465
392
|
case EnumToken.DescendantCombinatorTokenType:
|
|
466
393
|
case EnumToken.NextSiblingCombinatorTokenType:
|
|
467
394
|
case EnumToken.SubsequentSiblingCombinatorTokenType:
|
|
468
|
-
// if (tokens.at(-1)?.typ === EnumToken.WhitespaceTokenType) {
|
|
469
|
-
// tokens.pop();
|
|
470
|
-
// }
|
|
471
395
|
if (stream[i + 1]?.typ === EnumToken.WhitespaceTokenType) {
|
|
472
396
|
i++;
|
|
473
397
|
}
|
|
@@ -480,9 +404,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
480
404
|
errors: [
|
|
481
405
|
{
|
|
482
406
|
action: "drop",
|
|
483
|
-
message: `Unexpected combinator ${EnumToken[token.typ]}
|
|
407
|
+
message: `Unexpected combinator ${EnumToken[token.typ]}`,
|
|
484
408
|
node: token,
|
|
485
|
-
|
|
409
|
+
// @ts-expect-error
|
|
410
|
+
location: options.source.getSourceLocation(token[LOC].sta),
|
|
486
411
|
},
|
|
487
412
|
],
|
|
488
413
|
};
|
|
@@ -493,21 +418,6 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
493
418
|
if (stack.length > 0 && stack.at(-1).typ === EnumToken.UniversalSelectorTokenType) {
|
|
494
419
|
stack.pop();
|
|
495
420
|
}
|
|
496
|
-
// if (tokens.length === 0 || stack.at(-1)?.typ == EnumToken.CommaTokenType) {
|
|
497
|
-
// return {
|
|
498
|
-
// success: false,
|
|
499
|
-
// errors: [
|
|
500
|
-
// {
|
|
501
|
-
// action: "drop",
|
|
502
|
-
// message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOC]!.sta.lin}:${
|
|
503
|
-
// token[LOC]!.sta.col
|
|
504
|
-
// }`,
|
|
505
|
-
// node: token,
|
|
506
|
-
// location: token[LOC],
|
|
507
|
-
// },
|
|
508
|
-
// ],
|
|
509
|
-
// };
|
|
510
|
-
// }
|
|
511
421
|
stack.push(token);
|
|
512
422
|
break;
|
|
513
423
|
case EnumToken.Pipe:
|
|
@@ -518,44 +428,14 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
518
428
|
case EnumToken.StartMatchTokenType:
|
|
519
429
|
case EnumToken.EndMatchTokenType:
|
|
520
430
|
case EnumToken.DashMatchTokenType:
|
|
521
|
-
// if (
|
|
522
|
-
// stack.at(-1)?.typ !== EnumToken.AttrStartTokenType &&
|
|
523
|
-
// !(
|
|
524
|
-
// stack.at(-1)?.typ === EnumToken.UniversalSelectorTokenType &&
|
|
525
|
-
// stack.at(-2)?.typ === EnumToken.AttrStartTokenType
|
|
526
|
-
// )
|
|
527
|
-
// ) {
|
|
528
|
-
// return {
|
|
529
|
-
// success: false,
|
|
530
|
-
// errors: [
|
|
531
|
-
// {
|
|
532
|
-
// action: "drop",
|
|
533
|
-
// message: `Unexpected token ${EnumToken[token.typ]} at ${token[LOC]!.src}:${token[LOC]!.sta.lin}:${
|
|
534
|
-
// token[LOC]!.sta.col
|
|
535
|
-
// }`,
|
|
536
|
-
// node: token,
|
|
537
|
-
// location: token[LOC],
|
|
538
|
-
// },
|
|
539
|
-
// ],
|
|
540
|
-
// };
|
|
541
|
-
// }
|
|
542
431
|
break;
|
|
543
|
-
// case EnumToken.Star:
|
|
544
|
-
// Object.assign(token, { typ: EnumToken.UniversalSelectorTokenType });
|
|
545
|
-
// break;
|
|
546
432
|
case EnumToken.IdenTokenType:
|
|
547
433
|
case EnumToken.HashTokenType:
|
|
548
434
|
case EnumToken.PseudoElementTokenType:
|
|
549
435
|
case EnumToken.PseudoClassTokenType:
|
|
550
436
|
case EnumToken.ClassSelectorTokenType:
|
|
551
|
-
// if (stack.at(-1)?.typ === EnumToken.CommaTokenType) {
|
|
552
|
-
// stack.pop();
|
|
553
|
-
// }
|
|
554
437
|
break;
|
|
555
438
|
case EnumToken.AttrStartTokenType:
|
|
556
|
-
// if (stack.at(-1)?.typ === EnumToken.CommaTokenType) {
|
|
557
|
-
// stack.pop();
|
|
558
|
-
// }
|
|
559
439
|
stack.push(token);
|
|
560
440
|
break;
|
|
561
441
|
case EnumToken.AttrEndTokenType:
|
|
@@ -568,9 +448,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
568
448
|
errors: [
|
|
569
449
|
{
|
|
570
450
|
action: "drop",
|
|
571
|
-
message: `Unexpected token ${EnumToken[token.typ]}
|
|
451
|
+
message: `Unexpected token ${EnumToken[token.typ]}`,
|
|
572
452
|
node: token,
|
|
573
|
-
|
|
453
|
+
// @ts-expect-error
|
|
454
|
+
location: options.source.getSourceLocation(token[LOC].sta),
|
|
574
455
|
},
|
|
575
456
|
],
|
|
576
457
|
};
|
|
@@ -587,150 +468,18 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
587
468
|
}
|
|
588
469
|
slice.push(tokens[n]);
|
|
589
470
|
}
|
|
590
|
-
// if (slice.length === 0) {
|
|
591
|
-
// return {
|
|
592
|
-
// success: false,
|
|
593
|
-
// errors: [
|
|
594
|
-
// {
|
|
595
|
-
// action: "drop",
|
|
596
|
-
// message: `Invalid selector attribute at ${token[LOC]!.src}:${token[LOC]!.sta.lin}:${
|
|
597
|
-
// token[LOC]!.sta.col
|
|
598
|
-
// }`,
|
|
599
|
-
// node: token,
|
|
600
|
-
// location: token[LOC],
|
|
601
|
-
// },
|
|
602
|
-
// ],
|
|
603
|
-
// };
|
|
604
|
-
// }
|
|
605
471
|
if (slice[1]?.typ === EnumToken.Pipe) {
|
|
606
|
-
// if (
|
|
607
|
-
// slice[0].typ !== EnumToken.UniversalSelectorTokenType &&
|
|
608
|
-
// slice[0].typ !== EnumToken.Star &&
|
|
609
|
-
// slice[0].typ !== EnumToken.IdenTokenType
|
|
610
|
-
// ) {
|
|
611
|
-
// return {
|
|
612
|
-
// success: false,
|
|
613
|
-
// errors: [
|
|
614
|
-
// {
|
|
615
|
-
// action: "drop",
|
|
616
|
-
// message: `Invalid selector attribute at ${token[LOC]!.src}:${token[LOC]!.sta.lin}:${
|
|
617
|
-
// token[LOC]!.sta.col
|
|
618
|
-
// }`,
|
|
619
|
-
// node: token,
|
|
620
|
-
// location: token[LOC],
|
|
621
|
-
// },
|
|
622
|
-
// ],
|
|
623
|
-
// };
|
|
624
|
-
// }
|
|
625
472
|
slice.shift();
|
|
626
473
|
}
|
|
627
474
|
if (slice[0].typ === EnumToken.Pipe) {
|
|
628
|
-
// if (slice.length === 1) {
|
|
629
|
-
// return {
|
|
630
|
-
// success: false,
|
|
631
|
-
// errors: [
|
|
632
|
-
// {
|
|
633
|
-
// action: "drop",
|
|
634
|
-
// message: `Invalid selector attribute at ${token[LOC]!.src}:${token[LOC]!.sta.lin}:${
|
|
635
|
-
// token[LOC]!.sta.col
|
|
636
|
-
// }`,
|
|
637
|
-
// node: token,
|
|
638
|
-
// location: token[LOC],
|
|
639
|
-
// },
|
|
640
|
-
// ],
|
|
641
|
-
// };
|
|
642
|
-
// }
|
|
643
|
-
// if (slice[1]?.typ !== EnumToken.IdenTokenType) {
|
|
644
|
-
// return {
|
|
645
|
-
// success: false,
|
|
646
|
-
// errors: [
|
|
647
|
-
// {
|
|
648
|
-
// action: "drop",
|
|
649
|
-
// message: `Invalid selector attribute at ${token[LOC]!.src}:${token[LOC]!.sta.lin}:${
|
|
650
|
-
// token[LOC]!.sta.col
|
|
651
|
-
// }`,
|
|
652
|
-
// node: token,
|
|
653
|
-
// location: token[LOC],
|
|
654
|
-
// },
|
|
655
|
-
// ],
|
|
656
|
-
// };
|
|
657
|
-
// }
|
|
658
475
|
slice.shift();
|
|
659
476
|
}
|
|
660
477
|
if (slice.length === 1) {
|
|
661
|
-
// if (slice[0].typ !== EnumToken.IdenTokenType) {
|
|
662
|
-
// return {
|
|
663
|
-
// success: false,
|
|
664
|
-
// errors: [
|
|
665
|
-
// {
|
|
666
|
-
// action: "drop",
|
|
667
|
-
// message: `Invalid selector attribute at ${token[LOC]!.src}:${token[LOC]!.sta.lin}:${
|
|
668
|
-
// token[LOC]!.sta.col
|
|
669
|
-
// }`,
|
|
670
|
-
// node: token,
|
|
671
|
-
// location: token[LOC],
|
|
672
|
-
// },
|
|
673
|
-
// ],
|
|
674
|
-
// };
|
|
675
|
-
// }
|
|
676
478
|
stack.pop();
|
|
677
479
|
break;
|
|
678
480
|
}
|
|
679
481
|
slice.shift();
|
|
680
|
-
// if (
|
|
681
|
-
// slice[0].typ != EnumToken.DelimTokenType &&
|
|
682
|
-
// slice[0].typ !== EnumToken.DashMatchTokenType &&
|
|
683
|
-
// slice[0].typ !== EnumToken.EndMatchTokenType &&
|
|
684
|
-
// slice[0].typ !== EnumToken.IncludeMatchTokenType &&
|
|
685
|
-
// slice[0].typ !== EnumToken.StartMatchTokenType &&
|
|
686
|
-
// slice[0].typ !== EnumToken.ContainMatchTokenType
|
|
687
|
-
// ) {
|
|
688
|
-
// return {
|
|
689
|
-
// success: false,
|
|
690
|
-
// errors: [
|
|
691
|
-
// {
|
|
692
|
-
// action: "drop",
|
|
693
|
-
// message: `Unexpected token ${EnumToken[slice[0].typ]} at ${slice[0][LOC]!.src}:${slice[0][LOC]!.sta.lin}:${
|
|
694
|
-
// slice[0][LOC]!.sta.col
|
|
695
|
-
// }`,
|
|
696
|
-
// node: slice[0],
|
|
697
|
-
// location: slice[0][LOC],
|
|
698
|
-
// },
|
|
699
|
-
// ],
|
|
700
|
-
// };
|
|
701
|
-
// }
|
|
702
482
|
slice.shift();
|
|
703
|
-
// if (slice.length === 0) {
|
|
704
|
-
// // expect iden or string
|
|
705
|
-
// return {
|
|
706
|
-
// success: false,
|
|
707
|
-
// errors: [
|
|
708
|
-
// {
|
|
709
|
-
// action: "drop",
|
|
710
|
-
// message: `Invalid selector attribute at ${slice[0][LOC]!.src}:${slice[0][LOC]!.sta.lin}:${
|
|
711
|
-
// slice[0][LOC]!.sta.col
|
|
712
|
-
// }`,
|
|
713
|
-
// node: slice[0],
|
|
714
|
-
// location: slice[0][LOC],
|
|
715
|
-
// },
|
|
716
|
-
// ],
|
|
717
|
-
// };
|
|
718
|
-
// }
|
|
719
|
-
// if (slice[0].typ !== EnumToken.IdenTokenType && slice[0].typ !== EnumToken.StringTokenType) {
|
|
720
|
-
// return {
|
|
721
|
-
// success: false,
|
|
722
|
-
// errors: [
|
|
723
|
-
// {
|
|
724
|
-
// action: "drop",
|
|
725
|
-
// message: `Unexpected token ${EnumToken[slice[0].typ]} at ${slice[0][LOC]!.src}:${slice[0][LOC]!.sta.lin}:${
|
|
726
|
-
// slice[0][LOC]!.sta.col
|
|
727
|
-
// }`,
|
|
728
|
-
// node: slice[0],
|
|
729
|
-
// location: slice[0][LOC],
|
|
730
|
-
// },
|
|
731
|
-
// ],
|
|
732
|
-
// };
|
|
733
|
-
// }
|
|
734
483
|
if (slice[0]?.typ === EnumToken.StringTokenType &&
|
|
735
484
|
/^[a-zA-Z0-9_-]+$/.test(slice[0].val.slice(1, -1))) {
|
|
736
485
|
Object.assign(slice[0], {
|
|
@@ -750,9 +499,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
750
499
|
errors: [
|
|
751
500
|
{
|
|
752
501
|
action: "drop",
|
|
753
|
-
message: `Unexpected token ${EnumToken[slice[0].typ]}
|
|
502
|
+
message: `Unexpected token ${EnumToken[slice[0].typ]}`,
|
|
754
503
|
node: slice[0],
|
|
755
|
-
|
|
504
|
+
// @ts-expect-error
|
|
505
|
+
location: options.source.getSourceLocation(slice[0][LOC].sta),
|
|
756
506
|
},
|
|
757
507
|
],
|
|
758
508
|
};
|
|
@@ -863,9 +613,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
863
613
|
errors: [
|
|
864
614
|
{
|
|
865
615
|
action: "drop",
|
|
866
|
-
message: `Unexpected token ${EnumToken[token.typ]}
|
|
616
|
+
message: `Unexpected token ${EnumToken[token.typ]}`,
|
|
867
617
|
node: token,
|
|
868
|
-
|
|
618
|
+
// @ts-expect-error
|
|
619
|
+
location: options.source.getSourceLocation(token[LOC].sta),
|
|
869
620
|
},
|
|
870
621
|
],
|
|
871
622
|
};
|
|
@@ -905,9 +656,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
905
656
|
errors: [
|
|
906
657
|
{
|
|
907
658
|
action: "drop",
|
|
908
|
-
message: `Unexpected token ${EnumToken[token.typ]}
|
|
659
|
+
message: `Unexpected token ${EnumToken[token.typ]}`,
|
|
909
660
|
node: token,
|
|
910
|
-
|
|
661
|
+
// @ts-expect-error
|
|
662
|
+
location: options.source.getSourceLocation(token[LOC].sta),
|
|
911
663
|
},
|
|
912
664
|
],
|
|
913
665
|
};
|
|
@@ -926,9 +678,10 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
926
678
|
errors: [
|
|
927
679
|
{
|
|
928
680
|
action: "drop",
|
|
929
|
-
message: `Unsupported selector token ${EnumToken[token.typ]}
|
|
681
|
+
message: `Unsupported selector token ${EnumToken[token.typ]}`,
|
|
930
682
|
node: token,
|
|
931
|
-
|
|
683
|
+
// @ts-expect-error
|
|
684
|
+
location: options.source.getSourceLocation(token[LOC].sta),
|
|
932
685
|
},
|
|
933
686
|
],
|
|
934
687
|
};
|
|
@@ -951,23 +704,16 @@ function matchSelectorSyntax(stream, errors, options, nested = true) {
|
|
|
951
704
|
errors: [
|
|
952
705
|
{
|
|
953
706
|
action: "drop",
|
|
954
|
-
message: `Unmatched token ${EnumToken[stack.at(-1).typ]}
|
|
707
|
+
message: `Unmatched token ${EnumToken[stack.at(-1).typ]}`,
|
|
955
708
|
node: stack.at(-1),
|
|
956
|
-
|
|
709
|
+
// @ts-expect-error
|
|
710
|
+
location: options.source.getSourceLocation(stack.at(-1)[LOC].sta),
|
|
957
711
|
},
|
|
958
712
|
],
|
|
959
713
|
};
|
|
960
714
|
}
|
|
961
715
|
stream.length = 0;
|
|
962
716
|
stream.push(...tokens);
|
|
963
|
-
// if (!success && errors.length === 0) {
|
|
964
|
-
// errors.push({
|
|
965
|
-
// action: "drop",
|
|
966
|
-
// message: "Invalid selector",
|
|
967
|
-
// node: tokens[0],
|
|
968
|
-
// location: tokens[0][LOC]!,
|
|
969
|
-
// });
|
|
970
|
-
// }
|
|
971
717
|
return { success, errors };
|
|
972
718
|
}
|
|
973
719
|
function matchAllSyntaxes(syntaxes, context, options) {
|
|
@@ -975,28 +721,6 @@ function matchAllSyntaxes(syntaxes, context, options) {
|
|
|
975
721
|
...options,
|
|
976
722
|
visited: new Map(),
|
|
977
723
|
});
|
|
978
|
-
// if (result.success && !result.context.done()) {
|
|
979
|
-
// const node = result.context.peek() as Token;
|
|
980
|
-
// return {
|
|
981
|
-
// ...result,
|
|
982
|
-
// success: false,
|
|
983
|
-
// token: context.peek(),
|
|
984
|
-
// errors: [
|
|
985
|
-
// ...result.errors,
|
|
986
|
-
// {
|
|
987
|
-
// action: "drop",
|
|
988
|
-
// message: `Unexpected token ${EnumToken[node?.typ]} at ${node![LOC]?.src}:${node![LOC]?.sta?.lin}:${
|
|
989
|
-
// node![LOC]?.sta?.col
|
|
990
|
-
// }`,
|
|
991
|
-
// node,
|
|
992
|
-
// syntax:
|
|
993
|
-
// result.syntaxToken ??
|
|
994
|
-
// syntaxes?.reduce?.((acc, b) => acc + renderSyntax(b), "")?.trim?.() ??
|
|
995
|
-
// null,
|
|
996
|
-
// },
|
|
997
|
-
// ],
|
|
998
|
-
// };
|
|
999
|
-
// }
|
|
1000
724
|
if (syntaxes != null && result.success && result.syntaxToken != null) {
|
|
1001
725
|
const index = syntaxes.indexOf(result.syntaxToken);
|
|
1002
726
|
if (index != -1) {
|
|
@@ -1006,9 +730,6 @@ function matchAllSyntaxes(syntaxes, context, options) {
|
|
|
1006
730
|
syntaxes[i].isRepeatable) {
|
|
1007
731
|
continue;
|
|
1008
732
|
}
|
|
1009
|
-
// if (syntaxes[i].typ == ValidationTokenEnum.SemiColon && i === syntaxes.length - 1) {
|
|
1010
|
-
// continue;
|
|
1011
|
-
// }
|
|
1012
733
|
return {
|
|
1013
734
|
...result,
|
|
1014
735
|
success: false,
|
|
@@ -1026,7 +747,7 @@ function matchAllSyntaxes(syntaxes, context, options) {
|
|
|
1026
747
|
message: result.errors[0]?.message || "could not match syntax",
|
|
1027
748
|
node: result.token,
|
|
1028
749
|
syntax: result.syntaxToken,
|
|
1029
|
-
location: result.token?.[LOC] ?? context.tokens.at(-1)?.[LOC],
|
|
750
|
+
location: options.source.getSourceLocation((result.token?.[LOC] ?? context.tokens.at(-1)?.[LOC]).sta),
|
|
1030
751
|
},
|
|
1031
752
|
]
|
|
1032
753
|
: result.errors,
|
|
@@ -1061,22 +782,6 @@ function matchListSyntax(syntax, context, options) {
|
|
|
1061
782
|
}
|
|
1062
783
|
}
|
|
1063
784
|
} while (tmpResult.success && !context.done());
|
|
1064
|
-
// if (result?.success && match != null) {
|
|
1065
|
-
// if (count < match.min!.val || (Number.isFinite(match.max) && count > (match.max!.val as number))) {
|
|
1066
|
-
// return {
|
|
1067
|
-
// ...result,
|
|
1068
|
-
// success: false,
|
|
1069
|
-
// errors: [
|
|
1070
|
-
// {
|
|
1071
|
-
// action: "drop",
|
|
1072
|
-
// message: "could not match syntax",
|
|
1073
|
-
// node: context.peek(),
|
|
1074
|
-
// location: context.peek()?.[LOC]!,
|
|
1075
|
-
// },
|
|
1076
|
-
// ],
|
|
1077
|
-
// };
|
|
1078
|
-
// }
|
|
1079
|
-
// }
|
|
1080
785
|
return result == null
|
|
1081
786
|
? {
|
|
1082
787
|
success: false,
|
|
@@ -1123,7 +828,7 @@ function matchOccurenceSyntax(syntax, context, options) {
|
|
|
1123
828
|
action: "drop",
|
|
1124
829
|
message: "could not match syntax",
|
|
1125
830
|
node: context.peek(),
|
|
1126
|
-
location: context.peek()?.[LOC],
|
|
831
|
+
// location: options.source!.getSourceLocation(context.peek()?.[LOC]!.sta),
|
|
1127
832
|
},
|
|
1128
833
|
],
|
|
1129
834
|
syntaxToken: null,
|
|
@@ -1200,20 +905,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1200
905
|
context.next();
|
|
1201
906
|
continue;
|
|
1202
907
|
}
|
|
1203
|
-
// return {
|
|
1204
|
-
// ...result,
|
|
1205
|
-
// success: false,
|
|
1206
|
-
// token,
|
|
1207
|
-
// syntaxToken: syntaxes[i],
|
|
1208
|
-
// errors: [
|
|
1209
|
-
// {
|
|
1210
|
-
// action: "drop",
|
|
1211
|
-
// message: "could not match syntax",
|
|
1212
|
-
// node: context.peek(),
|
|
1213
|
-
// location: context.peek()![LOC]!,
|
|
1214
|
-
// },
|
|
1215
|
-
// ],
|
|
1216
|
-
// };
|
|
1217
908
|
}
|
|
1218
909
|
// custom function token
|
|
1219
910
|
if (token.typ === EnumToken.CustomFunctionTokenDefType) {
|
|
@@ -1264,10 +955,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1264
955
|
}
|
|
1265
956
|
continue;
|
|
1266
957
|
}
|
|
1267
|
-
// if (isOptional) {
|
|
1268
|
-
// continue;
|
|
1269
|
-
// }
|
|
1270
|
-
// return result;
|
|
1271
958
|
}
|
|
1272
959
|
if (syntaxes[i].isRepeatableAtLeastOnce || syntaxes[i].isRepeatable) {
|
|
1273
960
|
result = matchRepeatableSyntax(syntaxes[i], context.slice(), options);
|
|
@@ -1279,9 +966,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1279
966
|
context.update(result.context.current());
|
|
1280
967
|
continue;
|
|
1281
968
|
}
|
|
1282
|
-
// if (isOptional) {
|
|
1283
|
-
// continue;
|
|
1284
|
-
// }
|
|
1285
969
|
return result;
|
|
1286
970
|
}
|
|
1287
971
|
if (syntaxes[i].isList) {
|
|
@@ -1300,27 +984,8 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1300
984
|
};
|
|
1301
985
|
}
|
|
1302
986
|
context.update(result.context.current());
|
|
1303
|
-
// let k = i + 1;
|
|
1304
|
-
// for (; k < syntaxes.length; k++) {
|
|
1305
|
-
// if (syntaxes[k].typ !== ValidationTokenEnum.Whitespace) {
|
|
1306
|
-
// break;
|
|
1307
|
-
// }
|
|
1308
|
-
// if (syntaxes[k]?.typ === ValidationTokenEnum.Comma) {
|
|
1309
|
-
// i = k;
|
|
1310
|
-
// }
|
|
1311
|
-
// }
|
|
1312
987
|
continue;
|
|
1313
988
|
}
|
|
1314
|
-
// if (isOptional) {
|
|
1315
|
-
// // eat the next ','
|
|
1316
|
-
// if (
|
|
1317
|
-
// syntaxes[i + 1]?.typ === ValidationTokenEnum.Whitespace ||
|
|
1318
|
-
// syntaxes[i + 1]?.typ === ValidationTokenEnum.Comma
|
|
1319
|
-
// ) {
|
|
1320
|
-
// i++;
|
|
1321
|
-
// }
|
|
1322
|
-
// continue;
|
|
1323
|
-
// }
|
|
1324
989
|
return {
|
|
1325
990
|
success: false,
|
|
1326
991
|
valid: true,
|
|
@@ -1345,16 +1010,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1345
1010
|
context.update(result.context.current());
|
|
1346
1011
|
continue;
|
|
1347
1012
|
}
|
|
1348
|
-
// if (isOptional) {
|
|
1349
|
-
// // eat the next ','
|
|
1350
|
-
// if (syntaxes[i + 1]?.typ === ValidationTokenEnum.Whitespace) {
|
|
1351
|
-
// i++;
|
|
1352
|
-
// }
|
|
1353
|
-
// if (syntaxes[i + 1]?.typ === ValidationTokenEnum.Comma) {
|
|
1354
|
-
// i++;
|
|
1355
|
-
// }
|
|
1356
|
-
// continue;
|
|
1357
|
-
// }
|
|
1358
1013
|
return {
|
|
1359
1014
|
success: false,
|
|
1360
1015
|
valid: true,
|
|
@@ -1386,21 +1041,8 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1386
1041
|
success = true;
|
|
1387
1042
|
options.visited.get(token).delete(syntaxes[i]);
|
|
1388
1043
|
context.next();
|
|
1389
|
-
// if (context.done()) {
|
|
1390
|
-
// return {
|
|
1391
|
-
// success: true,
|
|
1392
|
-
// valid: true,
|
|
1393
|
-
// token: null,
|
|
1394
|
-
// context,
|
|
1395
|
-
// syntaxToken: syntaxes[i + 1],
|
|
1396
|
-
// errors: [],
|
|
1397
|
-
// };
|
|
1398
|
-
// }
|
|
1399
1044
|
break;
|
|
1400
1045
|
}
|
|
1401
|
-
// if (isOptional) {
|
|
1402
|
-
// break;
|
|
1403
|
-
// }
|
|
1404
1046
|
return {
|
|
1405
1047
|
success: false,
|
|
1406
1048
|
valid: true,
|
|
@@ -1409,34 +1051,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1409
1051
|
syntaxToken: syntaxes[i],
|
|
1410
1052
|
errors: [],
|
|
1411
1053
|
};
|
|
1412
|
-
// case ValidationTokenEnum.Colon:
|
|
1413
|
-
// if (token.typ == EnumToken.ColonTokenType) {
|
|
1414
|
-
// success = true;
|
|
1415
|
-
// (options.visited!.get(token) as Set<ValidationToken>)!.delete(syntaxes[i]);
|
|
1416
|
-
// context.next();
|
|
1417
|
-
// if (context.done()) {
|
|
1418
|
-
// return {
|
|
1419
|
-
// success: true,
|
|
1420
|
-
// valid: true,
|
|
1421
|
-
// token: null,
|
|
1422
|
-
// context,
|
|
1423
|
-
// syntaxToken: syntaxes[i + 1],
|
|
1424
|
-
// errors: [],
|
|
1425
|
-
// };
|
|
1426
|
-
// }
|
|
1427
|
-
// break;
|
|
1428
|
-
// }
|
|
1429
|
-
// if (isOptional) {
|
|
1430
|
-
// break;
|
|
1431
|
-
// }
|
|
1432
|
-
// return {
|
|
1433
|
-
// success: false,
|
|
1434
|
-
// valid: true,
|
|
1435
|
-
// token,
|
|
1436
|
-
// context,
|
|
1437
|
-
// syntaxToken: syntaxes[i],
|
|
1438
|
-
// errors: [],
|
|
1439
|
-
// };
|
|
1440
1054
|
case ValidationTokenEnum.Keyword:
|
|
1441
1055
|
if (token.typ == EnumToken.IdenTokenType &&
|
|
1442
1056
|
token.val.toLowerCase() ===
|
|
@@ -1504,38 +1118,10 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1504
1118
|
}
|
|
1505
1119
|
break;
|
|
1506
1120
|
}
|
|
1507
|
-
// case ValidationTokenEnum.AtRule:
|
|
1508
|
-
// if (token.typ == EnumToken.AtRuleTokenType) {
|
|
1509
|
-
// success = true;
|
|
1510
|
-
// (options.visited!.get(token) as Set<ValidationToken>)!.delete(syntaxes[i]);
|
|
1511
|
-
// context.next();
|
|
1512
|
-
// break;
|
|
1513
|
-
// }
|
|
1514
|
-
// if (isOptional) {
|
|
1515
|
-
// break;
|
|
1516
|
-
// }
|
|
1517
|
-
// return {
|
|
1518
|
-
// success: false,
|
|
1519
|
-
// valid: true,
|
|
1520
|
-
// token,
|
|
1521
|
-
// context,
|
|
1522
|
-
// syntaxToken: syntaxes[i],
|
|
1523
|
-
// errors: [],
|
|
1524
|
-
// };
|
|
1525
1121
|
case ValidationTokenEnum.StringToken:
|
|
1526
|
-
// if (token.typ == EnumToken.StringTokenType || token.typ == EnumToken.UrlFunctionTokenType) {
|
|
1527
|
-
// success = true;
|
|
1528
|
-
// } else if (token.typ === EnumToken.StringTokenType) {
|
|
1529
|
-
// success = (token as StringToken).val === (syntaxes[i] as ValidationStringToken).val.slice(1, -1);
|
|
1530
|
-
// } else
|
|
1531
1122
|
if (token.typ === EnumToken.Add) {
|
|
1532
1123
|
success = syntaxes[i].val.slice(1, -1) === "+";
|
|
1533
1124
|
}
|
|
1534
|
-
// else if (token.typ === EnumToken.Mul) {
|
|
1535
|
-
// success = (syntaxes[i] as ValidationStringToken).val.slice(1, -1) === "*";
|
|
1536
|
-
// } else if (token.typ === EnumToken.Div) {
|
|
1537
|
-
// success = (syntaxes[i] as ValidationStringToken).val.slice(1, -1) === "/";
|
|
1538
|
-
// }
|
|
1539
1125
|
else if (token.typ === EnumToken.Sub) {
|
|
1540
1126
|
success = syntaxes[i].val.slice(1, -1) === "-";
|
|
1541
1127
|
}
|
|
@@ -1560,24 +1146,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1560
1146
|
syntaxToken: syntaxes[i],
|
|
1561
1147
|
errors: [],
|
|
1562
1148
|
};
|
|
1563
|
-
// case ValidationTokenEnum.SemiColon:
|
|
1564
|
-
// if (token.typ == EnumToken.SemiColonTokenType) {
|
|
1565
|
-
// success = true;
|
|
1566
|
-
// (options.visited!.get(token) as Set<ValidationToken>)!.delete(syntaxes[i]);
|
|
1567
|
-
// context.next();
|
|
1568
|
-
// break;
|
|
1569
|
-
// }
|
|
1570
|
-
// if (isOptional) {
|
|
1571
|
-
// break;
|
|
1572
|
-
// }
|
|
1573
|
-
// return {
|
|
1574
|
-
// success: false,
|
|
1575
|
-
// valid: true,
|
|
1576
|
-
// token,
|
|
1577
|
-
// context,
|
|
1578
|
-
// syntaxToken: syntaxes[i],
|
|
1579
|
-
// errors: [],
|
|
1580
|
-
// };
|
|
1581
1149
|
case ValidationTokenEnum.PropertyType:
|
|
1582
1150
|
result = matchProperty(syntaxes[i], context, options);
|
|
1583
1151
|
if (!result.success) {
|
|
@@ -1631,25 +1199,10 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1631
1199
|
if (result?.success) {
|
|
1632
1200
|
success = true;
|
|
1633
1201
|
options.visited.get(token).delete(syntaxes[i]);
|
|
1634
|
-
// if (result!.context.done()) {
|
|
1635
|
-
// context.end();
|
|
1636
|
-
// return {
|
|
1637
|
-
// success: true,
|
|
1638
|
-
// valid: true,
|
|
1639
|
-
// token: null,
|
|
1640
|
-
// context,
|
|
1641
|
-
// syntaxToken: syntaxes[i + 1],
|
|
1642
|
-
// errors: [],
|
|
1643
|
-
// };
|
|
1644
|
-
// } else {
|
|
1645
1202
|
context.update(result.context.current());
|
|
1646
|
-
// }
|
|
1647
1203
|
break;
|
|
1648
1204
|
}
|
|
1649
1205
|
}
|
|
1650
|
-
// if (isOptional) {
|
|
1651
|
-
// break;
|
|
1652
|
-
// }
|
|
1653
1206
|
return {
|
|
1654
1207
|
success: false,
|
|
1655
1208
|
valid: true,
|
|
@@ -1661,7 +1214,8 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1661
1214
|
action: "drop",
|
|
1662
1215
|
message: "could not match syntax",
|
|
1663
1216
|
node: token,
|
|
1664
|
-
|
|
1217
|
+
// @ts-ignore
|
|
1218
|
+
// location: options.source!.getSourceLocation(token[LOC]?.sta),
|
|
1665
1219
|
syntax: syntaxes[i],
|
|
1666
1220
|
},
|
|
1667
1221
|
],
|
|
@@ -1719,9 +1273,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1719
1273
|
}
|
|
1720
1274
|
break;
|
|
1721
1275
|
}
|
|
1722
|
-
// if (isOptional) {
|
|
1723
|
-
// break;
|
|
1724
|
-
// }
|
|
1725
1276
|
return {
|
|
1726
1277
|
success: false,
|
|
1727
1278
|
valid: true,
|
|
@@ -1751,9 +1302,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1751
1302
|
}
|
|
1752
1303
|
break;
|
|
1753
1304
|
}
|
|
1754
|
-
// if (isOptional) {
|
|
1755
|
-
// break;
|
|
1756
|
-
// }
|
|
1757
1305
|
return {
|
|
1758
1306
|
success: false,
|
|
1759
1307
|
valid: true,
|
|
@@ -1762,47 +1310,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1762
1310
|
syntaxToken: syntaxes[i],
|
|
1763
1311
|
errors: [],
|
|
1764
1312
|
};
|
|
1765
|
-
// case ValidationTokenEnum.PseudoClassFunctionToken:
|
|
1766
|
-
// if (!((token as PseudoClassFunctionToken).val + "()" in config.selectors)) {
|
|
1767
|
-
// return {
|
|
1768
|
-
// success: false,
|
|
1769
|
-
// valid: true,
|
|
1770
|
-
// token,
|
|
1771
|
-
// context,
|
|
1772
|
-
// syntaxToken: syntaxes[i],
|
|
1773
|
-
// errors: [
|
|
1774
|
-
// {
|
|
1775
|
-
// action: "drop",
|
|
1776
|
-
// message: `Unknown pseudo-class selector ${(token as PseudoClassFunctionToken).val}()`,
|
|
1777
|
-
// node: token,
|
|
1778
|
-
// },
|
|
1779
|
-
// ],
|
|
1780
|
-
// };
|
|
1781
|
-
// }
|
|
1782
|
-
// result = matchSyntax(
|
|
1783
|
-
// ((
|
|
1784
|
-
// getParsedSyntax(
|
|
1785
|
-
// ValidationSyntaxGroupEnum.Selectors,
|
|
1786
|
-
// (token as PseudoClassFunctionToken).val + "()",
|
|
1787
|
-
// ) as [ValidationPseudoClassFunctionToken]
|
|
1788
|
-
// )?.[0]?.chi as ValidationToken[]) ?? [],
|
|
1789
|
-
// createValidationContext((token as PseudoClassFunctionToken).chi),
|
|
1790
|
-
// options,
|
|
1791
|
-
// );
|
|
1792
|
-
// if (result.success) {
|
|
1793
|
-
// success = true;
|
|
1794
|
-
// (options.visited!.get(token) as Set<ValidationToken>)!.delete(syntaxes[i]);
|
|
1795
|
-
// context.next();
|
|
1796
|
-
// break;
|
|
1797
|
-
// }
|
|
1798
|
-
// return {
|
|
1799
|
-
// success: false,
|
|
1800
|
-
// valid: true,
|
|
1801
|
-
// token,
|
|
1802
|
-
// context,
|
|
1803
|
-
// syntaxToken: syntaxes[i],
|
|
1804
|
-
// errors: result.errors,
|
|
1805
|
-
// };
|
|
1806
1313
|
case ValidationTokenEnum.Function:
|
|
1807
1314
|
if ((!tokensfuncDefMap.has(token.typ) &&
|
|
1808
1315
|
!funcLike.includes(token.typ) &&
|
|
@@ -1826,23 +1333,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1826
1333
|
}
|
|
1827
1334
|
if (tokensfuncDefMap.has(token.typ)) {
|
|
1828
1335
|
const range = context.peekRange();
|
|
1829
|
-
// if (range.at(-1)?.typ !== EnumToken.EndParensTokenType) {
|
|
1830
|
-
// const tk = range.at(-1) as Token;
|
|
1831
|
-
// return {
|
|
1832
|
-
// success: false,
|
|
1833
|
-
// valid: true,
|
|
1834
|
-
// token,
|
|
1835
|
-
// context,
|
|
1836
|
-
// syntaxToken: syntaxes[i],
|
|
1837
|
-
// errors: [
|
|
1838
|
-
// {
|
|
1839
|
-
// action: "drop",
|
|
1840
|
-
// message: `Expecting ')' at ${tk[LOC]?.src}:${tk[LOC]?.sta?.lin}:${tk[LOC]?.sta?.col}`,
|
|
1841
|
-
// node: token,
|
|
1842
|
-
// },
|
|
1843
|
-
// ],
|
|
1844
|
-
// };
|
|
1845
|
-
// }
|
|
1846
1336
|
result = matchSyntax(syntaxes[i].chi, createValidationContext(range.slice(1, -1)), options);
|
|
1847
1337
|
if (result.success && result.context.done()) {
|
|
1848
1338
|
context.update(range.at(-1));
|
|
@@ -1859,9 +1349,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1859
1349
|
break;
|
|
1860
1350
|
}
|
|
1861
1351
|
}
|
|
1862
|
-
// if (isOptional) {
|
|
1863
|
-
// break;
|
|
1864
|
-
// }
|
|
1865
1352
|
return {
|
|
1866
1353
|
success: false,
|
|
1867
1354
|
valid: true,
|
|
@@ -1870,20 +1357,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1870
1357
|
syntaxToken: syntaxes[i],
|
|
1871
1358
|
errors: result.errors,
|
|
1872
1359
|
};
|
|
1873
|
-
// case ValidationTokenEnum.LessThan:
|
|
1874
|
-
// if (token.typ === EnumToken.LtTokenType) {
|
|
1875
|
-
// (options.visited!.get(token) as Set<ValidationToken>)!.delete(syntaxes[i]);
|
|
1876
|
-
// context.next();
|
|
1877
|
-
// break;
|
|
1878
|
-
// }
|
|
1879
|
-
// return {
|
|
1880
|
-
// success: false,
|
|
1881
|
-
// valid: true,
|
|
1882
|
-
// token,
|
|
1883
|
-
// context,
|
|
1884
|
-
// syntaxToken: syntaxes[i],
|
|
1885
|
-
// errors: [],
|
|
1886
|
-
// };
|
|
1887
1360
|
case ValidationTokenEnum.Separator:
|
|
1888
1361
|
if (token.typ === EnumToken.LiteralTokenType && token.val === "/") {
|
|
1889
1362
|
options.visited.get(token).delete(syntaxes[i]);
|
|
@@ -1934,9 +1407,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1934
1407
|
context.next();
|
|
1935
1408
|
break;
|
|
1936
1409
|
}
|
|
1937
|
-
// if (isOptional) {
|
|
1938
|
-
// break;
|
|
1939
|
-
// }
|
|
1940
1410
|
return {
|
|
1941
1411
|
success: false,
|
|
1942
1412
|
valid: true,
|
|
@@ -1951,9 +1421,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1951
1421
|
context.next();
|
|
1952
1422
|
break;
|
|
1953
1423
|
}
|
|
1954
|
-
// if (isOptional) {
|
|
1955
|
-
// break;
|
|
1956
|
-
// }
|
|
1957
1424
|
return {
|
|
1958
1425
|
success: false,
|
|
1959
1426
|
valid: true,
|
|
@@ -1962,53 +1429,6 @@ function matchSyntax(syntaxes, context, options) {
|
|
|
1962
1429
|
syntaxToken: syntaxes[i],
|
|
1963
1430
|
errors: [],
|
|
1964
1431
|
};
|
|
1965
|
-
// case ValidationTokenEnum.DeclarationNameToken:
|
|
1966
|
-
// result = matchSyntax(
|
|
1967
|
-
// (getParsedSyntax(
|
|
1968
|
-
// ValidationSyntaxGroupEnum.Declarations,
|
|
1969
|
-
// (syntaxes[i] as ValidationDeclarationToken).val,
|
|
1970
|
-
// ) as ValidationFunctionToken[] as ValidationToken[]) ?? [],
|
|
1971
|
-
// context.slice(),
|
|
1972
|
-
// options,
|
|
1973
|
-
// );
|
|
1974
|
-
// if (!result.success) {
|
|
1975
|
-
// return {
|
|
1976
|
-
// success: false,
|
|
1977
|
-
// valid: true,
|
|
1978
|
-
// token,
|
|
1979
|
-
// context,
|
|
1980
|
-
// syntaxToken: syntaxes[i],
|
|
1981
|
-
// errors: result.errors,
|
|
1982
|
-
// };
|
|
1983
|
-
// }
|
|
1984
|
-
// success = true;
|
|
1985
|
-
// (options.visited!.get(token) as Set<ValidationToken>)!.delete(syntaxes[i]);
|
|
1986
|
-
// if (result.context.done()) {
|
|
1987
|
-
// context.end();
|
|
1988
|
-
// return {
|
|
1989
|
-
// success,
|
|
1990
|
-
// valid: true,
|
|
1991
|
-
// token: null,
|
|
1992
|
-
// context,
|
|
1993
|
-
// syntaxToken: syntaxes[1 + i],
|
|
1994
|
-
// errors: [],
|
|
1995
|
-
// };
|
|
1996
|
-
// } else {
|
|
1997
|
-
// context.update(result.context.current() as Token);
|
|
1998
|
-
// }
|
|
1999
|
-
// break;
|
|
2000
|
-
// case ValidationTokenEnum.DisallowWhitespace:
|
|
2001
|
-
// if (context.peek(0, false)?.typ === EnumToken.WhitespaceTokenType) {
|
|
2002
|
-
// return {
|
|
2003
|
-
// success: false,
|
|
2004
|
-
// valid: true,
|
|
2005
|
-
// token,
|
|
2006
|
-
// context,
|
|
2007
|
-
// syntaxToken: syntaxes[i],
|
|
2008
|
-
// errors: [],
|
|
2009
|
-
// };
|
|
2010
|
-
// }
|
|
2011
|
-
// break;
|
|
2012
1432
|
default:
|
|
2013
1433
|
throw new Error(`Unexpected syntax ${ValidationTokenEnum[syntaxes[i].typ]}`);
|
|
2014
1434
|
}
|
|
@@ -2174,17 +1594,6 @@ function matchProperty(property, context, options) {
|
|
|
2174
1594
|
};
|
|
2175
1595
|
}
|
|
2176
1596
|
switch (property.val) {
|
|
2177
|
-
// case "combinator":
|
|
2178
|
-
// {
|
|
2179
|
-
// const token = context.peek() as Token;
|
|
2180
|
-
// success =
|
|
2181
|
-
// token != null &&
|
|
2182
|
-
// (token.typ == EnumToken.NextSiblingCombinatorTokenType ||
|
|
2183
|
-
// token.typ == EnumToken.ChildCombinatorTokenType ||
|
|
2184
|
-
// token.typ == EnumToken.SubsequentSiblingCombinatorTokenType ||
|
|
2185
|
-
// token.typ == EnumToken.ColumnCombinatorTokenType);
|
|
2186
|
-
// }
|
|
2187
|
-
// break;
|
|
2188
1597
|
case "declaration-value":
|
|
2189
1598
|
{
|
|
2190
1599
|
// consume a declaration value
|
|
@@ -2195,41 +1604,9 @@ function matchProperty(property, context, options) {
|
|
|
2195
1604
|
let expectToken = true;
|
|
2196
1605
|
let token;
|
|
2197
1606
|
token = context.peek();
|
|
2198
|
-
// if (token?.typ == EnumToken.WhitespaceTokenType) {
|
|
2199
|
-
// context.next();
|
|
2200
|
-
// token = context.peek();
|
|
2201
|
-
// }
|
|
2202
|
-
// if (token?.typ == EnumToken.CommentTokenType) {
|
|
2203
|
-
// context.next();
|
|
2204
|
-
// token = context.peek();
|
|
2205
|
-
// }
|
|
2206
|
-
// if (token?.typ == EnumToken.CommaTokenType) {
|
|
2207
|
-
// context.next();
|
|
2208
|
-
// expectToken = true;
|
|
2209
|
-
// }
|
|
2210
1607
|
while ((token = context.peek()) != null) {
|
|
2211
1608
|
if (token.typ == EnumToken.StartParensTokenType || tokensfuncDefMap.has(token?.typ)) ;
|
|
2212
|
-
// if (token.typ == EnumToken.WhitespaceTokenType || token.typ == EnumToken.CommentTokenType) {
|
|
2213
|
-
// context.next();
|
|
2214
|
-
// }
|
|
2215
1609
|
if (expectToken) {
|
|
2216
|
-
// if (token?.typ == EnumToken.CommaTokenType || token.typ == EnumToken.EndParensTokenType) {
|
|
2217
|
-
// return {
|
|
2218
|
-
// success: false,
|
|
2219
|
-
// valid: true,
|
|
2220
|
-
// token,
|
|
2221
|
-
// context,
|
|
2222
|
-
// syntaxToken: property,
|
|
2223
|
-
// errors: [
|
|
2224
|
-
// {
|
|
2225
|
-
// action: "drop",
|
|
2226
|
-
// message: `Unexpected token ${EnumToken[token?.typ]} at ${token![LOC]?.src}:${token![LOC]?.sta?.lin}:${token![LOC]?.sta?.col}`,
|
|
2227
|
-
// node: token,
|
|
2228
|
-
// location: token[LOC],
|
|
2229
|
-
// },
|
|
2230
|
-
// ],
|
|
2231
|
-
// };
|
|
2232
|
-
// }
|
|
2233
1610
|
expectToken = false;
|
|
2234
1611
|
}
|
|
2235
1612
|
if (token.typ == EnumToken.CommaTokenType) {
|
|
@@ -2237,48 +1614,11 @@ function matchProperty(property, context, options) {
|
|
|
2237
1614
|
}
|
|
2238
1615
|
context.next();
|
|
2239
1616
|
}
|
|
2240
|
-
// if (stack.length > 0) {
|
|
2241
|
-
// token = stack.at(-1) as Token;
|
|
2242
|
-
// return {
|
|
2243
|
-
// success: false,
|
|
2244
|
-
// valid: true,
|
|
2245
|
-
// token,
|
|
2246
|
-
// context,
|
|
2247
|
-
// syntaxToken: property,
|
|
2248
|
-
// errors: [
|
|
2249
|
-
// {
|
|
2250
|
-
// action: "drop",
|
|
2251
|
-
// message: `unbalanced parentheses ${EnumToken[token?.typ]} at ${token![LOC]?.src}:${token![LOC]?.sta?.lin}:${token![LOC]?.sta?.col}`,
|
|
2252
|
-
// node: token,
|
|
2253
|
-
// location: token[LOC],
|
|
2254
|
-
// },
|
|
2255
|
-
// ],
|
|
2256
|
-
// };
|
|
2257
|
-
// }
|
|
2258
1617
|
success = !expectToken;
|
|
2259
|
-
// if (!success) {
|
|
2260
|
-
// return {
|
|
2261
|
-
// success: false,
|
|
2262
|
-
// valid: true,
|
|
2263
|
-
// token: token ?? context.current(),
|
|
2264
|
-
// context,
|
|
2265
|
-
// syntaxToken: property,
|
|
2266
|
-
// errors: [],
|
|
2267
|
-
// };
|
|
2268
|
-
// }
|
|
2269
1618
|
}
|
|
2270
1619
|
break;
|
|
2271
1620
|
case "calc-sum": {
|
|
2272
1621
|
const token = context.peek();
|
|
2273
|
-
// if (token?.typ === EnumToken.ParensTokenType) {
|
|
2274
|
-
// const result = matchSyntax(
|
|
2275
|
-
// (getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, "calc()") as ValidationFunctionToken[])[0].chi,
|
|
2276
|
-
// createValidationContext((token as ParensToken).chi),
|
|
2277
|
-
// options,
|
|
2278
|
-
// );
|
|
2279
|
-
// success = result.success && result.context.done();
|
|
2280
|
-
// break;
|
|
2281
|
-
// }
|
|
2282
1622
|
if (token?.typ === EnumToken.BinaryExpressionTokenType) {
|
|
2283
1623
|
let result = matchSyntax(getParsedSyntax(ValidationSyntaxGroupEnum.Syntaxes, "calc-sum"), createValidationContext([token.l]), options);
|
|
2284
1624
|
if (result.success) {
|
|
@@ -2313,16 +1653,6 @@ function matchProperty(property, context, options) {
|
|
|
2313
1653
|
case "an+b":
|
|
2314
1654
|
{
|
|
2315
1655
|
let token = context.peek();
|
|
2316
|
-
// if (token == null) {
|
|
2317
|
-
// return {
|
|
2318
|
-
// success: false,
|
|
2319
|
-
// valid: true,
|
|
2320
|
-
// token: null,
|
|
2321
|
-
// context,
|
|
2322
|
-
// syntaxToken: property,
|
|
2323
|
-
// errors: [],
|
|
2324
|
-
// };
|
|
2325
|
-
// }
|
|
2326
1656
|
if (token.typ === EnumToken.IdenTokenType &&
|
|
2327
1657
|
("even" === token.val || "odd" === token.val)) {
|
|
2328
1658
|
success = true;
|
|
@@ -2337,18 +1667,6 @@ function matchProperty(property, context, options) {
|
|
|
2337
1667
|
if (token.typ === EnumToken.LiteralTokenType || token.typ === EnumToken.IdenTokenType) {
|
|
2338
1668
|
let match = /^(([+-]?[0-9]*)?n)?([+-]?[0-9]+)?$/.exec(token.val);
|
|
2339
1669
|
success = match != null;
|
|
2340
|
-
// if (!success) {
|
|
2341
|
-
// success = /^(([+-]?[0-9]*)?n)?([+-])?$/.test((token as LiteralToken).val);
|
|
2342
|
-
// if (success) {
|
|
2343
|
-
// token = context.peek(1) as Token;
|
|
2344
|
-
// success =
|
|
2345
|
-
// token?.typ === EnumToken.NumberTokenType &&
|
|
2346
|
-
// Number.isInteger((token as NumberToken).val) &&
|
|
2347
|
-
// !(token as NumberToken).toString().includes(".") &&
|
|
2348
|
-
// (token as NumberToken).sign == null;
|
|
2349
|
-
// context.next();
|
|
2350
|
-
// }
|
|
2351
|
-
// } else
|
|
2352
1670
|
if (match?.[3] == null) {
|
|
2353
1671
|
token = context.peek(1);
|
|
2354
1672
|
if (token?.typ === EnumToken.Add ||
|
|
@@ -2361,12 +1679,6 @@ function matchProperty(property, context, options) {
|
|
|
2361
1679
|
!token.toString().includes(".") &&
|
|
2362
1680
|
token.sign == null;
|
|
2363
1681
|
}
|
|
2364
|
-
// else if (token?.typ === EnumToken.NumberTokenType) {
|
|
2365
|
-
// success =
|
|
2366
|
-
// Number.isInteger((token as NumberToken).val) &&
|
|
2367
|
-
// !(token as NumberToken).toString().includes(".") &&
|
|
2368
|
-
// (token as NumberToken).sign != null;
|
|
2369
|
-
// }
|
|
2370
1682
|
if (success) {
|
|
2371
1683
|
context.update(token);
|
|
2372
1684
|
return {
|
|
@@ -2385,26 +1697,6 @@ function matchProperty(property, context, options) {
|
|
|
2385
1697
|
success =
|
|
2386
1698
|
Number.isInteger(token.val) &&
|
|
2387
1699
|
!token.toString().includes(".");
|
|
2388
|
-
// if (!success) {
|
|
2389
|
-
// return {
|
|
2390
|
-
// success: false,
|
|
2391
|
-
// valid: true,
|
|
2392
|
-
// token: null,
|
|
2393
|
-
// context,
|
|
2394
|
-
// syntaxToken: property,
|
|
2395
|
-
// errors: [
|
|
2396
|
-
// {
|
|
2397
|
-
// action: "drop",
|
|
2398
|
-
// message: `expecting <dimension-token>`,
|
|
2399
|
-
// node: token,
|
|
2400
|
-
// location: token[LOC],
|
|
2401
|
-
// },
|
|
2402
|
-
// ],
|
|
2403
|
-
// };
|
|
2404
|
-
// }
|
|
2405
|
-
// if (token == null) {
|
|
2406
|
-
// break;
|
|
2407
|
-
// }
|
|
2408
1700
|
token = context.peek(1);
|
|
2409
1701
|
if (token == null) {
|
|
2410
1702
|
break;
|
|
@@ -2437,33 +1729,6 @@ function matchProperty(property, context, options) {
|
|
|
2437
1729
|
}
|
|
2438
1730
|
}
|
|
2439
1731
|
break;
|
|
2440
|
-
// case "number-token":
|
|
2441
|
-
// {
|
|
2442
|
-
// const token = context.peek();
|
|
2443
|
-
// success =
|
|
2444
|
-
// token?.typ === EnumToken.NumberTokenType &&
|
|
2445
|
-
// !(token as DimensionToken).val.toString().includes(".") &&
|
|
2446
|
-
// Number.isInteger((token as DimensionToken).val);
|
|
2447
|
-
// }
|
|
2448
|
-
// break;
|
|
2449
|
-
// case "ndashdigit-ident":
|
|
2450
|
-
// {
|
|
2451
|
-
// const token = context.peek();
|
|
2452
|
-
// success =
|
|
2453
|
-
// (token?.typ === EnumToken.IdenTokenType || token?.typ === EnumToken.LiteralTokenType) &&
|
|
2454
|
-
// /^-?n[-+]\d+$/.test((token as IdentToken | LiteralToken).val);
|
|
2455
|
-
// }
|
|
2456
|
-
// break;
|
|
2457
|
-
// case "dimension-token":
|
|
2458
|
-
// {
|
|
2459
|
-
// const token = context.peek();
|
|
2460
|
-
// success =
|
|
2461
|
-
// token?.typ === EnumToken.DimensionTokenType &&
|
|
2462
|
-
// (token as DimensionToken).unit === "n" &&
|
|
2463
|
-
// !(token as DimensionToken).val.toString().includes(".") &&
|
|
2464
|
-
// Number.isInteger((token as DimensionToken).val);
|
|
2465
|
-
// }
|
|
2466
|
-
// break;
|
|
2467
1732
|
case "quote":
|
|
2468
1733
|
case "display-box":
|
|
2469
1734
|
case "display-inside":
|
|
@@ -2486,29 +1751,6 @@ function matchProperty(property, context, options) {
|
|
|
2486
1751
|
token.val.toLowerCase() in config.mediaFeatures;
|
|
2487
1752
|
}
|
|
2488
1753
|
break;
|
|
2489
|
-
// case "mf-comparison":
|
|
2490
|
-
// {
|
|
2491
|
-
// const token = context.peek();
|
|
2492
|
-
// success =
|
|
2493
|
-
// token?.typ === EnumToken.LtTokenType ||
|
|
2494
|
-
// token?.typ === EnumToken.LteTokenType ||
|
|
2495
|
-
// token?.typ === EnumToken.GtTokenType ||
|
|
2496
|
-
// token?.typ === EnumToken.GteTokenType ||
|
|
2497
|
-
// token?.typ === EnumToken.DelimTokenType;
|
|
2498
|
-
// }
|
|
2499
|
-
// break;
|
|
2500
|
-
// case "mf-gt":
|
|
2501
|
-
// {
|
|
2502
|
-
// const token = context.peek();
|
|
2503
|
-
// success = token?.typ === EnumToken.GtTokenType || token?.typ === EnumToken.GteTokenType;
|
|
2504
|
-
// }
|
|
2505
|
-
// break;
|
|
2506
|
-
// case "mf-lt":
|
|
2507
|
-
// {
|
|
2508
|
-
// const token = context.peek();
|
|
2509
|
-
// success = token?.typ === EnumToken.LtTokenType || token?.typ === EnumToken.LteTokenType;
|
|
2510
|
-
// }
|
|
2511
|
-
// break;
|
|
2512
1754
|
case "dashed-ident":
|
|
2513
1755
|
case "extension-name":
|
|
2514
1756
|
case "custom-property-name":
|
|
@@ -2548,68 +1790,23 @@ function matchProperty(property, context, options) {
|
|
|
2548
1790
|
}
|
|
2549
1791
|
case "string": {
|
|
2550
1792
|
const token = context.peek();
|
|
2551
|
-
// if (token == null) {
|
|
2552
|
-
// break;
|
|
2553
|
-
// }
|
|
2554
1793
|
success = token?.typ === EnumToken.StringTokenType;
|
|
2555
1794
|
break;
|
|
2556
1795
|
}
|
|
2557
|
-
case "wq-name":
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
// };
|
|
2569
|
-
// } else if (context.peek(1)?.typ == EnumToken.Pipe) {
|
|
2570
|
-
// const success =
|
|
2571
|
-
// context.peek()?.typ === EnumToken.Star && context.peek(2)?.typ === EnumToken.IdenTokenType;
|
|
2572
|
-
// return {
|
|
2573
|
-
// success,
|
|
2574
|
-
// valid: true,
|
|
2575
|
-
// token: success ? context.update(context.peek(2) as Token).current() : context.peek(),
|
|
2576
|
-
// context,
|
|
2577
|
-
// syntaxToken: property,
|
|
2578
|
-
// errors: [],
|
|
2579
|
-
// };
|
|
2580
|
-
// } else
|
|
2581
|
-
{
|
|
2582
|
-
const success = context.peek()?.typ == EnumToken.IdenTokenType;
|
|
2583
|
-
return {
|
|
2584
|
-
success,
|
|
2585
|
-
valid: true,
|
|
2586
|
-
token: success ? context.next() : context.peek(),
|
|
2587
|
-
context,
|
|
2588
|
-
syntaxToken: property,
|
|
2589
|
-
errors: [],
|
|
2590
|
-
};
|
|
2591
|
-
}
|
|
2592
|
-
// case "id-selector":
|
|
2593
|
-
// success = context.peek()?.typ == EnumToken.HashTokenType;
|
|
2594
|
-
// break;
|
|
2595
|
-
// case "class-selector":
|
|
2596
|
-
// success = context.peek()?.typ == EnumToken.ClassSelectorTokenType;
|
|
2597
|
-
// break;
|
|
2598
|
-
// case "pseudo-class-selector":
|
|
2599
|
-
// {
|
|
2600
|
-
// const token = context.peek();
|
|
2601
|
-
// success =
|
|
2602
|
-
// token?.typ == EnumToken.PseudoClassTokenType ||
|
|
2603
|
-
// token?.typ == EnumToken.PseudoClassFuncTokenType ||
|
|
2604
|
-
// token?.typ == EnumToken.PseudoElementTokenType;
|
|
2605
|
-
// }
|
|
2606
|
-
// break;
|
|
1796
|
+
case "wq-name": {
|
|
1797
|
+
const success = context.peek()?.typ == EnumToken.IdenTokenType;
|
|
1798
|
+
return {
|
|
1799
|
+
success,
|
|
1800
|
+
valid: true,
|
|
1801
|
+
token: success ? context.next() : context.peek(),
|
|
1802
|
+
context,
|
|
1803
|
+
syntaxToken: property,
|
|
1804
|
+
errors: [],
|
|
1805
|
+
};
|
|
1806
|
+
}
|
|
2607
1807
|
case "number":
|
|
2608
1808
|
{
|
|
2609
1809
|
const token = context.peek();
|
|
2610
|
-
// if (token == null) {
|
|
2611
|
-
// break;
|
|
2612
|
-
// }
|
|
2613
1810
|
success = token?.typ == EnumToken.NumberTokenType;
|
|
2614
1811
|
}
|
|
2615
1812
|
break;
|