Beispiel #1
0
  private static void print(HiddenTokenAwareTree tree, int level) {
    indent(level);
    printSingleNode(tree);

    // print all children
    if (tree.getChildren() != null)
      for (Object ie : tree.getChildren()) {
        print((HiddenTokenAwareTree) ie, level + 1);
      }
  }
Beispiel #2
0
 public static void printSingleNode(HiddenTokenAwareTree tree) {
   String base = " " + tree.getType() + " " + tree.getText();
   if (printIndexes) {
     String optionalsuffix =
         " "
             + tree.getTokenStartIndex()
             + "-"
             + tree.getTokenStopIndex()
             + " "
             + (tree.getToken() == null ? "" : tree.getToken().getTokenIndex());
     base = base + optionalsuffix;
   }
   if (printComments) {
     String optionalsuffix =
         " PC:" + printComments(tree.getPreceding()) + " FC:" + printComments(tree.getFollowing());
     base = base + optionalsuffix;
   }
   System.out.println(base);
 }