1 unstable release
0.6.1 | Nov 13, 2022 |
---|
#764 in Configuration
96KB
2K
SLoC
Avid
A configuration language for programs with a Forth-like syntax, intended to be as plug-and-play as possible.
NOTE: The language is currently in a beta state
I am working on fixing this as soon as possible, but it should be known!
Documentation
To see the Avid documentation, check out the syntax and the standard library!
Quick Start
To add it as a configuration language to your program, add it to your dependencies in your Cargo.toml, like so:
[dependencies]
avid = {version = "*", git = "https://www.gitlab.com/daisyflare/avid"}
If you want to just use the language itself, you can do that like so:
$ git clone "https://www.gitlab.com/daisyflare/avid"
$ cd avid
$ cargo build --release && cp target/release/avid .
$ ./avid
lib.rs
:
Plug and play configuration language.
Provides a simple API to insert this configuration language into your project. The language is easy to learn and checks for many common errors, including unknown variables and malformed statements, at (Avid's) compile time.
The available APIs and other settings can be tweaked or modified easily by using the different methods on the [Builder] struct.
Examples
use avid::{Builder, Stack};
let src = "1 2 + print \"Hello, World!\" print-to-log";
let mut log = String::new();
let avid = Builder::new(src)
// Add a new function that pops one item from the top of the stack
// and prints it to the log
.register_fn("print-to-log", |stack: &mut Stack| {
let [to_print] = stack.pop()?;
log.push_str(&to_print.to_string());
Ok(())
})
.build().unwrap();
// Prints `3` to standard output
avid.run(None).unwrap();
assert_eq!(&log, "Hello, World!");
You can use any function with the correct signature, including closures.