Else Statement Tab Property

If the current statement is an "else" statement, and the corresponding "if" statement tested False, then increment the tab number by 1. 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 = else:
  • value at j in map (Control Map at time t) = pair ("if", False)

then the tab at time (t + 1) = j + 1

If the "if" statement previously tested False, then the "else" statement body will be executed. The "else" body's tab number is the "else" statement's tab number + 1, so increment the current tab number by 1.

For example, if the following are true:

  • the line at time 12 = 3
  • the tab at time 12 = 0
  • statement at line 3, tab 0 = else:
  • value at 0 in map (Control Map at time 12) = pair ("if", False)

then the tab at time (12 + 1) = 0 + 1

The "Control" map indicates that at tab 0, there was an "if" statement that tested false.

Try stepping through the simulator to see LW Python increment the tab number by 1

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments