1 define(['require', 'FormulaGrammarRule'],
  2 function(require, FormulaGrammarRule) {
  3 
  4 	/**
  5 	 * @description A Class Responsible for Complete Parsing Process of the Expressions
  6 	 * @name RuleEngine
  7 	 * @class RuleEngine
  8 	 * @example require('RuleEngine')
  9 	 * @exports RuleEngine
 10 	 * @version 1.0
 11 	 * @module RuleEngine
 12 	 * @augments FormulaGrammarRule
 13 	 **/
 14 	var RuleEngine = {
 15 		/**
 16 		 * @name runRules
 17 		 * @memberOf RuleEngine
 18 		 * @method 
 19 		 * @return {Void}
 20 		 * @description The function will run the designed rules for the programs generated through the Jison parser.
 21 		 * @param programs [] An Array of Parsed Expression Objects. 
 22 		 * @param showError {Boolean} If show error is true then it will call a modal popup and will project the error in the UI.
 23 		 * @function
 24 		 */
 25 		runRules : function(programs, showError) {
 26 			try {
 27 				FormulaGrammarRule.RULE_1().execute(programs);
 28 				FormulaGrammarRule.RULE_2().execute(programs);
 29 				FormulaGrammarRule.RULE_3().execute(programs);
 30 				//GrammerRule.RULE_3().execute(programs);
 31 				FormulaGrammarRule.RULE_4().execute(programs);
 32 				FormulaGrammarRule.RULE_5().execute(programs);
 33 				//FormulaGrammarRule.RULE_6().execute(programs); Allows the recursive calculations.
 34 				FormulaGrammarRule.RULE_7().execute(programs);
 35 				FormulaGrammarRule.RULE_8().execute(programs);
 36 				
 37 			} catch(error) {
 38 				if (error && showError)
 39 					modal({
 40 						type : 'error',
 41 						title : 'Error',
 42 						text : error
 43 					});
 44 				return false;
 45 			}
 46 			return true;
 47 		}
 48 	};
 49 	return RuleEngine;
 50 });