Beispiel #1
0
 @SuppressWarnings("unchecked") // tree.getChildren()
 private void walk(CommonTree tree, StringBuilder buffer, int level) {
   String indent = LOTSOBLANKS.substring(0, level);
   Token token = tree.token;
   int tokenType = token.getType();
   String tokenText = token.getText();
   int childCount = tree.getChildCount();
   int childIndex = tree.getChildIndex();
   buffer.append('\n');
   buffer.append(indent);
   buffer.append(tokenText);
   buffer.append(" class: ");
   buffer.append(tree.getClass().getName());
   buffer.append(" tokenType ");
   buffer.append(tokenType);
   buffer.append(" child count ");
   buffer.append(childCount);
   buffer.append(" child index ");
   buffer.append(childIndex);
   List<CommonTree> children = tree.getChildren();
   if (children == null) {
     return;
   }
   for (CommonTree child : children) {
     walk(child, buffer, level + 2);
   }
 }
Beispiel #2
0
 public int getChildIndex() {
   return node.getChildIndex();
 }