/** * {@inheritDoc} * * <p>The default implementation calls {@link ParseTree#accept} on the * specified tree.</p> */ @Override public T visit(ParseTree tree) { return tree.accept(this); }
/** * {@inheritDoc} * * <p>The default implementation initializes the aggregate result to * {@link #defaultResult defaultResult()}. Before visiting each child, it * calls {@link #shouldVisitNextChild shouldVisitNextChild}; if the result * is {@code false} no more children are visited and the current aggregate * result is returned. After visiting a child, the aggregate result is * updated by calling {@link #aggregateResult aggregateResult} with the * previous aggregate result and the result of visiting the child.</p> * * <p>The default implementation is not safe for use in visitors that modify * the tree structure. Visitors that modify the tree should override this * method to behave properly in respect to the specific algorithm in use.</p> */ @Override public T visitChildren(RuleNode node) { T result = defaultResult(); int n = node.getChildCount(); for (int i=0; i<n; i++) { if (!shouldVisitNextChild(node, result)) { break; } ParseTree c = node.getChild(i); T childResult = c.accept(this); result = aggregateResult(result, childResult); } return result; }
/** * {@inheritDoc} * * <p>The default implementation calls {@link ParseTree#accept} on the * specified tree.</p> */ @Override public T visit(ParseTree tree) { return tree.accept(this); }
@SuppressWarnings("unchecked") private <T extends AstNode> T accept(ParseTree node) { if (node != null) { return (T) node.accept(this); } return null; }
/** * Calls {@link ParseTree#accept} on the specified tree. */ @Override public Void visit(ParseTree tree) { tree.accept(this); return null; // Java says must return something even when Void }
/** * {@inheritDoc} * * <p>The default implementation calls {@link ParseTree#accept} on the * specified tree.</p> */ @Override public T visit(ParseTree tree) { return tree.accept(this); }
BinaryExpressionPredicate handleQuantifiedComparison(ParseTree left, ParseTree comparisonOperator, ParseTree right, PredicateQuantifier quantifier) { QuantifiableBinaryExpressionPredicate pred = (QuantifiableBinaryExpressionPredicate) comparisonOperator.accept(this); pred.setLeft(left.accept(this)); pred.setRight(right.accept(this)); pred.setQuantifier(quantifier); return pred; }
@Override public Code visitDirective(DirectiveContext ctx) { varNewLine = null; countLeadingSpaces = false; return ctx.getChild(0).accept(this); }
@Override public Code visitAlt_block_directive(Alt_block_directiveContext ctx) { return ctx.getChild(0).accept(this); }
@Override public Expression visitNestedExpr(RuleParser.NestedExprContext ctx) { return ctx.getChild(1).accept(this); }
/** * {@inheritDoc} * * <p>The default implementation calls {@link ParseTree#accept} on the * specified tree.</p> */ @Override public Result visit(@NotNull ParseTree tree) { return tree.accept(this); }
@Override public Code visitProc_content_directive(Proc_content_directiveContext ctx) { varNewLine = null; countLeadingSpaces = false; return ctx.getChild(0).accept(this); }
@Override public Code visitContext_directive(Context_directiveContext ctx) { if (!validContextDirective) { reportError("Directives relying on context are not allowed inside a proc.", ctx); } return ctx.getChild(0).accept(this); }
public ProcessedExpression( String expression, CompilerContext ctx, ProcessedFEELUnit.DefaultMode defaultBackend, List<FEELProfile> profiles) { super(expression, ctx, profiles); this.defaultBackend = defaultBackend; ParseTree tree = parser.compilation_unit(); ast = tree.accept(new ASTBuilderVisitor(ctx.getInputVariableTypes())); }
private static ShellCommand parse(ANTLRInputStream input) throws RecognitionException { ShellCommandsLexer lexer = new ShellCommandsLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); ShellCommandsParser parser = new ShellCommandsParser(tokens); ParseTree tree = parser.script(); return tree.accept(new ShellCommandBuilder()); }
private ContainerForMulti readElse(SelectionstatementContext selectionstatementContext) { final List<Element> elseElements = new ArrayList<>(); final ImmutableContainerForMulti.Builder builder = ImmutableContainerForMulti.builder().name(NAME_ELSE).tag(TAG_ELSE); if(selectionstatementContext.getChildCount() > 6){ elseElements.addAll(selectionstatementContext.getChild(6).accept(new StatementContextVisitor(visitor, builder))); } return builder.build(); }
public ProcessedUnaryTest( String expressions, CompilerContext ctx) { super(expressions, ctx, Collections.emptyList()); ParseTree tree = parser.unaryTestsRoot(); BaseNode initialAst = tree.accept(new ASTBuilderVisitor(ctx.getInputVariableTypes())); ast = initialAst.accept(new ASTUnaryTestTransform()).node(); }
private ContainerForMulti readThen(SelectionstatementContext selectionstatementContext) { final ImmutableContainerForMulti.Builder builder = ImmutableContainerForMulti.builder().name(NAME_THEN).tag(TAG_THEN); selectionstatementContext.getChild(4).accept(new StatementContextVisitor(visitor, builder)); return builder.build(); }