https://github.com/skyost/scriny
A tiny scripting language for Dart.
https://github.com/skyost/scriny
evaluation math parser script
Last synced: 5 days ago
JSON representation
A tiny scripting language for Dart.
- Host: GitHub
- URL: https://github.com/skyost/scriny
- Owner: Skyost
- License: mit
- Created: 2025-07-23T17:29:56.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-12-06T14:34:52.000Z (7 months ago)
- Last Synced: 2026-05-14T14:54:46.521Z (about 1 month ago)
- Topics: evaluation, math, parser, script
- Language: Dart
- Homepage: https://pub.dev/packages/scriny
- Size: 150 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
**Scriny** is a tiny scripting language for Dart (it's actually the concatenation of "script" and "tiny").
[](https://pub.dev/packages/scriny/score)
[](https://pub.dev/packages/scriny/score)
[](#License)
## Features
* Evaluates simple mathematical expressions.
* Supports variables of type string, number, boolean, list, map, and null.
* Includes control structures (`if`, `else`, `for`, `while`, etc.).
* Allows custom top-level functions and variables.
* Easy to use and integrate.
Scriny is already used in two of my projects :
- [Mathonaut](https://mathonaut.skyost.eu), for parsing and evaluating mathematical expressions.
- [Révise tes maths !](https://github.com/Skyost/ReviseTesMaths), for a similar purpose.
## Getting Started
Add Scriny to your project by following the instructions [here](https://pub.dev/packages/scriny/install).
## Usage
### Code
All the code examples below can be parsed using `ScrinyParser.parseProgram` and executed using
`run()`.
#### Mathematical expressions
This evaluates to `9` :
```
(2 + 1) * 3
```
This evaluates to `8` :
```
2^3
```
This evaluates to `true` :
```
2 == (1 + 1)
```
> [!NOTE]
> To negate a boolean, use the classic `!`. You can also use `!=` instead of `==`.
This evaluates to Dart’s `math.e` :
```
exp(1)
```
> [!NOTE]
> You can find all available built-in functions [here](https://pub.dev/documentation/scriny/latest/scriny/EvaluableFunction-class.html).
> We'll see how to add custom functions later.
#### Variables
This returns `8` :
```
a = 10;
b = -2;
return a + b;
```
This throws an error :
```
a = 10;
b = -2;
delete a;
return a + b;
```
This returns `"Hello world !"` :
```
list = ["Hello"];
map = {"w": "world"};
return list[0] + " " + map["w"] + " !";
```
#### Control statements
This evaluates to `1` :
```
if (true) {
return 1;
} else {
return 2;
}
```
This prints `0` to `9` and returns `null` :
```
for (i in range(10)) {
print(i);
}
```
> [!NOTE]
> If you don't return a value in your script, then `null` is returned.
> This is not the case for simple expressions (eg. `1 + 1` returns `2` once evaluated).
This returns `1998` :
```
n = 0;
while (true) {
n = n + 1;
if (n == 1998) {
break;
}
}
return n;
```
This returns `[2, 4]` :
```
list = [];
list = list + [1, 2, 3];
delete list[0];
list[1] = 4;
return list;
```
#### Custom top-level variables and functions
Adding custom top-level constants, variables and functions to Scriny is straightforward.
All you have to do is to provide a custom `EvaluationContext` to `ScrinyParser.parseProgram`.
Check out the example on [pub.dev](https://pub.dev/packages/Scriny/example), and see the
[`EvaluationContext`](https://pub.dev/documentation/scriny/latest/scriny/EvaluationContext-class.html)
class documentation for more information.
### Interpreter
Scriny comes with a built-in interpreter ! If you have a Scriny script file, you can run it with :
```bash
dart run scriny --file=
```
If your script consists of a single line, you can run it with :
```bash
dart run scriny --code=""
```
## License
This project is licensed under the [MIT License](https://github.com/Skyost/Scriny/blob/main/LICENSE).
## Contributions
There are many ways you can contribute to this project :
* [Fork it](https://github.com/Skyost/Scriny/fork) on GitHub.
* [Submit an issue](https://github.com/Skyost/Scriny/issues/new/choose) for a feature request or bug report.
* [Donate](https://paypal.me/Skyost) to support the developer.