\ LSR Language - Documentation & Playground
LSR Lang
ESP32 Embedded Scripting Engine

Master Embedded Scripting with LSR

LSR is a robust interpreted language built in C++ specifically for ESP32 microcontrollers. Version 2.5 supports functions with arguments and call stacks, dynamic list collections, conditional branches, loops, and shorthand variable declarations.

Explore Full Reference

Functions & Local Scopes

Define reusable blocks using function name(param) with dedicated call frame local variables and return handling.

List Array Collections

Store collections of numbers easily with syntax like list scores = [90, 85, 95]; and access elements dynamically.

ESP32 Flash & Watchdog

Engineered with a 5-second execution watchdog timer and fast symbol table lookups for optimal embedded microcontroller performance.

Complete Language Reference & Guides

Detailed documentation covering variables, functions, list arrays, conditions, and loops with copyable examples.

Variables & Output

Shorthand Declarations & wrightv()

Declare variables instantly using shorthand keywords like gan hi = 2; or explicit types like gan num val = 42;. Output values and strings to the ESP32 Serial Monitor using wrightv().

  • Automatic integer and string type inference
  • String concatenation supported with + operator
variables.lsr
gan hi = 2;
wrightv(hi);

gan message = "Hello ESP32!";
wrightv(message);
functions.lsr
function calculateArea(width, height) {
    gan area = width * height;
    wrightv("Calculated Area: " + area);
}

calculateArea(5, 10);
Functions & Scoping

Defining Functions & Parameters

Organize your code into modular routines using function name(param1, param2). Functions maintain local execution scopes via call frames and support return statements.

  • Pass multiple arguments separated by commas
  • Local variables do not pollute global scope
Collections

List Arrays (list)

Store sequences of numeric values easily using bracket notation list name = [val1, val2];. Access individual elements dynamically using zero-based index syntax.

  • Dynamic indexing like scores[0]
  • Optimized for fast flash lookup
lists.lsr
list scores = [90, 85, 95];
wrightv("First score:");
wrightv(scores[0]);
conditions.lsr
gan temperature = 35;

if (temperature >= 30) {
    wrightv("Warning: High Temp!");
} else {
    wrightv("Temp is safe.");
}
Control Flow

Conditional Branches (if / else)

Make decisions in your scripts using if (condition) { ... } else { ... } blocks supporting comparative operators like >=, <=, and ==.

Iteration

For and While Loops (foras / whileas)

Execute repetitive tasks efficiently using foras (init; cond; update) and whileas (cond) block loops.

loops.lsr
foras (gan i = 1; i <= 3; i = i + 1) {
    wrightv("Loop count: " + i);
}

gan count = 2;
whileas (count > 0) {
    wrightv("While item: " + count);
    count = count - 1;
}