1 define(['require',"GrammarTreeObjects","CONSTANT"], 
  2     // module definition function
  3     // dependencies (foo and bar) are mapped to function parameters
  4     function (require, TREEObjects, CONSTANT) {
  5     	var ObjectType = CONSTANT.ObjectType;
  6     	var TreeGenerationHelper ={
  7 	    	showArray : function(arr){
  8 				console.log('Array Length :'+arr.length);
  9 			},
 10 			
 11 			showFactName : function (rangeObj){
 12 				console.log('Type :'+rangeObj.type());
 13 				console.log('Type :'+rangeObj.type());
 14 				//if(ObjectType.BIN_OP ==  rangeObj.type())
 15 					console.log('============================It is a FACT RANGE :'+rangeObj.getName());
 16 			},
 17 			/*
 18 			 * returns and Array of programs
 19 			 */
 20 			appendProgramToArray : function(prgm, type, programs){
 21 				var prgm = new  TREEObjects.PROGRAM(prgm,type);
 22 				return [prgm].concat(programs); 
 23 			},
 24 			
 25 			createBinOpDetails : function(binOperation, constOpLhsObj, constOpRhsObj){
 26 				console.log("Binary Operation - createBinOpDetails -:"+binOperation);
 27 				var binOpObj = new TREEObjects.BIN_OP(binOperation);
 28 				binOpObj = binOpObj.setLhs(constOpLhsObj);
 29 				binOpObj = binOpObj.setRhs(constOpRhsObj);
 30 				return binOpObj;
 31 			},
 32 			
 33 			createUnaryMinus : function(constOpRhsObj){
 34 				/*console.log("Unary Operation - createUnaryMinus -:"+constOpRhsObj);
 35 				var binOpObj = new TREEObjects.BIN_OP('*');
 36 				binOpObj = binOpObj.setLhs(new TREEObjects.CONSTANT(ObjectType.CONSTANT_VAL, -1));
 37 				binOpObj = binOpObj.setRhs(constOpRhsObj);
 38 				*/
 39 				constOpRhsObj.setNegative();
 40 				return constOpRhsObj;
 41 			},
 42 			
 43 			setBinRelDetails : function(binRel, lhs, rhs){
 44 				var binRelObj = new TREEObjects.BIN_REL(binRel);
 45 				binRelObj = binRelObj.setLhs(lhs);
 46 				binRelObj = binRelObj.setRhs(rhs);
 47 				return binRelObj;
 48 			},
 49 			setOpEqualDetails : function(opEqualObj, variable, rhs){
 50 				opEqualObj =  new TREEObjects.OPER_EQUAL();
 51 				opEqualObj = opEqualObj.setVariable(variable);
 52 				opEqualObj = opEqualObj.setRhs(rhs);
 53 				return opEqualObj;
 54 			},
 55 			
 56 			createFact : function(range, variables){
 57 				var rangeObj = new TREEObjects.RANGE(ObjectType.FACT, range);
 58 				console.log("Range Object ----"+rangeObj);
 59 				rangeObj = rangeObj.addVariable(variables);
 60 				return rangeObj;
 61 			},
 62 			
 63 			clauseNoBody : function(fact){
 64 				return new TREEObjects.CLAUSE(ObjectType.CLAUSE_TYPE_NO_BODY, fact);
 65 			},
 66 			
 67 			clauseWithBody : function(fact, body){
 68 				return new TREEObjects.CLAUSE(ObjectType.CLAUSE_TYPE_BODY, fact, body);
 69 			},
 70 			//Parsing Context
 71 			_CXT:{
 72 				parsingContext:[],
 73 				evaluationContext:{
 74 					cellArray:[]
 75 				},
 76 				tokenList:require('Collections').Stack(),
 77 				init:function(){
 78 					this.parsingContext=[];
 79 					this.tokenList =require('Collections').Stack();
 80 				},
 81 				clearContext:function(){
 82 					this.parsingContext=[];
 83 				},
 84 				foundToken:function(type, tok){
 85 					this.tokenList.push({type:type, token:tok});
 86 				}, 
 87 				getTokenStack:function(){
 88 					return this.tokenList;
 89 				},
 90 				addVariable:function(variable){
 91 					if(!this.parsingContext['VARIABLE'])
 92 						this.parsingContext['VARIABLE'] = require('Collections').ArrayList();
 93 					this.parsingContext['VARIABLE'].add(variable);
 94 				},
 95 				getVariables:function(){
 96 					if(!this.parsingContext['VARIABLE'])
 97 						this.parsingContext['VARIABLE'] = require('Collections').ArrayList();
 98 					return this.parsingContext['VARIABLE'].getElements();
 99 				}
100 			}
101     	};
102 		return TreeGenerationHelper;
103 });