org.antlr.runtime.tree.Tree.toStringTree()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(98)

本文整理了Java中org.antlr.runtime.tree.Tree.toStringTree()方法的一些代码示例,展示了Tree.toStringTree()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tree.toStringTree()方法的具体详情如下:
包路径:org.antlr.runtime.tree.Tree
类名称:Tree
方法名:toStringTree

Tree.toStringTree介绍

暂无

代码示例

代码示例来源:origin: apache/hive

String treeAsString = child.getChild(j).toStringTree();
Integer pos = exprPos.get(treeAsString);
if (pos == null) {

代码示例来源:origin: apache/drill

String treeAsString = child.getChild(j).toStringTree();
Integer pos = exprPos.get(treeAsString);
if (pos == null) {

代码示例来源:origin: apache/hive

poolChanges.setPoolPath(poolPath(param));
 break;
default: throw new SemanticException("Incorrect alter syntax: " + child.toStringTree());

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/** Override this if you need transformation tracing to go somewhere
 *  other than stdout or if you're not using Tree-derived trees.
 */
public void reportTransformation(Object oldTree, Object newTree) {
  System.out.println(((Tree)oldTree).toStringTree()+" -> "+
            ((Tree)newTree).toStringTree());
}

代码示例来源:origin: antlr/antlr3

/** Override this if you need transformation tracing to go somewhere
 *  other than stdout or if you're not using Tree-derived trees.
 */
public void reportTransformation(Object oldTree, Object newTree) {
  System.out.println(((Tree)oldTree).toStringTree()+" -> "+
            ((Tree)newTree).toStringTree());
}

代码示例来源:origin: antlr/antlr3

/** Override this if you need transformation tracing to go somewhere
 *  other than stdout or if you're not using Tree-derived trees.
 */
public void reportTransformation(Object oldTree, Object newTree) {
  System.out.println(((Tree)oldTree).toStringTree()+" -> "+
            ((Tree)newTree).toStringTree());
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/** Override this if you need transformation tracing to go somewhere
 *  other than stdout or if you're not using Tree-derived trees.
 */
public void reportTransformation(Object oldTree, Object newTree) {
  System.out.println(((Tree)oldTree).toStringTree()+" -> "+
            ((Tree)newTree).toStringTree());
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/** Override this if you need transformation tracing to go somewhere
 *  other than stdout or if you're not using Tree-derived trees.
 */
public void reportTransformation(Object oldTree, Object newTree) {
  System.out.println(((Tree)oldTree).toStringTree()+" -> "+
            ((Tree)newTree).toStringTree());
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime

/** Override this if you need transformation tracing to go somewhere
 *  other than stdout or if you're not using Tree-derived trees.
 */
public void reportTransformation(Object oldTree, Object newTree) {
  System.out.println(((Tree)oldTree).toStringTree()+" -> "+
            ((Tree)newTree).toStringTree());
}

代码示例来源:origin: org.apache.pig/pig

Tree expandMacro(Tree ast) throws ParserException {
  LOG.debug("Original macro AST:\n" + ast.toStringTree() + "\n");
  // first insert the import files
  while (expandImport(ast))
    ;
  LOG.debug("macro AST after import:\n" + ast.toStringTree() + "\n");
  List<CommonTree> macroNodes = new ArrayList<CommonTree>();
  List<CommonTree> inlineNodes = new ArrayList<CommonTree>();
  // find all macro def/inline nodes
  traverse(ast, macroNodes, inlineNodes);
  Map<String, PigMacro> seen = new HashMap<String, PigMacro>();
  List<PigMacro> macroDefs = new ArrayList<PigMacro>();
  // gether all the def nodes
  for (CommonTree t : macroNodes) {
    macroDefs.add(makeMacroDef(t, seen));
  }
  // inline macros
  inlineMacro(inlineNodes, macroDefs);
  LOG.debug("Resulting macro AST:\n" + ast.toStringTree() + "\n");
  return ast;
}

代码示例来源:origin: apache/tapestry-5

private RuntimeException unexpectedNodeType(Tree node, int... expected)
{
  List<String> tokenNames = CollectionFactory.newList();
  for (int i = 0; i < expected.length; i++)
    tokenNames.add(PropertyExpressionParser.tokenNames[expected[i]]);
  String message = String.format("Node %s was type %s, but was expected to be (one of) %s.",
      node.toStringTree(), PropertyExpressionParser.tokenNames[node.getType()],
      InternalCommonsUtils.joinSorted(tokenNames));
  return new RuntimeException(message);
}

代码示例来源:origin: antlr/antlr3

/** Print out a whole tree not just a node */
@Override
public String toStringTree() {
  if ( children==null || children.isEmpty() ) {
    return this.toString();
  }
  StringBuilder buf = new StringBuilder();
  if ( !isNil() ) {
    buf.append("(");
    buf.append(this.toString());
    buf.append(' ');
  }
  for (int i = 0; children!=null && i < children.size(); i++) {
    Tree t = (Tree)children.get(i);
    if ( i>0 ) {
      buf.append(' ');
    }
    buf.append(t.toStringTree());
  }
  if ( !isNil() ) {
    buf.append(")");
  }
  return buf.toString();
}

代码示例来源:origin: io.virtdata/virtdata-lib-realer

/** Print out a whole tree not just a node */
@Override
public String toStringTree() {
  if ( children==null || children.isEmpty() ) {
    return this.toString();
  }
  StringBuilder buf = new StringBuilder();
  if ( !isNil() ) {
    buf.append("(");
    buf.append(this.toString());
    buf.append(' ');
  }
  for (int i = 0; children!=null && i < children.size(); i++) {
    Tree t = (Tree)children.get(i);
    if ( i>0 ) {
      buf.append(' ');
    }
    buf.append(t.toStringTree());
  }
  if ( !isNil() ) {
    buf.append(")");
  }
  return buf.toString();
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/** Print out a whole tree not just a node */
public String toStringTree() {
  if ( children==null || children.size()==0 ) {
    return this.toString();
  }
  StringBuffer buf = new StringBuffer();
  if ( !isNil() ) {
    buf.append("(");
    buf.append(this.toString());
    buf.append(' ');
  }
  for (int i = 0; children!=null && i < children.size(); i++) {
    Tree t = (Tree)children.get(i);
    if ( i>0 ) {
      buf.append(' ');
    }
    buf.append(t.toStringTree());
  }
  if ( !isNil() ) {
    buf.append(")");
  }
  return buf.toString();
}

代码示例来源:origin: antlr/antlr3

/** Print out a whole tree not just a node */
@Override
public String toStringTree() {
  if ( children==null || children.isEmpty() ) {
    return this.toString();
  }
  StringBuilder buf = new StringBuilder();
  if ( !isNil() ) {
    buf.append("(");
    buf.append(this.toString());
    buf.append(' ');
  }
  for (int i = 0; children!=null && i < children.size(); i++) {
    Tree t = (Tree)children.get(i);
    if ( i>0 ) {
      buf.append(' ');
    }
    buf.append(t.toStringTree());
  }
  if ( !isNil() ) {
    buf.append(")");
  }
  return buf.toString();
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.antlr-runtime

/** Print out a whole tree not just a node */
@Override
public String toStringTree() {
  if ( children==null || children.isEmpty() ) {
    return this.toString();
  }
  StringBuilder buf = new StringBuilder();
  if ( !isNil() ) {
    buf.append("(");
    buf.append(this.toString());
    buf.append(' ');
  }
  for (int i = 0; children!=null && i < children.size(); i++) {
    Tree t = (Tree)children.get(i);
    if ( i>0 ) {
      buf.append(' ');
    }
    buf.append(t.toStringTree());
  }
  if ( !isNil() ) {
    buf.append(")");
  }
  return buf.toString();
}

代码示例来源:origin: com.github.cfparser/cfml.parsing

public static void main(String[] args) {
    try {
      CharStream input = new ANTLRFileStream("./src/cfml/parsing/cfml/antlr/input3");
      XMLLexer lex = new XMLLexer(input);
      
      CommonTokenStream tokens = new CommonTokenStream(lex);
      XMLParser parser = new XMLParser(tokens);
      XMLParser.compilationUnit_return root = parser.compilationUnit();
      System.out.println("tree=" + ((Tree) root.tree).toStringTree());
      
      CommonTreeNodeStream nodes = new CommonTreeNodeStream(root.tree);
      XMLTree walker = new XMLTree(nodes);
      walker.document();
    } catch (Throwable t) {
      System.out.println("exception: " + t);
      t.printStackTrace();
    }
  }
}

代码示例来源:origin: Galigator/openllet

public static void main(final String[] args) throws IOException, RecognitionException
  {
    final SparqlOwlLexer lexer = new SparqlOwlLexer(new ANTLRReaderStream(new InputStreamReader(System.in)));
    final CommonTokenStream tokenStream = new CommonTokenStream(lexer);
    final SparqlOwlParser parser = new SparqlOwlParser(tokenStream);
    final SparqlOwlParser.query_return result = parser.query();
    final Tree t = result.getTree();
    System.out.println(t.toStringTree());
  }
}

代码示例来源:origin: eBay/YiDB

private void parseGroup(Tree groupTree, ParseQueryNode queryNode) {
  SearchGroup group = new SearchGroup();
  for (int i = 0, count = groupTree.getChildCount(); i < count; i++) {
    Tree child = groupTree.getChild(i);
    if (child.getType() == CMSQueryLexer.SRCH_ATTR) {
      ISearchField field = parseSearchField(child, queryNode, true);
      group.addGroupField(new GroupField(field));
    } else if (child.getType() == CMSQueryLexer.AGGR_ATTR) {
      throw new QueryParseException(QueryErrCodeEnum.AGG_FIELD_IN_GROUP, "Group can't contains aggregation field" + child.toStringTree());
    }            
  }
  queryNode.setGroup(group);
}

代码示例来源:origin: eBay/YiDB

private AggregationField parseAggregationField(Tree fieldTree, ParseQueryNode queryNode, boolean isFilterField) {
  if (queryNode.getGroup() == null) {
    throw new QueryParseException(QueryErrCodeEnum.AGG_WITHOUT_GROUP, "Aggregation " + fieldTree.toStringTree() + " without group");
  }
  
  Tree funcTree = fieldTree.getChild(0);
  Tree searchFieldTree = fieldTree.getChild(1);
  
  AggFuncEnum aggFunc = AggrFuncFactory.getAggrFunc(funcTree.getType());
  if (aggFunc == null) {
    throw new QueryParseException(QueryErrCodeEnum.AGG_FUNC_NOT_FOUND, "Can't find aggregation function " + funcTree.getText());
  }
  AggregationField aggField = null;
  // count should not have search field given
  if (searchFieldTree == null) {
    aggField = new AggregationField(AggFuncEnum.COUNT, null);
  } else {
    ISearchField searchField = parseSearchField(searchFieldTree, queryNode, isFilterField);
    aggField = new AggregationField(aggFunc, searchField);
  }
  queryNode.getGroup().addAggregationField(aggField);
  return aggField;
}

相关文章