]> git.kianting.info Git - clo/blobdiff - src/index.js
add readme
[clo] / src / index.js
index fb887701725ab7261a7bda6b47b78fa15babc3a5..f5f76745b6e30a286c0f4ddab0b259fdadf9961f 100644 (file)
@@ -22,40 +22,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
     __setModuleDefault(result, mod);
     return result;
 };
+var __importDefault = (this && this.__importDefault) || function (mod) {
+    return (mod && mod.__esModule) ? mod : { "default": mod };
+};
 Object.defineProperty(exports, "__esModule", { value: true });
-exports.match1token = void 0;
 var fs = require('fs');
-const tk = __importStar(require("./tokenize.js"));
-let b = tk.tokenize("2+2");
-/**
- * @description
- * it returns a function which test if the first char of the `remained` part of
- *  the argument of the function is `c`, if it's true, update the `MatchedPair` wrapped
- * in `Some`. Otherwise, it returns `None`.
- *  * @param t : the char to be test.
- * @returns the updated `MatchedPair` wrapped in `Some(x)` or `None`.
- */
-function match1token(t) {
-    return (m) => {
-        if (m.remained.length == 0) {
-            return { _tag: "None" };
-        }
-        const tokenToBeMatched = m.remained[0];
-        if (tokenToBeMatched === t) {
-            m.matched.push(tokenToBeMatched);
-            return {
-                _tag: "Some", value: {
-                    matched: m.matched,
-                    remained: m.remained.slice(1)
-                }
-            };
-        }
-        else {
-            return { _tag: "None" };
-        }
-    };
-}
-exports.match1token = match1token;
-;
-let c = tk.toSome(b);
-console.log(thenDo(c, match1token(tk.tokenize("+")[0])));
+const js_tokens_1 = __importDefault(require("js-tokens"));
+const util = __importStar(require("util"));
+let repr = (x) => { return util.inspect(x, { depth: null }); };
+const tokens = Array.from((0, js_tokens_1.default)(`
+import foo from\t 'bar';
+import * as util  from 'util';
+
+
+花$非花,霧\\{非霧 。{{foo();}}下
+一句`));
+console.log("RESULT=" + repr(tokens));