Beispiel #1
0
  /**
   * 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);
      }
    }
  }
Beispiel #2
0
 /**
  * This function takes a file, obtains a parsed TCRL_AST object and stores it in the unique
  * instance of RefLawRepository
  *
  * @param tcrlFile The file with the refinement law
  * @return the name of the parsed law
  */
 public static String parseFile(File tcrlFile) throws Exception {
   try {
     // First we parse the file and preprocess it
     TCRL_Parser parser = new TCRL_Parser(new FileInputStream(tcrlFile));
     TCRL_AST ast = parser.parse();
     ast = TCRL_PreProcessor.preProcess(ast);
     String refLawName = ast.getName();
     // Now we store it in the RefLawRepository
     RefLawRepository refLawRepository = RefLawRepository.getInstance();
     refLawRepository.addRefLaw(refLawName, ast);
     return refLawName;
   } catch (Exception e) {
     throw e;
   }
 }