예제 #1
0
 static void createGraTraInstance(GraGra grammar) {
   if (grammar.getGraTraOptions().contains("priority")) {
     gratra = new PriorityGraTraImpl();
     priority = true;
     System.out.println("Transformation by rule priority ...");
   } else if (grammar.getGraTraOptions().contains("layered")) {
     gratra = new LayeredGraTraImpl();
     layered = true;
     System.out.println("Layered transformation ...");
   } else if (grammar.getGraTraOptions().contains("ruleSequence")) {
     gratra = new RuleSequencesGraTraImpl();
     ruleSequence = true;
     System.out.println("Transformation by rule sequences ...");
   } else {
     gratra = new DefaultGraTraImpl();
     System.out.println("Transformation  non-deterministically ...");
   }
 }
예제 #2
0
  public static void transform(GraGra grammar, GraTraEventListener l) {
    if (grammar == null) return;

    System.out.println(grammar.getGraTraOptions().toString());
    createGraTraInstance(grammar);

    gratra.addGraTraListener(l);
    gratra.setGraGra(grammar);
    gratra.setHostGraph(grammar.getGraph());
    gratra.enableWriteLogFile(writeLogFile);

    MorphCompletionStrategy strategy = CompletionStrategySelector.getDefault();
    // strategy = new Completion_NAC(new Completion_InjCSP());

    if (grammar.getGraTraOptions().isEmpty()) {
      grammar.setGraTraOptions(strategy);
      gratra.setCompletionStrategy(strategy);
    } else {
      if (grammar.getGraTraOptions().contains("showGraphAfterStep"))
        grammar.getGraTraOptions().remove("showGraphAfterStep");
      gratra.setGraTraOptions(grammar.getGraTraOptions());
      System.out.println("Options:  " + grammar.getGraTraOptions());
      System.out.println();
    }

    grammar.destroyAllMatches();

    if (priority) ((PriorityGraTraImpl) gratra).transform();
    else if (layered) ((LayeredGraTraImpl) gratra).transform();
    else if (ruleSequence) ((RuleSequencesGraTraImpl) gratra).transform();
    else ((DefaultGraTraImpl) gratra).transform();
  }