#dsl #intended #math #pink #definition #repl #replecement

bin+lib pink-runtime

A very minimal replecement based DSL, intended for math

2 releases

0.1.1 Feb 19, 2023
0.1.0 Feb 10, 2023

#919 in Text processing

23 downloads per month

GPL-3.0+

50KB
1K SLoC

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

Dependencies

~8–20MB
~271K SLoC