Skip to content

A little scripting language written in rust.

License

Notifications You must be signed in to change notification settings

baby-steve/kaon-lang

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to Kaon

Rust

A little scripting language written in rust.

Examples

Hello World

A simple hello world program:

System.println("Hello, World!")

Classes

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.

Features

  • Object-oriented
  • Bytecode compiler and VM
  • Simple, straightforward syntax
  • Strongly typed; the compiler does its best to eliminate runtime errors

  • Getting Started

    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

    Usage

    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.

    Contributing

    All contributions are welcome! If you find any bugs or have ideas to make the language better, you can open up an issue.

    License

    Kaon is avaliable under the permissive MIT license.

    About

    A little scripting language written in rust.

    Resources

    License

    Stars

    Watchers

    Forks

    Releases

    No releases published

    Packages

    No packages published

    Languages

    • Rust 99.6%
    • Python 0.4%