/** * This function prints a parsed TCRL refinement law. Only for debug purposes * * @param r The AST object */ public static void printRefFunction(TCRL_AST r) { System.out.println(); System.out.println("**************************************************"); System.out.println("RefFunction"); System.out.println("**************************************************"); System.out.println("Nombre: " + r.getName()); System.out.println("Preambulo: " + r.getPreamble()); System.out.println("Reglas: "); NodeRules rules = r.getRules(); NodeRule rule; Set<String> keys = rules.getKeys(); Iterator<String> iter = keys.iterator(); while (iter.hasNext()) { rule = rules.getRule(iter.next()); if (rule instanceof RuleSynonym) { printRuleSynonym((RuleSynonym) rule); } else { printRuleRefinement((RuleRefinement) rule); } } }
/** * This function obtains the refinement rule associated with a specification ID * * @param specID The identifier of a variable in the specification * @param rules A list with refinement rules * @return the rule associated with the variable */ public static RuleRefinement getRefinementRule(String specID, NodeRules rules) { RuleRefinement ruleRefinement = null; Set<String> setRuleNames = rules.getKeys(); Iterator<String> iterRuleNames = setRuleNames.iterator(); boolean found = false; while (iterRuleNames.hasNext() && !found) { String ruleName = iterRuleNames.next(); NodeRule rule = rules.getRule(ruleName); List<String> ruleSpecIDs = ((RuleRefinement) rule).getSpecIDs(); Iterator<String> iterRuleSpecIDs = ruleSpecIDs.iterator(); while (iterRuleSpecIDs.hasNext() && !found) { String ruleSpecID = iterRuleSpecIDs.next(); if (specID.equals(ruleSpecID)) { found = true; if (rule instanceof RuleRefinement) ruleRefinement = (RuleRefinement) rule; } } } return ruleRefinement; }