20 lines
486 B
Python
20 lines
486 B
Python
from TreeParser import TreeParser
|
|
from TreeVisitor import TreeVisitor
|
|
|
|
class MyTreeVisitor(TreeVisitor):
|
|
def visitTop(self, ctx:TreeParser.TopContext):
|
|
return self.visit(ctx.int_tree())
|
|
|
|
def visitLeaf(self, ctx:TreeParser.LeafContext):
|
|
return True
|
|
|
|
def visitNode(self, ctx:TreeParser.NodeContext):
|
|
return (
|
|
len(ctx.int_tree()) == 2
|
|
and all([self.visit(it) for it in ctx.int_tree()])
|
|
)
|
|
|
|
|
|
del TreeVisitor
|
|
del TreeParser
|