81728172 syntax: "ltr | rtl"
81738173 },
81748174 display: {
8175- syntax: "[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy>| <-non-standard-display>"
8175+ syntax: "[ <display-outside> || <display-inside> ] | <display-listitem> | <display-internal> | <display-box> | <display-legacy> | <-non-standard-display>"
81768176 },
81778177 "dominant-baseline": {
81788178 syntax: "auto | text-bottom | alphabetic | ideographic | middle | central | mathematical | hanging | text-top"
81938193 syntax: "nonzero | evenodd"
81948194 },
81958195 filter: {
8196- syntax: "none | <filter-value-list>| <-ms-filter-function-list>"
8196+ syntax: "none | <filter-value-list> | <-ms-filter-function-list>"
81978197 },
81988198 flex: {
81998199 syntax: "none | [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ]"
83888388 syntax: "from-image | <angle> | [ <angle>? flip ]"
83898389 },
83908390 "image-rendering": {
8391- syntax: "auto | crisp-edges | pixelated | smooth| optimizeSpeed | optimizeQuality | <-non-standard-image-rendering>"
8391+ syntax: "auto | crisp-edges | pixelated | smooth | optimizeSpeed | optimizeQuality | <-non-standard-image-rendering>"
83928392 },
83938393 "image-resolution": {
83948394 syntax: "[ from-image || <resolution> ] && snap?"
85928592 syntax: "<'max-width'>"
85938593 },
85948594 "max-height": {
8595- syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>| stretch | <-non-standard-size>"
8595+ syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
85968596 },
85978597 "max-inline-size": {
85988598 syntax: "<'max-width'>"
86018601 syntax: "none | <integer>"
86028602 },
86038603 "max-width": {
8604- syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>| stretch | <-non-standard-size>"
8604+ syntax: "none | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
86058605 },
86068606 "min-block-size": {
86078607 syntax: "<'min-width'>"
86138613 syntax: "<'min-width'>"
86148614 },
86158615 "min-width": {
8616- syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()>| stretch | <-non-standard-size>"
8616+ syntax: "auto | <length-percentage [0,∞]> | min-content | max-content | fit-content | fit-content(<length-percentage [0,∞]>) | <calc-size()> | <anchor-size()> | stretch | <-non-standard-size>"
86178617 },
86188618 "mix-blend-mode": {
86198619 syntax: "<blend-mode> | plus-lighter"
86708670 syntax: "<line-width>"
86718671 },
86728672 overflow: {
8673- syntax: "[ visible | hidden | clip | scroll | auto ]{1,2}| <-non-standard-overflow>"
8673+ syntax: "[ visible | hidden | clip | scroll | auto ]{1,2} | <-non-standard-overflow>"
86748674 },
86758675 "overflow-anchor": {
86768676 syntax: "auto | none"
86918691 syntax: "normal | break-word | anywhere"
86928692 },
86938693 "overflow-x": {
8694- syntax: "visible | hidden | clip | scroll | auto| <-non-standard-overflow>"
8694+ syntax: "visible | hidden | clip | scroll | auto | <-non-standard-overflow>"
86958695 },
86968696 "overflow-y": {
8697- syntax: "visible | hidden | clip | scroll | auto| <-non-standard-overflow>"
8697+ syntax: "visible | hidden | clip | scroll | auto | <-non-standard-overflow>"
86988698 },
86998699 overlay: {
87008700 syntax: "none | auto"
87818781 syntax: "auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit"
87828782 },
87838783 position: {
8784- syntax: "static | relative | absolute | sticky | fixed| -webkit-sticky"
8784+ syntax: "static | relative | absolute | sticky | fixed | -webkit-sticky"
87858785 },
87868786 "position-anchor": {
87878787 syntax: "auto | <anchor-name>"
92109210 syntax: "normal | break-word"
92119211 },
92129212 "writing-mode": {
9213- syntax: "horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr| <svg-writing-mode>"
9213+ syntax: "horizontal-tb | vertical-rl | vertical-lr | sideways-rl | sideways-lr | <svg-writing-mode>"
92149214 },
92159215 x: {
92169216 syntax: "<length> | <percentage>"
1166011660 ValidationSyntaxGroupEnum["AtRules"] = "atRules";
1166111661 })(ValidationSyntaxGroupEnum || (ValidationSyntaxGroupEnum = {}));
1166211662
11663- var WalkValidationTokenEnum;
11664- (function (WalkValidationTokenEnum) {
11665- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreChildren"] = 0] = "IgnoreChildren";
11666- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreNode"] = 1] = "IgnoreNode";
11667- WalkValidationTokenEnum[WalkValidationTokenEnum["IgnoreAll"] = 2] = "IgnoreAll";
11668- })(WalkValidationTokenEnum || (WalkValidationTokenEnum = {}));
11669- var WalkValidationTokenKeyTypeEnum;
11670- (function (WalkValidationTokenKeyTypeEnum) {
11671- WalkValidationTokenKeyTypeEnum["Array"] = "array";
11672- WalkValidationTokenKeyTypeEnum["Children"] = "chi";
11673- WalkValidationTokenKeyTypeEnum["Left"] = "l";
11674- WalkValidationTokenKeyTypeEnum["Right"] = "r";
11675- WalkValidationTokenKeyTypeEnum["Prelude"] = "prelude";
11676- })(WalkValidationTokenKeyTypeEnum || (WalkValidationTokenKeyTypeEnum = {}));
1167711663 const skipped = [
1167811664 ValidationTokenEnum.Star,
1167911665 ValidationTokenEnum.HashMark,
1168711673 writable: true,
1168811674 configurable: true
1168911675 };
11690- // syntaxes: keyword | <'property'> | <function>
11691- // "none | [ [<dashed-ident> || <try-tactic>] | inset-area( <'inset-area'> ) ]#"
11692- // ""
11693- // : "<outline-radius>{1,4} [ / <outline-radius>{1,4} ]?
11694- // ""
11695- // false | true
11696- // [ <mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || [ <box> | border | padding | content | text ] || [ <box> | border | padding | content ] ]#
11697- // false | true | green | pipe
11698- // keyword | <'property'> | <function>
11699- // [<dashed-ident> || <try-tactic>]
11700- // [ <mask-reference> || <position> [ / <bg-size> ]? || <repeat-style> || [ <box> | border | padding | content | text ] || [ <box> | border | padding | content ] ]#
11701- // none | [ [<dashed-ident> || <try-tactic>] | inset-area( <'inset-area'> ) ]
1170211676 function* tokenize(syntax, position = { ind: 0, lin: 1, col: 0 }, currentPosition = {
1170311677 ind: -1,
1170411678 lin: 1,
@@ -13383,13 +13357,13 @@
1338313357 update(context) {
1338413358 // @ts-ignore
1338513359 const newIndex = result.indexOf(context.current());
13386- if (newIndex != -1 ) {
13360+ if (newIndex > this.index ) {
1338713361 this.index = newIndex;
1338813362 }
1338913363 },
1339013364 consume(token, howMany) {
1339113365 let newIndex = result.indexOf(token, this.index + 1);
13392- if (newIndex == -1) {
13366+ if (newIndex == -1 || newIndex < this.index ) {
1339313367 return false;
1339413368 }
1339513369 howMany ??= 0;
@@ -13426,13 +13400,21 @@
1342613400 return result.slice(this.index + 1);
1342713401 },
1342813402 clone() {
13429- const context = createContext(input .slice());
13403+ const context = createContext(result .slice());
1343013404 context.index = this.index;
1343113405 return context;
13406+ },
13407+ // @ts-ignore
13408+ toJSON() {
13409+ return {
13410+ index: this.index,
13411+ slice: this.slice(),
13412+ tokens: this.tokens()
13413+ };
1343213414 }
1343313415 };
1343413416 }
13435- function evaluateSyntax(node, options, parent ) {
13417+ function evaluateSyntax(node, options) {
1343613418 let ast;
1343713419 let result;
1343813420 switch (node.typ) {
1351813500 let i = 0;
1351913501 let result;
1352013502 let token = null;
13521- // console.error(`doEvaluateSyntax: ${syntaxes.reduce((acc, curr) => acc + renderSyntax(curr), '')}`, context.peek());
13522- // console.error(new Error('anyOf '));
13503+ // console.error(`>> doEvaluateSyntax: ${syntaxes.reduce((acc, curr) => acc + renderSyntax(curr), '')}`, context.peek());
13504+ // console.error(new Error('doEvaluateSyntax '));
1352313505 for (; i < syntaxes.length; i++) {
1352413506 syntax = syntaxes[i];
1352513507 if (context.done()) {
1352913511 break;
1353013512 }
1353113513 token = context.peek();
13514+ // console.error(`>> doEvaluateSyntax: ${ renderSyntax(syntax)}`, context.peek());
1353213515 if (syntax.typ == ValidationTokenEnum.Whitespace) {
1353313516 if (context.peek()?.typ == exports.EnumToken.WhitespaceTokenType) {
1353413517 context.next();
1356213545 clearVisited(token, syntax, 'doEvaluateSyntax', options);
1356313546 }
1356413547 }
13548+ // console.error(`>> doEvaluateSyntax: ${ renderSyntax(syntax)}\nvalid:${result.valid == SyntaxValidationResult.Valid ? 'valid' : 'invalid'}\n`, context.peek());
1356513549 if (result.valid == SyntaxValidationResult.Drop) {
1356613550 if (syntax.isOptional) {
1356713551 continue;
@@ -13635,11 +13619,13 @@
1363513619 context
1363613620 };
1363713621 }
13622+ // console.error(`>> matchList: ${tokens.reduce((acc, curr, index) => acc + (index > 0 ? ' ' : '') + renderToken(curr), '')}`);
1363813623 result = doEvaluateSyntax([syntax], createContext(tokens), {
1363913624 ...options,
1364013625 isList: false,
1364113626 occurence: false
1364213627 });
13628+ // console.error(`>> matchList: ${tokens.reduce((acc, curr, index) => acc + (index > 0 ? ' ' : '') + renderToken(curr), '')}\n>> result: ${result.valid == SyntaxValidationResult.Valid ? 'valid' : 'invalid'}\n${JSON.stringify(result, null, 1)}`);
1364313629 if (result.valid == SyntaxValidationResult.Valid) {
1364413630 context = con.clone();
1364513631 count++;
1369813684 let success = false;
1369913685 let result;
1370013686 let token = context.peek();
13687+ // console.error(`>> match: ${renderSyntax(syntax)}`);
1370113688 switch (syntax.typ) {
1370213689 case ValidationTokenEnum.PipeToken:
1370313690 return someOf(syntax.chi, context, options);
1407514062 context.next();
1407614063 }
1407714064 result = doEvaluateSyntax(syntaxes[i], context.clone(), options);
14065+ // console.error(JSON.stringify({result, syntax: syntaxes[i], context, slice: context.slice()}, null, 1));
1407814066 if (result.valid == SyntaxValidationResult.Valid) {
1407914067 success = true;
1408014068 if (result.context.done()) {
1408714075 // pick the best match
1408814076 matched.sort((a, b) => a.context.done() ? -1 : b.context.done() ? 1 : b.context.index - a.context.index);
1408914077 }
14078+ // console.error(JSON.stringify({matched, context, slice: context.slice(), syntaxes}, null, 1));
1409014079 return matched[0] ?? {
1409114080 valid: SyntaxValidationResult.Drop,
1409214081 node: context.current(),
1414214131 for (i = 0; i < slice.length; i++) {
1414314132 if (slice[i].typ == exports.EnumToken.FunctionTokenType && wildCardFuncs.includes(slice[i].val.toLowerCase())) {
1414414133 vars.push(slice[i]);
14145- slice.splice(i, 1);
14146- if (slice[i]?.typ == exports.EnumToken.WhitespaceTokenType) {
14147- vars.push(slice[i]);
14148- slice.splice(i, 1);
14149- if (i > 0) {
14150- i--;
14151- }
14152- }
14153- if (i > 0) {
14154- i--;
14134+ if (slice[i + 1]?.typ == exports.EnumToken.WhitespaceTokenType) {
14135+ vars.push(slice[++i]);
1415514136 }
1415614137 continue;
1415714138 }
@@ -14167,15 +14148,22 @@
1416714148 const con = createContext(tokens);
1416814149 let cp;
1416914150 let j;
14151+ // console.error(`>> allOf:syntax: ${syntax.reduce((acc, curr, index) => acc + (index > 0 ? ' && ' : '') + curr.reduce((acc, curr) => acc + renderSyntax(curr), ''), '')}`);
14152+ // console.error(`>> allOf:tokens: ${con.slice<Token>().reduce((acc, curr, index) => acc + (index > 0 ? ' ' : '') + renderToken(curr), '')}`);
14153+ // console.error(`>> allOf:tokens:slice: ${context.slice<Token>().reduce((acc, curr, index) => acc + (index > 0 ? ' ' : '') + renderToken(curr), '')}`);
1417014154 for (i = 0; i < syntax.length; i++) {
14155+ // console.error(`>> allOf:${i}:${syntax[i].reduce((acc, curr) => acc + renderSyntax(curr), '')}:current()`, con.current());
1417114156 if (syntax[i].length == 1 && syntax[i][0].isOptional) {
14157+ // syntax[i][0 = structuredClone(syntax[i][0]);
1417214158 syntax[i][0].isOptional = false;
1417314159 j = 0;
1417414160 cp = con.clone();
1417514161 slice = cp.slice();
1417614162 if (cp.done()) {
14163+ syntax[i][0].isOptional = true;
1417714164 syntax.splice(i, 1);
1417814165 i = -1;
14166+ // console.error(`>> allOf:done:peek: `, con.peek());
1417914167 continue;
1418014168 }
1418114169 while (!cp.done()) {
1419614184 }
1419714185 syntax[i][0].isOptional = true;
1419814186 // @ts-ignore
14187+ // console.error(`>> allOf:result valid: `, result?.valid == SyntaxValidationResult.Valid, con.current<Token>());
14188+ // @ts-ignore
1419914189 if (result?.valid == SyntaxValidationResult.Valid) {
1420014190 syntax.splice(i, 1);
14191+ // console.error(`>> allOf:syntaxes: ${syntax.reduce((acc, curr, index) => acc + (index > 0 ? ' && ' : '') + curr.reduce((acc, curr) => acc + renderSyntax(curr), ''), '')}`);
14192+ // console.error(`>> allOf:context:`, JSON.stringify(con, null, 1));
1420114193 i = -1;
1420214194 }
1420314195 continue;
1684716839 value: valid.valid == SyntaxValidationResult.Valid
1684816840 });
1684916841 if (valid.valid == SyntaxValidationResult.Drop) {
16842+ // console.error({result, valid});
16843+ // console.error(JSON.stringify({result, options, valid}, null, 1));
1685016844 errors.push({
1685116845 action: 'drop',
1685216846 message: valid.error,
0 commit comments