1 8 package org.lsmp.djep.djep.diffRules; 9 10 import org.nfunk.jep.*; 11 import org.lsmp.djep.djep.DJep; 12 import org.lsmp.djep.xjep.*; 13 import org.nfunk.jep.function.PostfixMathCommandI; 14 15 16 26 public class MacroDiffRules extends ChainRuleDiffRules 27 { 28 34 35 public MacroDiffRules(DJep djep,String inName,Node node) throws ParseException 36 { 37 name = inName; 38 pfmc = djep.getFunctionTable().get(inName); 39 if(pfmc!=null) 40 { 41 int nParam = pfmc.getNumberOfParameters(); 42 if(nParam != 1) 43 throw new ParseException("Number of rules must match number of parameters for "+inName+" which is "+nParam); 44 } 45 rules = new Node[1]; 46 rules[0] = node; 47 } 49 50 56 public MacroDiffRules(DJep djep,String inName,String rule) throws ParseException 57 { 58 this(djep,inName,djep.getFunctionTable().get(inName),rule); 59 } 60 61 68 public MacroDiffRules(DJep djep,String inName,PostfixMathCommandI inPfmc,String rule) throws ParseException 69 { 70 name = inName; 72 pfmc = inPfmc; 73 if(pfmc!=null) 74 { 75 int nParam = pfmc.getNumberOfParameters(); 76 if(nParam != 1) 77 throw new ParseException("Number of rules must match number of parameters for "+inName+" which is "+nParam); 78 } 79 XSymbolTable localSymTab = (XSymbolTable) ((XSymbolTable) djep.getSymbolTable()).newInstance(); localSymTab.copyConstants(djep.getSymbolTable()); 81 XJep localJep = djep.newInstance(localSymTab); 82 Node node = localJep.parse(rule); 83 rules = new Node[1]; 84 rules[0] = node; 85 } 87 88 97 public MacroDiffRules(DJep djep,String inName,PostfixMathCommandI inPfmc,String rule1,String rule2) throws ParseException 98 { 99 name = inName; 101 pfmc = inPfmc; 102 if(pfmc!=null) 103 { 104 int nParam = pfmc.getNumberOfParameters(); 105 if(nParam != 2) 106 throw new ParseException("Number of rules must match number of parameters for "+inName+" which is "+nParam); 107 } 108 XSymbolTable localSymTab = (XSymbolTable) ((XSymbolTable) djep.getSymbolTable()).newInstance(); localSymTab.copyConstants(djep.getSymbolTable()); 110 XJep localJep = djep.newInstance(localSymTab); 111 Node node1 = localJep.parse(rule1); 112 Node node2 = localJep.parse(rule2); 113 rules = new Node[2]; 114 rules[0] = node1; 115 rules[1] = node2; 116 } 118 119 127 public MacroDiffRules(DJep djep,String inName,String rule1,String rule2) throws ParseException 128 { 129 this(djep,inName,djep.getFunctionTable().get(inName),rule1,rule2); 130 } 131 132 141 158 166 178 public MacroDiffRules(DJep djep,String inName,PostfixMathCommandI inPfmc,String [] inRules) throws ParseException 179 { 180 name = inName; 182 pfmc = inPfmc; 183 if(pfmc!=null) 184 { 185 int nParam = pfmc.getNumberOfParameters(); 186 if(nParam != inRules.length) 187 throw new ParseException("Number of rules must match number of parameters for "+inName+" which is "+nParam); 188 } 189 190 XSymbolTable localSymTab = (XSymbolTable) ((XSymbolTable) djep.getSymbolTable()).newInstance(); localSymTab.copyConstants(djep.getSymbolTable()); 192 XJep localJep = djep.newInstance(localSymTab); 193 194 rules = new Node[inRules.length]; 195 for(int i=0;i<inRules.length;++i) 196 { 197 rules[i] = localJep.parse(inRules[i]); 198 } 199 } 201 202 210 public MacroDiffRules(DJep djep,String inName,String [] inRules) throws ParseException 211 { 212 this(djep,inName,djep.getFunctionTable().get(inName),inRules); 213 } 214 222 237 244 249 } 250 | Popular Tags |