String treeAsString = child.getChild(j).toStringTree(); Integer pos = exprPos.get(treeAsString); if (pos == null) {
String treeAsString = child.getChild(j).toStringTree(); Integer pos = exprPos.get(treeAsString); if (pos == null) {
poolChanges.setPoolPath(poolPath(param)); break; default: throw new SemanticException("Incorrect alter syntax: " + child.toStringTree());
/** 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()); }
/** 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()); }
/** 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()); }
/** 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()); }
/** 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()); }
/** 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()); }
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; }
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); }
/** 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(); }
/** 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(); }
/** 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(); }
/** 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(); }
/** 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(); }
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(); } } }
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()); } }
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); }
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; }