Initialize Expression Property

If LW Python is in the "not_expr" state and the next statement to execute is an expression, then update LW Python's internal "Expression" to the expression. 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 = c
  • expression state at time t = "not_expr"
  • c is constant

then the expression at time (t + 1) = c

"Expression" is data that LW Python uses internally to track which expression is currently being evaluated. Thus, "Expression" is set to the current expression, whether it is a constant, variable, or a function call.

For example, if the following are true:

  • the line at time 0 = 1
  • the tab at time 0 = 0
  • statement at line 1, tab 0 = 5
  • expression state at time 0 = "not_expr"

then the expression at time (0 + 1) = 5

Try clicking "Next" on the simulator to see the "Expression."

Code Editor
LW Python State
Current Line1Current Tab0Time0
LW Python Simulator

Comments

Please log in to add comments