Class CobolAstVisitor

  • All Implemented Interfaces:
    AstVisitor
    Direct Known Subclasses:
    CobolCheck

    public abstract class CobolAstVisitor
    extends Object
    implements AstVisitor
    Base class to visit an AST (Abstract Syntactic Tree) generated by a parser. Methods are visited in the following sequential order : init(), visitFile(), visitNode(), leaveNode(), leaveFile() and destroy()
    • Constructor Detail

      • CobolAstVisitor

        public CobolAstVisitor()
    • Method Detail

      • getAstNodeTypesToVisit

        public final List<AstNodeType> getAstNodeTypesToVisit()
        This method can't be overridden. The method subscribeTo(AstNodeType... astNodeTypes) must be used to while overriding the public void init() method.
        Specified by:
        getAstNodeTypesToVisit in interface AstVisitor
        Returns:
        the AST node types this must be registered for.
      • subscribeTo

        public final void subscribeTo​(AstNodeType... astNodeTypes)
        This method must called into the init() method when a Cobol AST visitor wants to subscribe to a set of AST node type.
      • setGrammar

        public final void setGrammar​(CobolGrammar grammar)
        Do not use
      • setComments

        public final void setComments​(Comments comments)
        Do not use
      • setSymbolTable

        public final void setSymbolTable​(CobolSymbolTable symbolTable)
        Do not use
      • getComments

        public final Comments getComments()
      • init

        public void init()
        Initialize the visitor. This is the time to verify that the visitor has everything required to perform it job. This method is called once.
      • visitFile

        public void visitFile​(@Nullable
                              AstNode astNode)
        Called before starting visiting a computation unit tree. Ideal place to initialize information that is to be collected while processing the tree.
        Specified by:
        visitFile in interface AstVisitor
        Parameters:
        astNode - the root of the tree, or null if no tree
      • visitNode

        public void visitNode​(AstNode astNode)
        Called to process an AST node whose type has been registered to be visited.
        Specified by:
        visitNode in interface AstVisitor
        Parameters:
        astNode - the AST node to process
      • leaveFile

        public void leaveFile​(@Nullable
                              AstNode astNode)
        Called once a computation unit tree has been fully visited. Ideal place to report on information collected while processing a tree.
        Specified by:
        leaveFile in interface AstVisitor
        Parameters:
        astNode - the root of the tree, or null if no tree
      • leaveNode

        public void leaveNode​(AstNode astNode)
        Called once an AST node has been fully visited.
        Specified by:
        leaveNode in interface AstVisitor
        Parameters:
        astNode - the AST node which has been visited
      • destroy

        public void destroy()
        Destroy the visitor. It is being retired from service.
      • getCharset

        public Charset getCharset()
      • setCharset

        public void setCharset​(Charset charset)
      • getCobolFile

        public CobolFile getCobolFile()
      • setCobolFile

        public void setCobolFile​(CobolFile cobolFile)
      • getCobolGrammar

        protected final CobolGrammar getCobolGrammar()
      • getSqlGrammar

        protected final DB2Grammar getSqlGrammar()
      • getCicsGrammar

        protected final CicsGrammar getCicsGrammar()