def visitExp4(self, ctx:MPParser.Exp4Context): op = "" if ctx.SUBOP(): op = ctx.SUBOP().getText() elif ctx.NOT(): op = ctx.NOT().getText() else: return self.visit(ctx.exp5()) return UnaryOp(op, self.visit(ctx.exp4()))
def visitExp4(self, ctx: MPParser.Exp4Context): if ctx.getChildCount() == 1: return self.visit(ctx.exp5()) if ctx.SUB(): return UnaryOp(ctx.SUB().getText(), self.visit(ctx.exp4())) if ctx.NOT(): return UnaryOp(ctx.NOT().getText(), self.visit(ctx.exp4()))
def visitExp4(self, ctx: MPParser.Exp4Context): if (ctx.SUB() or ctx.NOT()): if ctx.SUB(): return UnaryOp(ctx.SUB().getText(), self.visit(ctx.exp4())) elif ctx.NOT(): return UnaryOp(ctx.NOT().getText(), self.visit(ctx.exp4())) else: return self.visit(ctx.exp5())
def visitExp4(self, ctx: MPParser.Exp4Context): log('visitExp4') if ctx.getChildCount() == 1: return self.visit(ctx.operands()) op = ctx.NOT().getText() if ctx.NOT() else ctx.SUB().getText() body = self.visit(ctx.exp4()) log1(body) log1(op) return UnaryOp(op, body)