Class AstVisitorBase<P,​R>

  • All Implemented Interfaces:

    public abstract class AstVisitorBase<P,​R>
    extends Object
    implements AstVisitor<P,​R>
    Base implementation of AstVisitor, that performs a top-down (preorder) visit and may accumulate a result.

    Note that if you care about the result (<R>), then you need to override visitChildren to implement the logic that combines values from children, if any.

    • Constructor Detail

      • AstVisitorBase

        public AstVisitorBase()
    • Method Detail

      • visitChildren

        protected R visitChildren​(Node node,
                                  P data)
        Visit the children. By default the data parameter is passed unchanged to all descendants, and null is returned. Override this method to customize this behavior.
        node - Node whose children should be visited
        data - Parameter of the visit
        Some value for the children
      • visitNode

        public R visitNode​(Node node,
                           P param)
        Description copied from interface: AstVisitor
        Visit a node. This method is dispatched statically, you should use Node.acceptVisitor(AstVisitor, Object) if you want to call the most specific method instead.
        Specified by:
        visitNode in interface AstVisitor<P,​R>
        node - Node to visit
        param - Parameter
        Some result