def visitIf_statement(self, ctx: MPParser.If_statementContext): thenStmt = self.visit(ctx.statement(0)) thenStmt = thenStmt if type(thenStmt) == list else [thenStmt] if ctx.ELSE(): elseStmt = self.visit(ctx.statement(1)) elseStmt = elseStmt if type(elseStmt) == list else [elseStmt] return If(self.visit(ctx.exp()), thenStmt, elseStmt) return If(self.visit(ctx.exp()), thenStmt)
def visitIf_statement(self, ctx:MPParser.If_statementContext): if ctx.getChildCount()==4: return If(self.visit(ctx.expression()),self.visit(ctx.statement(0))) elif ctx.getChildCount()==6: return If(self.visit(ctx.expression()),self.visit(ctx.statement(0)),self.visit(ctx.statement(1))) else: print("Error if child count","askjdh")
def visitIf_statement(self, ctx: MPParser.If_statementContext): if ctx.ELSE() != None: return [ If(self.visit(ctx.exp()), self.visit(ctx.statement(0)), self.visit(ctx.statement(1))) ] else: return [If(self.visit(ctx.exp()), self.visit(ctx.statement(0)))] return