A simple program that takes expressions like 5 + 8 * (7-1)
and parses them into a syntax tree. GRAMMAR.md explains the process in greater detail. A few things will be implemented like executing the syntax tree that lexer and parser create. This is really just an experiment to see how a context-free grammar-based parser might be implemented in Rust
.
A Makefile
makes running the code in this repository easy:
bash
make
make test # runs the binary with appropriate parameters (especially `-e <expr>')
make err1 # demonstrates an error; `err2' and `err3' exist, too
But cargo
can be used, too. E.g., install the binary from crates.io with:
bash
cargo install expr_parser
expr_parser --help # validates a successful installation
graphviz
must be installed on your system. If you make
and make test
, .gv
and .pdf
files will be created in the project root. Refer to the Makefile
or run make help
for available parameters.
evaluate
function[]
, log2
, log10
$var
syntax), using a stack machineThe code in this repository is MIT-licensed (see LICENSE.md).