X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=src%2Findex.js;h=f5f76745b6e30a286c0f4ddab0b259fdadf9961f;hb=ae71f2351bd6ffb5e054687dd1e3eb99f72545fe;hp=fb887701725ab7261a7bda6b47b78fa15babc3a5;hpb=cda463d89022d09a5273b59bcd3e776f1127697a;p=clo diff --git a/src/index.js b/src/index.js index fb88770..f5f7674 100644 --- a/src/index.js +++ b/src/index.js @@ -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));