+ else{
+ ast_middle = [inner];
+ }
+ let new_ast = [ast_middle];
+ a.value.ast = new_ast;
+ }
+ return a;
+}
+
+/** single1 = tInt | "(" expr ")"*/
+let single1 = circumfix((x : TokenMatcheePair) =>
+ thenDo(thenDo(thenDo(toSome(x), tLParen), expr), tRParen), "fac1");
+let single2= tInt;
+let single = orDo(single1, single2);
+
+/** args = single "," args | single */
+let args1 = (x: TokenMatcheePair)=>{
+ var ret = thenDo(thenDo(thenDo(toSome(x), single), tComma), args);
+ if (ret._tag == "Some"){
+ let retLength = ret.value.ast.length;
+ ret.value.ast = [[ret.value.ast[retLength-3]].concat(ret.value.ast[retLength-1])];
+ console.log("$$"+repr(ret.value.ast));
+ }
+ return ret;
+};
+
+let args2 = single;
+
+let args = orDo(args1, args2);
+
+
+/** callees = "(" args ")" | "(" ")" */
+
+
+let callees1 = circumfix((x : TokenMatcheePair) =>
+ thenDo(thenDo(thenDo(toSome(x), tLParen), args), tRParen), "callees1");
+let callees2 = (x: TokenMatcheePair)=>{
+ let ret = thenDo(thenDo(toSome(x), tLParen), tRParen);
+ if (ret._tag == "Some"){
+ let new_ast : tkTree[] = [[]];
+ ret.value.ast = new_ast;
+ }
+
+ return ret};
+
+let callees = orDo(callees1, callees2);
+
+
+
+/** %apply R combinating token */
+let applyToken = {
+ text: "%apply",
+ type: tk.TokenType.ID,
+ col: 0,
+ ln: 0,