Crates.io | pink-runtime |
lib.rs | pink-runtime |
version | 0.1.1 |
source | src |
created_at | 2023-02-10 12:44:19.600582 |
updated_at | 2023-02-19 10:55:46.567944 |
description | A very minimal replecement based DSL, intended for math. |
homepage | |
repository | https://github.com/Odilf/pink |
max_upload_size | |
id | 781832 |
size | 66,989 |
A very minimal replecement based DSL, intended for math.
WARNING: This is still in extremely early stages. Don't expected anything.
To install pink as a binary, if you have cargo just do
cargo install pink-runtime
Then, to run a program you can run
pink-runtime [PATH]
To see more information you can do
pink-runtime --help
To use pink as a library, you can add it as any other crates.io dependency (though I would recommend to use it as a git dependency).
Each file corresponds to a structure. At the top of each file you have to delcare it's domain, a set of reserved keywords and it's dependencies.
domain { true, false }
reserve { in } # Commas, curly braces and parenthesis are reserved by the runtime itself
use { }
After the head, you can have a series of definitions. A definition may have concrete elements from the domain or literals from the reserved keywords. Anything else is considered a variable (really, anything, including mathematical symbols).
true and true => true;
p and q => false;
Expressions are matched from top to bottom. So, while p
and q
are normally able to bind to true
, given the order of the definitions here we won't ever reach that case.
If a variable ends with ...
, then it can capture an arbitrary amount of items (but at least 1 (this might change)).
x in { } => false;
x in { x } => true;
x in { y } => false;
x in { x, rest... } => true;
x in { y, rest... } => x in { rest... };
The runtime matches every possible subexpression and finds the result with the least number of tokens in the end.
In the REPL you can evaluate expressions. For now, an expression only has elements and literals (no variables).
>> false in { false }
true