Exemplo n.º 1
0
 def visitExpr(self, ctx: MPParser.ExprContext):
     if ctx.getChildCount() == 1:
         return self.visit(ctx.expr1())
     if ctx.AND() and ctx.THEN():
         return BinaryOp("andthen", self.visit(ctx.expr()),
                         self.visit(ctx.expr1()))
     elif ctx.OR() and ctx.ELSE():
         return BinaryOp("orelse", self.visit(ctx.expr()),
                         self.visit(ctx.expr1()))
Exemplo n.º 2
0
 def visitExpr(self, ctx: MPParser.ExprContext):
     #BinaryOp
     #op:string: AND THEN => andthen; OR ELSE => orelse; other => keep it
     #left:Expr
     #right:Expr
     #def __init__(self, op, left, right):
     pass
     if ctx.getChildCount() == 4:
         if ctx.ANDOP() and ctx.THEN():
             return BinaryOp("andthen", self.visit(ctx.expr()),
                             self.visit(ctx.exp0()))
         elif ctx.OROP() and ctx.ELSE():
             return BinaryOp("orelse", self.visit(ctx.expr()),
                             self.visit(ctx.exp0()))
     else:
         return self.visit(ctx.exp0())