Skip to content

Usage

A Lupe file is a sequence of statements. A line break ends a statement. Blank lines and indentation do not change the meaning. A block is closed with end .

A comment starts with # and runs to the end of the line. Names are case-sensitive. A name starts with an ASCII letter or underscore and continues with letters, digits, and underscores. It cannot be a keyword.

Values

Type Example
Integer 42
Float 3.14
String "Hello"
Boolean true
Null null
List [1, 2, 3]
Dictionary {"a": 1}

Integers grow with the host's memory. Floats are double-precision. Strings are immutable and may use \n , \t , \r , \\ , \" , and \' .

/ always produces a float. // divides and rounds toward negative infinity. % matches that rounding, so a equals (a // b) * b + (a % b) . ** is right-associative and binds tighter than unary minus, so -2 ** 2 is -4 . Dividing by zero is an arithmetic error. A step of zero in a numeric loop is a value error.

+ concatenates two strings. It does not convert a number to a string. Use str(10) when you need the text.

and , or , and not require booleans. and and or skip the right operand when the left operand already decides the result. Comparisons do not chain: 1 < x < 5 is a syntax error. Ordered comparison is allowed for two numbers or two strings. == compares numbers numerically, so 1 == 1.0 is true. A boolean is not a number, so true == 1 is false. Lists and dictionaries compare by value.

Names

let name = "Lupe"
let counter = 0
let result

counter = counter + 1
const PI = 3.14159265

let without a value stores null . A second let or const for the same name in the same scope is an error. A let inside a loop is one statement, so each later iteration updates that variable instead of declaring it again. Assigning a name that has not been declared is an error. A constant must be given a value and cannot be assigned again. If the constant holds a list or dictionary, the collection itself can still be changed.

A variable may hold different types over its life.

Names of built-in functions can be called, but they cannot be declared again.

Conditions and Loops

if score >= 90
    print "Excellent"
elseif score >= 70
    print "Good"
else
    print "Fail"
end

Only the first matching branch runs. The condition must be a boolean. if 1 is a type error.

while counter <= 5
    print counter
    counter += 1
end

for i = 1 to 5
    print i
end

for i = 10 to 1 step -1
    print i
end

for name in names
    print name
end

A numeric loop includes both ends. The start, end, and step are evaluated once. The default step is 1 . The loop variable is created in the current scope if it is not already there. Changing it inside the body does not change the sequence: the next value is written at the start of the next iteration.

for ... in walks a list, the characters of a string, or the keys of a dictionary in insertion order. break leaves the innermost loop. continue skips the rest of that iteration. Either word outside a loop is a syntax error.

Blocks do not create scopes. A let inside if or while belongs to the enclosing function or to the file.

Functions

function add(a, b)
    return a + b
end

print add(10, 20)

Functions are declared at the top level of a file and are not values. The call must pass one argument for each parameter. A function that does not return produces null . Functions may call themselves. The interpreter stops a chain longer than 1000 Lupe calls.

A function can read a global. An assignment inside a function writes a local name or a parameter. It does not write a global. Declare the local with let first.

let value = 10

function example()
    let value = 20
    print value
end

example()
print value

That prints 20 and then 10 .

Collections

Lists are ordered and mutable. The first index is 0 . A negative index is an index error. Dictionaries keep insertion order. Keys are strings. Reading a missing key is a key error. Assigning a missing key adds it.

let numbers = [10, 20, 30]
numbers[1] = 50

let user = {"name": "Alice"}
user["country"] = "UK"

Assigning a list or dictionary to another name shares the same collection. There is no slice syntax in this draft.

Modules

import "maths.lupe"

print maths.add(10, 20)

The import path is relative to the file that contains the import . The name before .lupe becomes the module name, and it must be a normal identifier. The file runs in its own global environment, and it runs only once. A cycle is an import error. import is allowed at the top level of a file.

maths.add calls a function in that module. maths.ANSWER reads a global from that module. A function is not a value, so it can be called but not stored.

Output

print is a statement, not a function. Values are separated by one space and the line ends with a newline. Strings are printed without quotes. Inside a list or dictionary they are quoted.

print "Result:", 42

input(prompt) writes the prompt and returns one line without the newline.