A scripting language written in Rust
cargo build --release
./target/release/kscript <flags> file.ks
If not file is provided a repl is opened
Use -h or --help for a full list of flags
Example scripts are provided in the examples folder
./target/release/kscript ./examples/fib.ks
Use -d or --debug flag to print debugging info to STDOUT
Use -df <file> or --debug-file <file> to print the debugging info to a file
- Bool represented as t and f
- Integer
- Float
- Char
- String
- Function
- Array
Copies by value or reference depending on the type
- == Checks if two items are the same, throws error if types are not the same
All number ops check if the two types are integers, if not the operation is done as if they where floats
- + Addition
- - Subtraction
- * Multiplication
- \ Division
- \\ Modulo
- ** Exponential
All commands can be grouped with ()
1 + 2 * 3 >> 1 # 7
(1 + 2) * 3 >> 1 # 9
- + concat two strings to make a new string
new_stirng = "a" + "b"
- ++ modifies a string in place by adding a new string on to the end of it
my_string ++ "a"
- * repeat a string a number of times into a new string
new_string = "a" * 5
- [] get an element in the array/string
a = @[1, 2, 3]
a[1] >> 1
- =[] get and update an element in the array string
a = @[1, 2, 3]
a =[1] 5
a >> 1
- .[] run a function in a collection
a = @[1, 2, .x,y { x + y }]
a.[2]a[0],a[1]; >> 1
- @? get the length of the collection as an integer
a = @[1, 2, 3]
@? a >> 1
Functions are data that can be passed
.x,y,z... { <body> }
They can take any number of arguments and implicitly return the last value
add = .x,y { x + y }
add.1,2; >> 1
If nothing is on the stack when called it will try to call itself
To leave a function use ;;
e = .{ 1 == 1 ? { 2 ;; } 4 }
e.; >> 1
This will also return the last value on the stack if any
- STDOUT
- STDERR
- > IoWrite
- STDOUT, STDERR writes without a new line
"Test" > 1
- >> IoAppend
- STDOUT, STDERR writes with a new line
"Test >> 1