X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=src%2Findex.ts;fp=src%2Findex.ts;h=599d32a9040ef78c4127eff01698f54b0aa95ab1;hb=9784854866f652eb2118c390425a6cbe7a702ab1;hp=988e266d774a3ae4350a95544ea6fc47a631f1a8;hpb=7227602546e6eaa298a14289e88c3d948b3ef457;p=uann diff --git a/src/index.ts b/src/index.ts index 988e266..599d32a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -198,6 +198,7 @@ export function matchAny(m: TokenMatcheePair): tk.Maybe { } /** + * Danger : Maybe it's not enough to work. * @description repeating matching function `f` * zero or more times, like the asterisk `*` in regex `f*` . * @param f : the function to be repeated 0+ times. @@ -277,7 +278,9 @@ let single = orDo(single1, single2); */ -/** fac = single ["(" single ")"]? | single */ +/** fac = single ["(" single ")"]? | single + * Issue1 to be fixed. + */ let fac1Appliee = circumfix((x : TokenMatcheePair) => thenDo(thenDo(thenDo(tk.toSome(x), tLParen), tInt), tRParen), "fac1"); let fac1 = (x : TokenMatcheePair) => { @@ -351,19 +354,18 @@ let expr = orDo(expr1, expr2); let tokens = tk.tokenize("1"); +let tokens2 = tk.tokenize("1(2)"); +let tokens3 = tk.tokenize("1(2)(3)"); +let tokens4 = tk.tokenize("(3(2))*2+1"); //let tokens = tk.tokenize("(4-(3/4))"); //tk.tokenize(argv[2]); -let tokensFiltered = tokens.filter( +let tokensFiltered = tokens4.filter( (x)=>{return (x.type != tk.TokenType.NL && x.type != tk.TokenType.SP)}); -let wrappedTokens : tk.Maybe = - tk.toSome({ - matched : [] , - remained : tokensFiltered, - ast : []}); + let beta = expr({ matched : [] ,