An example implementation of the Shunting-yard algorithm in Rust
UNLICENSE License
An example implementation of Edsger Dijkstra's Shunting-yard algorithm in Rust.
This implementation handles:
+
, -
, *
, /
, and ^
(exponent) operators+
and -
operatorsShunting Rust includes a regex-based lexer, the shunting-yard parser, an evaluator for the resulting trees, and a simple read-eval-print loop for checking the program interactively.
It also includes a small set of tests for each component.
Shunting Rust should run on the latest stable version of Rust -- just clone the repository and use cargo test
to run tests or cargo run
to try out the REPL!
$ git clone https://github.com/LPGhatguy/shunting-rust.git
$ cd shunting-rust
$ cargo run
> 1 + 2
3
I started this repository to practice parser construction and idiomatic Rust. It's intended to be an educational resource, but it isn't perfect!
Shunting Rust is notably lacking:
If you spot any errors, major or minor, feel free to open an issue or pull request!
Shunting Rust is available under The Unlicense. See LICENSE.md for details.