File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ from ast import *
2+ from interp_Pif import InterpPif
3+ from utils import *
4+
5+ class InterpPwhile (InterpPif ):
6+
7+ def interp_stmts (self , ss , env ):
8+ if len (ss ) == 0 :
9+ return
10+ match ss [0 ]:
11+ case While (test , body , []):
12+ while self .interp_exp (test , env ):
13+ self .interp_stmts (body , env )
14+ return self .interp_stmts (ss [1 :], env )
15+ case _:
16+ return super ().interp_stmts (ss , env )
17+
Original file line number Diff line number Diff line change 1+ from ast import *
2+ from type_check_Pvar import check_type_equal
3+ from type_check_Pif import TypeCheckPif
4+ from utils import *
5+
6+ class TypeCheckPwhile (TypeCheckPif ):
7+
8+ def type_check_stmts (self , ss , env ):
9+ if len (ss ) == 0 :
10+ return
11+ match ss [0 ]:
12+ case While (test , body , []):
13+ test_t = self .type_check_exp (test , env )
14+ check_type_equal (bool , test_t , test )
15+ body_t = self .type_check_stmts (body , env )
16+ return self .type_check_stmts (ss [1 :], env )
17+ case _:
18+ return super ().type_check_stmts (ss , env )
19+
You can’t perform that action at this time.
0 commit comments