Interpreter
The interpreter walks the syntax tree. A statement node runs for its effect. An expression node returns a value. The walk is ordinary Python method calls, one per node kind, which is why a reader can follow a program statement by statement.
Values are Python objects with Lupe's type rules on top.
null
is
None
. An integer is a Python
int
, which already has arbitrary precision. A float is a Python
float
. Booleans are checked before integers, because Python's
bool
is a subclass of
int
. A Lupe boolean is never treated as
0
or
1
unless the program calls
bool()
the other way, through
int(true)
.
Names
A file has one global environment.
let
adds a name there. A
let
with no value stores
null
. Using
let
again for the same name in that scope is a runtime error. An assignment without
let
updates a name that already exists, and it is an error when the name was never declared.
const
uses the same environment and records that the binding cannot be replaced. The binding stops a later assignment. It does not freeze a list or dictionary stored in that name, so
append
on a constant list still changes the list.
The same
let
may run again inside a loop. Blocks do not create a new scope, so a second iteration would otherwise look like a redeclaration. The binding remembers the declaration node. Running that same node again updates the value. A different
let
for the same name is still an error.
Output
print
is a statement, not a function. The interpreter writes each value, separated by one space, and then a newline. Strings are written without quotes. Strings nested inside a list or dictionary are quoted so the structure stays readable.