Single-Page Reference
LMScript & LMCode Cheat Sheet
Side-by-side quick reference for outer LMScript (.lms) and inner
LMCode (_lmcode_) blocks.
Outer LMScript (.lms)
1. LMScript Syntax At a Glance
lmscript_syntax.lms
# Constants, variables & 0-based collections
const DOMAIN = "lmscript.io";
x = 42;
xs = ["a", "b", "c"]; # xs[0] == "a", xs[-1] == "c"
m = {host: "db", port: 5432};
# Strings, Regex & Path literals
s1 = f"host={m.host}:{m.port}";
s2 = r"^\d+\.\d+$";
cfg = path"config/settings.json";
one = regex_find("cpu 72% mem 88%", r"\d+%"); # "72%"
all = regex_matches("cpu 72% mem 88%", r"\d+%"); # ["72%", "88%"]
pos("let x", 0);
tok = regex_find_pos("let x", r"[A-Za-z_]\w*"); # "let", pos() -> 3
# Control flow & Loops ({ } blocks, ; terminators)
if (x > 10 && m.port == 5432) {
println(s1);
} else if (x == 0) {
println("zero");
} else {
println("other");
}
for (val in xs) { println(val); }
for (k in m) { println(f"{k}={m[k]}"); }
for (i = 0; i < 5; i = i + 1) { println(i); }
# Functions (hoisted, recursion allowed, isolated locals)
fn greet(who) {
msg = f"Hello, {who}!";
return msg;
}
Inner LMCode (_lmcode_)
2. LMCode Syntax At a Glance
lmcode_syntax.lms
prog = _lmcode_ cli="lmaws" install="github:lmctl-ai/lmaws@v0.1.34";
# Strongly typed locals (let + ; required)
let count = 3;
let ratio = 1.25;
let active = true;
# Quote-lists (0-indexed!) & homogeneous maps
let names = qw(alpha beta gamma); # StrList
let nums = qi(10 20 30); # IntList
let weights = qf(0.5 1.5 2e-2); # FloatList
let tags = %(env => "prod", tier => "web"); # StrMap
# Validated JSONC heredoc -> immutable Json handle
let doc = json <<~JSON;
{ "domain": "lmscript.io", "ports": [80, 443] }
JSON
# Control flow & 0-based range
for (name in names) {
if (name == "alpha" && active) {
lmcode_return_put("first", name);
}
}
for (i in range(0, nums.len())) {
lmcode_return_put("sum", nums.at(i) + count);
}
end _lmcode_
r = run_lmcode(prog);
3. Side-by-Side Comparison: Outer LMScript vs Inner LMCode
| Aspect | Outer LMScript (.lms) |
Inner LMCode (_lmcode_ ... end _lmcode_) |
|---|---|---|
| Typing | Dynamically typed (null, boolean, number, string, array, object) |
Statically typed against dsl.schema: 2 + lmcode_std_v3 (int, float, string, bool, void, Json, host objects/enums) |
| Statement & Block Form | Statements end with ;, blocks use { ... } |
Statements end with ;, blocks use { ... }, locals use let x = ...; |
| Indexing | 0-based (xs[0], xs[-1], xs.get(i, def)) |
0-based (list.at(0), range(0, n)) |
| Functions | fn f(a, b) { ... } (hoisted, recursion allowed) |
fn f(a: int) -> int { ... } (compile-time inlined, recursion rejected) + @ann fn ... implements Interface |
| Execution Model | Statically checked workflow runtime with an explicit, separate dry-run mode | Compiled to DSLB v6 bytecode; verified & executed by native/managed host VM |