- return {_tag : "None"};
- }
-}
-
-/**
- * define the right hand side of a grammar
- * eg. `LHS ::= a + b`
- * @param process the right hand side processing : eg. `a + b` in `LHS`
- * @param arrange define the order (0 starting) of the elements of the result.
- * ast. : eg. `a + c` is `1 0 2` `(+ a c)`
- * @returns the processed ast.
- */
-function gramRHS (process: Function, arrange : number[]){
- return (m : TokenMatcheePair)=>{
-
- let middle : tk.Maybe<TokenMatcheePair> = process(m);
-
- console.log("Middle"+util.inspect(middle, { showHidden: true, depth: null }));
-
- if (middle._tag == "None"){
- return middle;
- }
- else{
- let matched = middle.value.matched;
- let arrLength = arrange.length;
- let returnRrray : tkTree[] = Array(arrange.length);
-
- arrange.forEach((val, index) => {
- returnRrray[arrange[index]] = matched[index];
- });
-
- let matchedTmp1Length = matched.length-arrLength;
- console.log(matchedTmp1Length);
- var matchedTmp1 : tkTree[] = matched
- .slice(0,matchedTmp1Length);
-
- console.log("matchedTmp1"+util.inspect(matchedTmp1, { showHidden: true, depth: null }));
- console.log("returnRrray"+util.inspect(returnRrray, { showHidden: true, depth: null }));
- matchedTmp1.push(returnRrray);
-