def visitExp1(self, ctx: MCParser.Exp1Context):
     #exp1: exp1 OR exp2 | exp2;
     if ctx.getChildCount() == 3:
         return BinaryOp(ctx.OR().getText(), self.visit(ctx.exp1()),
                         self.visit(ctx.exp2()))
     else:
         return self.visit(ctx.exp2())
Example #2
0
 def visitExp1(self, ctx:MCParser.Exp1Context):
     if (ctx.getChildCount() == 1):
         return self.visit(ctx.exp2())
     left = self.visit(ctx.exp1())
     right = self.visit(ctx.exp2())
     op = ctx.OR().getText()
     return BinaryOp(op,left,right)
Example #3
0
 def visitExp1(self, ctx: MCParser.Exp1Context):
     if (ctx.getChildCount() == 1):
         return self.visit(ctx.getChild(0))
     else:
         return BinaryOp(
             ctx.getChild(1).getText(), self.visit(ctx.exp1()),
             self.visit(ctx.exp2()))
Example #4
0
 def visitExp1(self, ctx:MCParser.Exp1Context):
     if (ctx.getChildCount() == 1):
         return self.visit(ctx.exp2())
     else:
         or_ = ctx.getChild(1).getText()
         exp1 = self.visit(ctx.exp1())
         exp2 = self.visit(ctx.exp2())
         return BinaryOp(or_,exp1,exp2)
Example #5
0
 def visitExp1(self, ctx: MCParser.Exp1Context):
     '''exp1: exp1 AND exp2 | exp2 ; '''
     if ctx.getChildCount() == 1:
         return self.visit(ctx.exp2())
     else:
         left = self.visit(ctx.exp1())
         right = self.visit(ctx.exp2())
         return BinaryOp(ctx.AND().getText(), left, right)
Example #6
0
 def visitExp1(self, ctx: MCParser.Exp1Context):
     if ctx.getChildCount() == 3:
         return BinaryOp(ctx.LOGICALOR().getText(), self.visit(ctx.exp1()),
                         self.visit(ctx.exp2()))
     else:
         return self.visit(ctx.exp2())
Example #7
0
 def visitExp1(self, ctx: MCParser.Exp1Context):
     return BinaryOp(ctx.OROP().getText(), self.visit(ctx.exp1()),self.visit(ctx.exp2())) if ctx.getChildCount() == 3 \
         else self.visit(ctx.exp2())