Live playground: the compiler, in your browser
The self-hosted PatLang compiler (lexer, parser, lowerer) compiled to WebAssembly. Edit the program, press Run: your source is tokenized, parsed, and lowered by PatLang code running in this page, then executed on the runtime VM. No server, no rustc.
# Edit me, then press Run. This compiles and executes in your browser.
make a function called fib takes n returns r
if n < 2 then
return n
else
return fib(n - 1) + fib(n - 2)
end
end
when greeting do
print("event says: " + event_data)
end
let xs = [3, 1, 4, 1, 5, 9, 2, 6]
let total = 0
let i = 0
while i < xs.length do
let total = total + xs[i]
let i = i + 1
end
print("sum of " + xs + " is " + total)
print("fib(20) = " + fib(20))
emit("greeting", "hello from the browser")
(not run yet)