Crates.io | kdl-script |
lib.rs | kdl-script |
version | 0.4.1 |
source | src |
created_at | 2022-10-05 02:09:21.273284 |
updated_at | 2024-07-12 18:51:53.563786 |
description | execute kdl documents! |
homepage | https://faultlore.com/abi-cafe/book |
repository | https://github.com/Gankra/abi-cafe |
max_upload_size | |
id | 680260 |
size | 148,278 |
KDLScript, the KDL-based programming language!
KDLScript ("Cuddle Script") is a "fake" scripting language that actually just exists to declare type/function signatures without tying ourselves to any particular language's semantics. It exists to be used by ABI Cafe.
Basically, KDLScript is a header format we can make as weird as we want for our own usecase:
struct "Point" {
x "f32"
y "f32"
}
enum "ScaleMode" {
Width
Height
}
fn "print" {
inputs { _ "Point"; }
}
fn "scale" {
inputs { _ "Point"; factor "f32"; scalemode "ScaleMode"; }
outputs { _ "Point"; }
}
fn "sum" {
inputs { _ "&[Point; 4]"; }
outputs { _ "Point"; }
}
Ultimately the syntax and concepts are heavily borrowed from Rust, for a few reasons:
The ultimate goal of this is to test that languages can properly communicate over FFI by declaring the types/interface once and generating the Rust/C/C++/... versions of the program (both caller and callee) and then linking them into various combinations like "Rust calls C++" to check that the values are passed correctly.
kdl-script is both a library and a CLI application. The CLI is just for funsies.
The main entry point to the library is Compiler::compile_path
or Compiler::compile_string
, which will produce a TypedProgram
. See the types
module docs for how to use that.
The CLI application can be invoked as kdl-script path/to/program.kdl
to run a KDLScript program.