]>
git.kianting.info Git - uann/blob - index.js
fb887701725ab7261a7bda6b47b78fa15babc3a5
2 var __createBinding
= (this && this.__createBinding
) || (Object
.create
? (function(o
, m
, k
, k2
) {
3 if (k2
=== undefined) k2
= k
;
4 var desc
= Object
.getOwnPropertyDescriptor(m
, k
);
5 if (!desc
|| ("get" in desc
? !m
.__esModule
: desc
.writable
|| desc
.configurable
)) {
6 desc
= { enumerable
: true, get: function() { return m
[k
]; } };
8 Object
.defineProperty(o
, k2
, desc
);
9 }) : (function(o
, m
, k
, k2
) {
10 if (k2
=== undefined) k2
= k
;
13 var __setModuleDefault
= (this && this.__setModuleDefault
) || (Object
.create
? (function(o
, v
) {
14 Object
.defineProperty(o
, "default", { enumerable
: true, value
: v
});
18 var __importStar
= (this && this.__importStar
) || function (mod
) {
19 if (mod
&& mod
.__esModule
) return mod
;
21 if (mod
!= null) for (var k
in mod
) if (k
!== "default" && Object
.prototype.hasOwnProperty
.call(mod
, k
)) __createBinding(result
, mod
, k
);
22 __setModuleDefault(result
, mod
);
25 Object
.defineProperty(exports
, "__esModule", { value
: true });
26 exports
.match1token
= void 0;
27 var fs
= require('fs');
28 const tk
= __importStar(require("./tokenize.js"));
29 let b
= tk
.tokenize("2+2");
32 * it returns a function which test if the first char of the `remained` part of
33 * the argument of the function is `c`, if it's true, update the `MatchedPair` wrapped
34 * in `Some`. Otherwise, it returns `None`.
35 * * @param t : the char to be test.
36 * @returns the updated `MatchedPair` wrapped in `Some(x)` or `None`.
38 function match1token(t
) {
40 if (m
.remained
.length
== 0) {
41 return { _tag
: "None" };
43 const tokenToBeMatched
= m
.remained
[0];
44 if (tokenToBeMatched
=== t
) {
45 m
.matched
.push(tokenToBeMatched
);
47 _tag
: "Some", value
: {
49 remained
: m
.remained
.slice(1)
54 return { _tag
: "None" };
58 exports
.match1token
= match1token
;
61 console
.log(thenDo(c
, match1token(tk
.tokenize("+")[0])));