- throw new Error("the tkTree can't be concated, because it's not an array.");
- }
-}
-function slice(x, index, end) {
- if (Array.isArray(x)) {
- return x.slice(index, end);
- }
- else {
- throw new Error("the tkTree can't be concated, because it's not an array.");
- }
-}
-/**
- * @description
- * match one token type.
- *
- * it returns a function which test if the type of first token of the `remained` part of
- * the argument of the function is `typ` , if it's true, update the `TokenMatcheePair` wrapped
- * in `Some`. Otherwise, it returns `None`.
- * * @param typ : the type to be test.
- * @returns the updated `TokenMatcheePair` wrapped in `Some(x)` or `None`.
- */
-function m1TType(typ) {
- return (m) => {
- if (m.remained.length == 0) {
- return { _tag: "None" };
- }
- /**
- * token to be matched
- * */
- const ttbm = m.remained[0];
- if (ttbm.type == typ) {
- let new_matched = m.matched.concat(ttbm);
- let result = {
- _tag: "Some", value: {
- matched: new_matched,
- remained: m.remained.slice(1),
- ast: ([ttbm]),
- }
- };
- return result;