+ * TODO: 12(13)(14) only parsed with only 12(13)
+ */
+/** single1 = tInt | "(" expr ")"*/
+let single1 = circumfix((x : TokenMatcheePair) =>
+ thenDo(thenDo(thenDo(tk.toSome(x), tLParen), expr), tRParen), "fac1");
+let single2= tInt;
+let single = orDo(single1, single2);
+
+/** func = single | single "(" single ")"
+ * i.e.
+ *
+ * func = single | func_aux ( int )
+ *
+*/
+
+
+/** 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) =>
+ {
+ let raw = thenDo(thenDo(toSome(x), single), OnceOrMoreDo(fac1Appliee));
+
+
+
+ if (raw._tag == "Some"){
+
+
+ var result : tkTree = raw.value.ast[0];
+ let applyToken : tk.Token = {text: '%apply', ln:0, col:0};
+ for (var i=1; i<raw.value.ast.length; i++){
+ result = [applyToken, result, raw.value.ast[i]];
+ }
+
+ if (!Array.isArray(result)){
+ raw.value.ast = [result];
+ }else{
+ raw.value.ast = result;
+ }
+ }
+
+
+
+
+ return raw;
+ };
+let fac2 = single;
+let fac = orDo(fac1, fac2);
+
+
+
+/**
+ *
+ * term1 = fac (MUL | DIV) fac