val
val (eval) is a simple arbitrary precision calculator language built on top of chumsky and ariadne.
Installation
val should run on any system, including Linux, MacOS, and the BSDs.
The easiest way to install it is by using cargo, the Rust package manager:
Pre-built binaries
Pre-built binaries for Linux, MacOS, and Windows can be found on the releases page.
Usage
The primary way to use val is via the provided command-line interface. There is currently ongoing work on a Rust library and web playground, which will provide a few extra ways to interact with the runtime.
Below is the output of val --help, which describes some of the
arguments/options we support:
Usage: val [OPTIONS] [FILENAME]
Arguments:
[FILENAME]
Options:
-e, --expression <EXPRESSION>
-h, --help Print help
-V, --version Print version
Running val on its own will spawn a repl (read–eval–print loop) environment, where you can evaluate arbitrary val code and see its output immediately. We use rustyline for its implementation, and we support a few quality of life features:
- Syntax highlighting (see image above)
- Persistent command history
- Emacs-style editing support by default
- Filename completions
- Hints (virtual text pulled from history)
The val language supports not only expressions, but quite a few statements as well. You may want to save val programs and execute them later, so the command-line interface provides a way to evaluate entire files.
For instance, lets say you have the following val program at
factorial.val:
println;
You can execute this program by running val factorial.val, which will write to
standard output 120.
Lastly, you may want to evaluate a val expression and use it within another
program. The tool supports executing arbitrary expressions inline using the
--expression or -e option:
n.b. The --expression option and filename argument are mutually
exclusive.
Features
This section describes some of the language features val implements in detail, and should serve as a guide to anyone wanting to write a val program.
Statements
val supports a few statement constructs
Prior Art
bc(1) - An arbitrary precision calculator language