X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=src%2Findex.ts;h=8cbd145671c4508ca55759035ba2da57c1edcccb;hb=e2668789e238707fa38ce3e724e3b64fba5d53b3;hp=bcd3e10cc153cc9ee1495f29aaecce30401465ee;hpb=a722e739575012ebad8cd0a7d2c12df478a54eb8;p=clo diff --git a/src/index.ts b/src/index.ts index bcd3e10..8cbd145 100644 --- a/src/index.ts +++ b/src/index.ts @@ -27,10 +27,13 @@ export type Maybe = Some | None; /** * @description * the pair of the string to be matched later and the string that have been matched - * @param matched : string have been matched - * @param remained : string will be tested whether it'll be matched. - */ -export type MatcheePair = {matched : string; remained : string}; +*/ +export interface MatcheePair { + /** have been matched */ + matched : string + /** will be tested whether it'll be matched. */ + remained : string +} /** * @description @@ -231,7 +234,7 @@ export function tokenize(input : string){ {matched:"", remained: input}); - // integer = ([+]|[-])\d\d? + // integer = ([+]|[-])?\d\d* let integer = (x : MatcheePair) => { let wrapped_x = toSome(x); let plusMinus = orDo(match1Char('+'), match1Char('-')); // ([+]|[-]) @@ -242,6 +245,7 @@ export function tokenize(input : string){ } console.log(input+", result: "); console.log(thenDo(input_matchee_pair, integer)); + // TODO: id, string, space, basic operator, 3 marks: @, {, }. } @@ -249,4 +253,4 @@ tokenize("+123"); tokenize("123"); tokenize("-123"); tokenize(" 123"); -tokenize("c123"); \ No newline at end of file +tokenize("c123");