emcode/README.md

69 lines
1.3 KiB
Markdown

# Emcode
Embeddable code compiler
```
// comment
var a = 0 // create var (you can not create var without initial value)
a = 1 // int, set var
a = "123" // string, dynamic var type
a = {"11": "11"} // map (map<string, string>)
a."11" = "44" // set value to map item
a = {"11", "12"} // list (map<int, string>)
a.0 = "55" // set value to list element
a = 0.41 // float
var c = 10
c = c + a // addition (works with string+string=string)
c = c - a // subtraction
c = c * a // multiplication (works with string*int=string)
c = c / a // division
c = c % a // module
//
// var types:
// int, float, map[key, value], string, null, function, bool
{
var b = 0
// this is scope
// <- here local vars for scope
}
// <- here global vars for scope
// global scope cant see local vars (var b in this case)
if a == 0.42 {
// works totally like scope
} else {
// has no else if or elif
}
// logical operations:
// a == b a equals b
// a >= b a greater than or equals b
// a <= b a less than or equals b
// a > b a greater than b
// a < b a less than b
// a != b a not equals b
// a || b a or b
// a && b a and b
// !a not a
var func = [arg, arg2] { // create function. also work like scope
return "123"
}
func ["arg1", "arg2"] // run function
```