Ejemplo n.º 1
0
    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()))
Ejemplo n.º 2
0
 def visitExp4(self, ctx: MPParser.Exp4Context):
     if ctx.SUBOP():
         return UnaryOp('-', self.visit(ctx.exp4()))
     elif ctx.NOTOP():
         return UnaryOp(ctx.NOTOP().getText(), self.visit(ctx.exp4()))
     else:
         return self.visit(ctx.operand())