antlr-ast icon indicating copy to clipboard operation
antlr-ast copied to clipboard

Function for mapping visitor -> AstNode classmethods

Open machow opened this issue 7 years ago • 0 comments

Currently, a common pattern is to repeat visitor methods like below. But could be collapsed easily.

    def visitQuery_specification(self, ctx):
        return SelectStmt._from_fields(self, ctx)

    def visitInsert_statement(self, ctx):
        return InsertStmt._from_fields(self, ctx)

    def visitDelete_statement(self, ctx):
        return DeleteStmt._from_fields(self, ctx)

    def visitUpdate_statement(self, ctx):
        return UpdateStmt._from_fields(self, ctx)

    def visitUnion_query_expression(self, ctx):
        return Union._from_fields(self, ctx)

machow avatar Apr 14 '17 14:04 machow