pink-runtime

Crates.iopink-runtime
lib.rspink-runtime
version0.1.1
sourcesrc
created_at2023-02-10 12:44:19.600582
updated_at2023-02-19 10:55:46.567944
descriptionA very minimal replecement based DSL, intended for math.
homepage
repositoryhttps://github.com/Odilf/pink
max_upload_size
id781832
size66,989
(Odilf)

documentation

README

pink

A very minimal replecement based DSL, intended for math.

WARNING: This is still in extremely early stages. Don't expected anything.

Get started

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).

Documentation

Head

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 { }

Definitions

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.

Spread variables

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... };

Matching

The runtime matches every possible subexpression and finds the result with the least number of tokens in the end.

REPL

In the REPL you can evaluate expressions. For now, an expression only has elements and literals (no variables).

>> false in { false }
true
Commit count: 43

cargo fmt