Just a stack based language
cargo build
./target/debug/jsl source.jsl
Functions can defined with fn
keyword, for example
import std
fn callme -> {
str Helloworld printstr
}
call callme
output:
HelloWorld
also you can specify a arguments of a function after name of function for example:
fn callme x y z -> {
x put
y put
z put
}
1 2 3 call callme
output:
3
2
1
You can define object in Jsl with object
keyword
example:
object {
x = 1
y = 2
}
This will push the pointer to the object to stack
also you can get the property of object with get
keyword like:
get x
let
is like global variables, unlike macros let cant hold expression only holds value float64
usage:
10 let x
x put
this will return 10
You can set let value with set
keyword
for example:
30 set x
x put
this will return 30
str HelloWorld put
result will be
HelloWorld
true
-> will push 1 to stack
false
-> will push 0 to stack
for Eq if two last elements in stack is equal , this will push bool to stack
1 2 eq put
will return 0
For not equal
1 2 eq put
will return 1
then
runs function if the top of stack is true
example:
1 1 eq then {
1 put
}
times
is a keyword like for
loops
times will pop the top of stack and do body of times x times
example:
3 times {
1 print
}
will return:
1
1
1
example:
import lib.jsl
call test
will return:
HelloWorld
lib.jsl:
fn test -> {
str HelloWorld putstr
}
Reverse Polish notation. (2023, August 14). In Wikipedia. https://en.wikipedia.org/wiki/Reverse_Polish_notation
Stack-oriented programming. (2023, July 30). In Wikipedia. https://en.wikipedia.org/wiki/Stack-oriented_programming