While Test True Store Property

If there is a while statement at the current line and tab and the "while" test evaluated to True, then set a new entry with the current tab and line numbers in the "Control" map. More formally,

if the following are true:
  • the line at time t = i
  • the tab at time t = j
  • statement at line i, tab j = "while" statement with condition (function call with name: name and arguments: args)
  • expression state at time t = "end_expr"
  • Return Value at time t = True

then Control Map at time (t + 1) = result of storing (pair ("while", i)) at key: j in map: (Control Map at time t)

When the "while" statement test is True, LW Python remembers the line number so that at the end of the "while" body, LW Python can return to the "while" statement and evaluate the test again.

For example, if the following are true:

  • the line at time 11 = 2
  • the tab at time 11 = 0
  • statement at line 2, tab 0 = while __lt__(a, 2):
  • expression state at time 11 = "end_expr"
  • Return Value at time 11 = True
  • Control Map at time 11 = [ ]

then Control Map at time (11 + 1) = result of storing (pair ("while", 2)) at key: 0 in map: (Control Map at time 11)

The new entry key is the current tab number. The entry value is the pair "while":2, which indicates that there is a "while" statement at line 2. Try stepping through the simulator to see line 2 added to the "Control" map.

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments