Esempio n. 1
0
 def visitExp3(self, ctx: MPParser.Exp3Context):
     if ctx.getChildCount() == 1:  # exp4
         return self.visit(ctx.exp4())
     left = self.visit(ctx.exp3())
     right = self.visit(ctx.exp4())
     op = ctx.getChild(1).getText()
     return BinaryOp(op, left, right)
Esempio n. 2
0
 def visitExp3(self, ctx: MPParser.Exp3Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp4())
     op = ctx.getChild(1).getText()
     exp3 = self.visit(ctx.exp3())
     exp4 = self.visit(ctx.exp4())
     return BinaryOp(op, exp3, exp4)
Esempio n. 3
0
 def visitExp3(self, ctx: MPParser.Exp3Context):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp4())
     else:
         return BinaryOp(
             ctx.getChild(1).getText(), self.visit(ctx.exp3()),
             self.visit(ctx.exp4()))
 def visitExp3(self, ctx: MPParser.Exp3Context):
     '''dxp3: exp3 DIV_F exp4 | exp3 MUL exp4 | exp3 DIV exp4 | exp3 MOD exp4 | exp3 AND exp4 | exp4;'''
     return BinaryOp(
         ctx.getChild(1).getText(), self.visit(ctx.exp3()),
         self.visit(
             ctx.exp4())) if ctx.getChildCount() == 3 else self.visit(
                 ctx.exp4())
Esempio n. 5
0
 def visitExp3(self, ctx:MPParser.Exp3Context):
     if ctx.getChildCount() == 3:
         exp0 = self.visit(ctx.exp3())
         exp1 = self.visit(ctx.exp4())
         op = self.visit(ctx.multiplicativeOperator())
         return BinaryOp(op,exp0,exp1)
     else:
         return self.visit(ctx.exp4())
Esempio n. 6
0
 def visitExp3(self, ctx: MPParser.Exp3Context):
     log('visitExp3')
     if ctx.getChildCount() == 1:  # exp4
         return self.visit(ctx.exp4())
     left = self.visit(ctx.exp3())
     right = self.visit(ctx.exp4())
     op = ctx.getChild(1).getText()
     log1(left)
     log1(right)
     log1(op)
     return BinaryOp(op, left, right)
     return self.visitChildren(ctx)
Esempio n. 7
0
 def visitExp3(self, ctx: MPParser.Exp3Context):
     if ctx.DIVOP():
         return BinaryOp('/', self.visit(ctx.exp3()),
                         self.visit(ctx.exp4()))
     elif ctx.MULOP():
         return BinaryOp('*', self.visit(ctx.exp3()),
                         self.visit(ctx.exp4()))
     elif ctx.DIV():
         return BinaryOp(ctx.DIV().getText(), self.visit(ctx.exp3()),
                         self.visit(ctx.exp4()))
     elif ctx.MODOP():
         return BinaryOp(ctx.MODOP().getText(), self.visit(ctx.exp3()),
                         self.visit(ctx.exp4()))
     elif ctx.ANDOP():
         return BinaryOp(ctx.ANDOP().getText(), self.visit(ctx.exp3()),
                         self.visit(ctx.exp4()))
     else:
         return self.visit(ctx.exp4())
Esempio n. 8
0
    def visitExp3(self, ctx:MPParser.Exp3Context):
        op = ""
        if ctx.DIVOP(): op = ctx.DIVOP().getText()
        elif ctx.MULOP(): op = ctx.MULOP().getText()
        elif ctx.DIV(): op = ctx.DIV().getText()
        elif ctx.MOD(): op = ctx.MOD().getText()
        elif ctx.AND(): op = ctx.AND().getText()
        else: return self.visit(ctx.exp4())

        return BinaryOp(op, self.visit(ctx.exp3()), self.visit(ctx.exp4()))
 def visitExp3(self, ctx: MPParser.Exp3Context):
     if ctx.exp3():
         if ctx.DIVISION():
             return BinaryOp(ctx.DIVISION().getText(),
                             self.visit(ctx.exp3()), self.visit(ctx.exp4()))
         elif ctx.MUL():
             return BinaryOp(ctx.MUL().getText(), self.visit(ctx.exp3()),
                             self.visit(ctx.exp4()))
         elif ctx.DIV():
             return BinaryOp(ctx.DIV().getText(), self.visit(ctx.exp3()),
                             self.visit(ctx.exp4()))
         elif ctx.AND():
             return BinaryOp(ctx.AND().getText(), self.visit(ctx.exp3()),
                             self.visit(ctx.exp4()))
         elif ctx.MOD():
             return BinaryOp(ctx.MOD().getText(), self.visit(ctx.exp3()),
                             self.visit(ctx.exp4()))
         else:
             return BinaryOp("Unknown", self.visit(ctx.exp3()),
                             self.visit(ctx.exp4()))
     else:
         return self.visit(ctx.exp4())
Esempio n. 10
0
 def visitExp3(self, ctx: MPParser.Exp3Context):
     if (ctx.ADD()):
         return BinaryOp("+", self.visit(ctx.exp3()),
                         self.visit(ctx.exp4()))
     elif (ctx.SUBNE()):
         return BinaryOp("-", self.visit(ctx.exp3()),
                         self.visit(ctx.exp4()))
     elif (ctx.OR()):
         return BinaryOp(ctx.OR().getText(), self.visit(ctx.exp3()),
                         self.visit(ctx.exp4()))
     else:
         return self.visit(ctx.exp4())