def visitExp2(self, ctx: BKITParser.ProgramContext): if (ctx.getChildCount() == 1): return ctx.exp3().accept(self) return BinaryOp( ctx.getChild(1).getText(), ctx.exp2().accept(self), ctx.exp3().accept(self))
def visitExp3(self, ctx: BKITParser.ProgramContext): # right association should be calced first ? if (ctx.getChildCount() == 1): return ctx.exp4().accept(self) return BinaryOp( ctx.getChild(1).getText(), ctx.exp3().accept(self), ctx.exp4().accept(self))