def visitExp(self, ctx: MCParser.ExpContext):
     #exp: exp1 ASSIGN exp | exp1;
     if ctx.getChildCount() == 3:
         return BinaryOp(ctx.ASSIGN().getText(), self.visit(ctx.exp1()),
                         self.visit(ctx.exp()))
     else:
         return self.visit(ctx.exp1())
示例#2
0
 def visitExp(self, ctx:MCParser.ExpContext):
     if (ctx.getChildCount() == 1):
         return self.visit(ctx.exp1())
     left = self.visit(ctx.exp1())
     right = self.visit(ctx.exp())
     op = ctx.ASSIGN().getText()
     return BinaryOp(op,left,right)
示例#3
0
 def visitExp(self, ctx: MCParser.ExpContext):
     if (ctx.getChildCount() == 1):
         return self.visit(ctx.getChild(0))
     else:
         return BinaryOp(
             ctx.getChild(1).getText(), self.visit(ctx.exp1()),
             self.visit(ctx.exp()))
示例#4
0
 def visitExp(self, ctx: MCParser.ExpContext):
     '''exp: exp OR exp1 | exp1 ;'''
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp1())
     else:
         left = self.visit(ctx.exp())
         right = self.visit(ctx.exp1())
         return BinaryOp(ctx.OR().getText(), left, right)
示例#5
0
 def visitExp(self, ctx:MCParser.ExpContext):
     
     if (ctx.getChildCount() == 1):
         return self.visit(ctx.exp1())
     else:
         exp1 = self.visit(ctx.exp1())
         exp0 = self.visit(ctx.exp())
         Assign = ctx.getChild(1).getText()   
         return BinaryOp(Assign,exp1,exp0)
示例#6
0
    def visitExp(self, ctx: MCParser.ExpContext):
        if ctx.ASSIGN():
            op = ctx.ASSIGN().getText()
            left = self.visit(ctx.term1())
            right = self.visit(ctx.exp())
            exp = BinaryOp(op, left, right)
        else:
            exp = self.visit(ctx.getChild(0))

        return exp
示例#7
0
 def visitExp(self, ctx: MCParser.ExpContext):
     if ctx.getChildCount() == 3:
         op = ctx.getChild(1).getText()
         left = ctx.term(0).accept(self)
         right = ctx.term(1).accept(self)
         return Binary(
             op, left,
             right)  # return a Binary object for the first right hand side
     else:
         return ctx.term(0).accept(
             self)  # generate code for the second right hand side
 def visitExp(self, ctx: MCParser.ExpContext):
     if ctx.getChildCount() == 3:
         return BinaryOp(ctx.OP_ASSIGN().getText(), self.visit(ctx.term1()),
                         self.visit(ctx.exp()))
     else:
         self.visit(ctx.getChild(0))
示例#9
0
 def visitExp(self, ctx: MCParser.ExpContext):
     if ctx.ASSIGN():
         return BinaryOp(ctx.ASSIGN().getText(), self.visit(ctx.exp1()),
                         self.visit(ctx.exp()))
     return self.visit(ctx.exp1())
示例#10
0
 def visitExp(self, ctx: MCParser.ExpContext):
     return Binary(ctx.COMPARE().getText(), self.visit(
         ctx.term(0)), self.visit(
             ctx.term(1))) if ctx.COMPARE() else self.visit(ctx.term(0))
示例#11
0
 def visitExp(self, ctx: MCParser.ExpContext):
     if ctx.getChildCount() == 3:
         return None  # return a Binary object for the first right hand side
     else:
         return None  # generate code for the second right hand side
示例#12
0
 def visitExp(self, ctx: MCParser.ExpContext):
     return BinaryOp(ctx.ASSIGNOP().getText(), self.visit(ctx.exp1()),self.visit(ctx.exp())) if ctx.getChildCount() == 3 \
         else self.visit(ctx.exp1())
示例#13
0
 def visitExp(self, ctx: MCParser.ExpContext):
     # exp: exp1 ASSIGN exp | exp1;
     return BinaryOp(ctx.ASSIGN().getText(), self.visit(ctx.exp1()),
                     self.visit(ctx.exp())) if ctx.ASSIGN() else self.visit(
                         ctx.exp1())
示例#14
0
 def visitExp(self, ctx: MCParser.ExpContext):
     if ctx.ASSIGN():
         return BinaryOp('=', self.visit(ctx.exp1()), self.visit(ctx.exp()))
     else:
         return self.visit(ctx.exp1())
示例#15
0
 def visitExp(self, ctx: MCParser.ExpContext):
     return int('-' + ctx.INTLIT().getText()) if ctx.SIGN() else int(
         ctx.INTLIT().getText())
示例#16
0
 def visitExp(self, ctx: MCParser.ExpContext):
     if (ctx.funcall()):
         return self.visit(ctx.funcall())
     else:
         return IntLiteral(int(ctx.INTLIT().getText()))