+/**
+ *
+ * @param m : the `MatcheePair` to be consumed.
+ * @returns if the length of `m.remained` >= 1; consumes the matchee by 1 token
+ * and wraps it in `Some`,
+ * otherwise, returns `None`.
+ */
+function matchAny(m) {
+ if (m.remained.length >= 1) {
+ return {
+ _tag: "Some", value: {
+ matched: m.matched.concat(m.remained[0]),
+ remained: m.remained.slice(1),
+ ast: [m.remained[0]],
+ }
+ };
+ }
+ else {
+ return { _tag: "None" };
+ }
+}
+exports.matchAny = matchAny;
+/**
+* @description repeating matching function `f`
+* zero or more times, like the asterisk `*` in regex `f*` .
+* @param f : the function to be repeated 0+ times.
+* @returns:the combined function
+*/
+function OnceOrMoreDo(f) {
+ return (x) => {
+ var wrappedOldX = { _tag: "Some", value: x };
+ var wrappedNewX = wrappedOldX;
+ var counter = -1;
+ while (wrappedNewX._tag != "None") {
+ wrappedOldX = wrappedNewX;
+ wrappedNewX = thenDo(wrappedOldX, f);
+ counter += 1;
+ }
+ ;
+ if (counter <= 0) {
+ return { _tag: "None" };
+ }
+ let ast = wrappedOldX.value.ast;
+ wrappedOldX.value.ast = ast.slice(ast.length - counter);
+ console.log(repr(wrappedOldX.value.ast));
+ return wrappedOldX;
+ };
+}
+exports.OnceOrMoreDo = OnceOrMoreDo;