51 lines
939 B
Markdown
51 lines
939 B
Markdown
# Mako
|
|
|
|
Scripting language!
|
|
|
|
```
|
|
// C-style comments
|
|
/*
|
|
C-style multiline comments
|
|
*/
|
|
|
|
/*
|
|
The language's intent and design should mimic Lua as much as possible.
|
|
There is a global table that is accessible, but all variables are implicitly
|
|
local.
|
|
*/
|
|
var = 2 // in the global scope
|
|
var2 = 4 // also in global scope
|
|
echo var + var2 // outputs 6
|
|
|
|
fn function_name(arg1, arg2)
|
|
var3 = "hi" // implicitly local to this block
|
|
var4 = var + var3 // var4 = "2hi"
|
|
var5 = "hello" + "world"
|
|
return var5
|
|
end
|
|
|
|
/*
|
|
Tables work like lua but are ordered hash maps in implementation, and coerced to arrays
|
|
if it makes sense to do so. Trailing comma is optional
|
|
*/
|
|
var6 = {
|
|
table1 = "foo",
|
|
"table2" = 42,
|
|
240 = anothertable
|
|
}
|
|
var6[lol] = "foo"
|
|
|
|
if condition then
|
|
// do stuff
|
|
elseif condition2 then
|
|
// do stuff
|
|
else
|
|
// do stuff
|
|
end
|
|
|
|
var7 = condition ? left : right
|
|
|
|
for k, v in any_table do
|
|
// ordered hash map, so ipairs/pairs not necessary
|
|
end
|