예제 #1
0
 def visitWhile_stmt(self, ctx:BKITParser.While_stmtContext):
     """
     exp: Expr
     sl:Tuple[List[VarDecl],List[Stmt]]
     """
     getExpr = self.visitExp(ctx.exp())
     tempBody = []
     temp_var = []
     temp_stmt = []
     # for x in ctx.body():
     #     temp = self.visitBody(x)
     #     if temp[0] == 0:
     #         if isinstance(temp[1], list):
     #             temp_var.extend(temp[1])
     #         else:
     #             temp_var.append(temp[1])
     #     else:
     #         if isinstance(temp[1], list):
     #             temp_stmt.extend(temp[1])
     #         else:
     #             temp_stmt.append(temp[1])
     getLstBody = self.visitBody(ctx.body())
     tempBody.append(getLstBody[0])
     tempBody.append(getLstBody[1])
     getBody = (tempBody[0], tempBody[1])
     return While(getExpr, getBody)
예제 #2
0
 def visitWhile_stmt(self, ctx: BKITParser.While_stmtContext):
     bca = self.visit(ctx.stmt2())
     return While(self.visit(ctx.exp()), (bca[0], bca[1]))