Crates.io | kaon |
lib.rs | kaon |
version | 0.1.4 |
source | src |
created_at | 2022-05-26 19:18:07.438987 |
updated_at | 2022-05-26 19:18:07.438987 |
description | A little scripting language written in rust |
homepage | |
repository | https://github.com/PlutonianHacker/kaon-lang |
max_upload_size | |
id | 594334 |
size | 293,636 |
A little scripting language written in rust.
A simple hello world program:
System.println("Hello, World!")
A slightly more convoluted example using classes:
class Vector {
// A field
var x = 0
var y = 0
// A constructor
create new(a, b) {
self.x = a
self.y = b
}
fun add(other: Vector) {
self.x = self.x + other.x
self.y = self.y + other.y
}
// A method
fun to_string() {
return "{ x: " + self.x + " y: " + self.y + " }"
}
}
fun main() {
var v1 = Vector.new(4, 5)
var v2 = Vector.new(6, 7)
v1.add(v2)
print(v1.to_string()) // -> { x: 10 y: 12 }
}
main()
More examples can be found in scripts or tests/kaon.
To get started using kaon, first make sure you have cargo installed, then run the following commands:
git clone https://github.com/PlutonianHacker/kaon-lang.git
cd kaon-lang
cargo build
Currently the only way to run a Kaon script is with cargo run
inside the kaon-lang directory.
To run a file, use cargo run <FILE.kaon>
, if no file is provided, interactive mode is run instead. To see a list of options, run cargo run -- --help
.
All contributions are welcome! If you find any bugs or have ideas to make the language better, you can open up an issue.
Kaon is avaliable under the permissive MIT license.