Пример #1
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();
  }