private <T extends AstNode> EcmascriptNode<T> buildInternal(T astNode) { // Create a Node EcmascriptNode<T> node = createNodeAdapter(astNode); // Append to parent Node parent = nodes.isEmpty() ? null : nodes.peek(); if (parent != null) { parent.jjtAddChild(node, parent.jjtGetNumChildren()); node.jjtSetParent(parent); } handleParseProblems(node); // Build the children... nodes.push(node); parents.push(astNode); astNode.visit(this); nodes.pop(); parents.pop(); return node; }
public void hoist(AstNode node) { node.visit(n -> { if (n instanceof Scope) { Scope scope = (Scope) n; if (scope.getSymbolTable() != null) { for (String name : scope.getSymbolTable().keySet()) { declareName(name); } } } return true; }); }
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { for (Node kid : this) { ((AstNode)kid).visit(v); } } } }
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { for (Node kid : this) { ((AstNode)kid).visit(v); } } } }
/** * Visits this node, then the wrapped statement. */ @Override public void visit(NodeVisitor v) { if (v.visit(this)) { expr.visit(v); } } }
/** * Visits this node, then the child expression. */ @Override public void visit(NodeVisitor v) { if (v.visit(this)) { expression.visit(v); } } }
/** * Visits this node, and if present, the yielded value. */ @Override public void visit(NodeVisitor v) { if (v.visit(this) && value != null) { value.visit(v); } } }
/** * Visits this node, then the child expression. */ @Override public void visit(NodeVisitor v) { if (v.visit(this)) { expression.visit(v); } } }
/** * Visits this node, then the return value if specified. */ @Override public void visit(NodeVisitor v) { if (v.visit(this) && returnValue != null) { returnValue.visit(v); } } }
@Override public void visit(NodeVisitor v) { if (v.visit(this)) { for (Node kid : this) { ((AstNode)kid).visit(v); } } } }
/** * Visits this node, then the thrown expression. */ @Override public void visit(NodeVisitor v) { if (v.visit(this)) { expression.visit(v); } } }
/** * Visits this node, then the return value if specified. */ @Override public void visit(NodeVisitor v) { if (v.visit(this) && returnValue != null) { returnValue.visit(v); } } }
/** * Visits this node, then the thrown expression. */ @Override public void visit(NodeVisitor v) { if (v.visit(this)) { expression.visit(v); } } }
/** * Returns a debugging representation of the parse tree * starting at this node. * @return a very verbose indented printout of the tree. * The format of each line is: abs-pos name position length [identifier] */ public String debugPrint() { DebugPrintVisitor dpv = new DebugPrintVisitor(new StringBuilder(1000)); visit(dpv); return dpv.toString(); } }