Mako/README.md

59 lines
1.2 KiB
Markdown

# Mako
Lightweight, efficient Lua-like scripting language with a Go backend!
the go mod is `git.sharkk.net/Sharkk/Mako`
### Lexing & Parsing
Recursive descent + Pratt parsing.
Scanner should move through tokens with virtually no allocations.
Easy-to-consume AST for bytecode compilation.
### VM
Stack-based VM, register-based optimizations where it makes sense for performance, and a very minimal bytecode
format to preserve space.
### Memory Management
Go's GC is robust and can be used for most needs; the internals can pool commonly used structures to reduce pressure.
## Syntax
Lua-like, but with more minimalism and eventually some syntactic sugars.
```
// C style comments
/*
C style multi line comments
*/
// No local for variable definitions; the local behavior should be implicit
x = "foo"
y = "bar"
fn add(a, b)
return a + b
end
echo add(x, y) // Outputs: foobar
fnVar = fn(x, y, ...) /* do something */ end
if expression and expression2 then
res = add(1, 2)
elseif otherExpression() then
// do other stuff
else
// final thing
end
// Table order is preserved, unlike Lua
table = {
anything = "foo",
123 = "arg"
}
echo table["anything"] // outputs foo
echo table.anything // outputs foo
table.rawr = "mega"
table["mega"] = "rawr"
```