Skip to content

Latest commit

 

History

History
45 lines (31 loc) · 1.32 KB

README.md

File metadata and controls

45 lines (31 loc) · 1.32 KB

RCalc

Have you ever been twiddling your thumbs waiting for your calculator to finish calculating? Probably not, but here's an over-engineered solution anyway

rcalc is the fastest calculator for your terminal out there. rcalc carries out your math calculations 🔥 blazingly fast by compliling your expressions to Web Assembly on the fly 🔥 😎

I built this project mostly as an excuse to learn about writing parser cominbators in rust using chumsky along with the basics of building a JIT compiler targeting Web Assembly using wasm-encoder and wasmtime.

Usage

> rcalc '1 + 1 * 2 / 4'
1.4998751

Malformed input example

❯ rcalc 2 -+3
Failed to parse input expression
Error: found + expected '(', or '-'
   ╭─[<unknown>:1:4]
   │
 1 │ 2 -+3
   │    ┬
   │    ╰── found + expected '(', or '-'

Installation

To install rcalc, clone this repo and run cargo install --path . in the cloned directory. Do note that this project requires rust nightly to build.

Tests

This project uses proptest for property based testing. To run the tests, simply run

> cargo test # or `cargo nextest run` if you have `cargo-nextest` installed

For code coverage, install cargo-llvm-cov and run

cargo llvm-cov