@optique/core 0.9.0-dev.233 → 0.9.0-dev.237
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/dist/primitives.cjs +11 -44
- package/dist/primitives.js +11 -44
- package/package.json +1 -1
package/dist/primitives.cjs
CHANGED
|
@@ -784,58 +784,25 @@ function command(name, parser, options = {}) {
|
|
|
784
784
|
},
|
|
785
785
|
consumed: context.buffer.slice(0, 1)
|
|
786
786
|
};
|
|
787
|
-
} else if (context.state[0] === "matched") {
|
|
787
|
+
} else if (context.state[0] === "matched" || context.state[0] === "parsing") {
|
|
788
|
+
const innerState = context.state[0] === "matched" ? parser.initialState : context.state[1];
|
|
788
789
|
const parseResultOrPromise = parser.parse({
|
|
789
790
|
...context,
|
|
790
|
-
state:
|
|
791
|
+
state: innerState
|
|
791
792
|
});
|
|
792
|
-
|
|
793
|
-
if (parseResult
|
|
793
|
+
const wrapState = (parseResult) => {
|
|
794
|
+
if (parseResult.success) return {
|
|
794
795
|
success: true,
|
|
795
796
|
next: {
|
|
796
|
-
...parseResult
|
|
797
|
-
state: ["parsing", parseResult
|
|
797
|
+
...parseResult.next,
|
|
798
|
+
state: ["parsing", parseResult.next.state]
|
|
798
799
|
},
|
|
799
|
-
consumed: parseResult
|
|
800
|
+
consumed: parseResult.consumed
|
|
800
801
|
};
|
|
801
|
-
return parseResult
|
|
802
|
-
});
|
|
803
|
-
const parseResult = parseResultOrPromise;
|
|
804
|
-
if (parseResult.success) return {
|
|
805
|
-
success: true,
|
|
806
|
-
next: {
|
|
807
|
-
...parseResult.next,
|
|
808
|
-
state: ["parsing", parseResult.next.state]
|
|
809
|
-
},
|
|
810
|
-
consumed: parseResult.consumed
|
|
811
|
-
};
|
|
812
|
-
return parseResult;
|
|
813
|
-
} else if (context.state[0] === "parsing") {
|
|
814
|
-
const parseResultOrPromise = parser.parse({
|
|
815
|
-
...context,
|
|
816
|
-
state: context.state[1]
|
|
817
|
-
});
|
|
818
|
-
if (isAsync) return parseResultOrPromise.then((parseResult$1) => {
|
|
819
|
-
if (parseResult$1.success) return {
|
|
820
|
-
success: true,
|
|
821
|
-
next: {
|
|
822
|
-
...parseResult$1.next,
|
|
823
|
-
state: ["parsing", parseResult$1.next.state]
|
|
824
|
-
},
|
|
825
|
-
consumed: parseResult$1.consumed
|
|
826
|
-
};
|
|
827
|
-
return parseResult$1;
|
|
828
|
-
});
|
|
829
|
-
const parseResult = parseResultOrPromise;
|
|
830
|
-
if (parseResult.success) return {
|
|
831
|
-
success: true,
|
|
832
|
-
next: {
|
|
833
|
-
...parseResult.next,
|
|
834
|
-
state: ["parsing", parseResult.next.state]
|
|
835
|
-
},
|
|
836
|
-
consumed: parseResult.consumed
|
|
802
|
+
return parseResult;
|
|
837
803
|
};
|
|
838
|
-
return
|
|
804
|
+
if (isAsync) return parseResultOrPromise.then(wrapState);
|
|
805
|
+
return wrapState(parseResultOrPromise);
|
|
839
806
|
}
|
|
840
807
|
return {
|
|
841
808
|
success: false,
|
package/dist/primitives.js
CHANGED
|
@@ -784,58 +784,25 @@ function command(name, parser, options = {}) {
|
|
|
784
784
|
},
|
|
785
785
|
consumed: context.buffer.slice(0, 1)
|
|
786
786
|
};
|
|
787
|
-
} else if (context.state[0] === "matched") {
|
|
787
|
+
} else if (context.state[0] === "matched" || context.state[0] === "parsing") {
|
|
788
|
+
const innerState = context.state[0] === "matched" ? parser.initialState : context.state[1];
|
|
788
789
|
const parseResultOrPromise = parser.parse({
|
|
789
790
|
...context,
|
|
790
|
-
state:
|
|
791
|
+
state: innerState
|
|
791
792
|
});
|
|
792
|
-
|
|
793
|
-
if (parseResult
|
|
793
|
+
const wrapState = (parseResult) => {
|
|
794
|
+
if (parseResult.success) return {
|
|
794
795
|
success: true,
|
|
795
796
|
next: {
|
|
796
|
-
...parseResult
|
|
797
|
-
state: ["parsing", parseResult
|
|
797
|
+
...parseResult.next,
|
|
798
|
+
state: ["parsing", parseResult.next.state]
|
|
798
799
|
},
|
|
799
|
-
consumed: parseResult
|
|
800
|
+
consumed: parseResult.consumed
|
|
800
801
|
};
|
|
801
|
-
return parseResult
|
|
802
|
-
});
|
|
803
|
-
const parseResult = parseResultOrPromise;
|
|
804
|
-
if (parseResult.success) return {
|
|
805
|
-
success: true,
|
|
806
|
-
next: {
|
|
807
|
-
...parseResult.next,
|
|
808
|
-
state: ["parsing", parseResult.next.state]
|
|
809
|
-
},
|
|
810
|
-
consumed: parseResult.consumed
|
|
811
|
-
};
|
|
812
|
-
return parseResult;
|
|
813
|
-
} else if (context.state[0] === "parsing") {
|
|
814
|
-
const parseResultOrPromise = parser.parse({
|
|
815
|
-
...context,
|
|
816
|
-
state: context.state[1]
|
|
817
|
-
});
|
|
818
|
-
if (isAsync) return parseResultOrPromise.then((parseResult$1) => {
|
|
819
|
-
if (parseResult$1.success) return {
|
|
820
|
-
success: true,
|
|
821
|
-
next: {
|
|
822
|
-
...parseResult$1.next,
|
|
823
|
-
state: ["parsing", parseResult$1.next.state]
|
|
824
|
-
},
|
|
825
|
-
consumed: parseResult$1.consumed
|
|
826
|
-
};
|
|
827
|
-
return parseResult$1;
|
|
828
|
-
});
|
|
829
|
-
const parseResult = parseResultOrPromise;
|
|
830
|
-
if (parseResult.success) return {
|
|
831
|
-
success: true,
|
|
832
|
-
next: {
|
|
833
|
-
...parseResult.next,
|
|
834
|
-
state: ["parsing", parseResult.next.state]
|
|
835
|
-
},
|
|
836
|
-
consumed: parseResult.consumed
|
|
802
|
+
return parseResult;
|
|
837
803
|
};
|
|
838
|
-
return
|
|
804
|
+
if (isAsync) return parseResultOrPromise.then(wrapState);
|
|
805
|
+
return wrapState(parseResultOrPromise);
|
|
839
806
|
}
|
|
840
807
|
return {
|
|
841
808
|
success: false,
|