XO

# rcalc [![Build Status](https://travis-ci.org/ayazhafiz/rcalc.svg?branch=master)](https://travis-ci.org/ayazhafiz/rcalc) [![Coverage Status](https://coveralls.io/repos/github/ayazhafiz/rcalc/badge.svg?branch=master)](https://coveralls.io/github/ayazhafiz/rcalc?branch=master) `rcalc` is a glorified calculator written in Rust that incorporates the fundamentals of building any programming language, including a [lexer](./src/rcalc/lexer.rs), [parser](./src/rcalc/parser/mod.rs), [Abstract Syntax Tree](./src/rcalc/ast.rs), and [AST traverser](./src/rcalc/interpreter/mod.rs). ### Try it ```bash git clone https://github.com/ayazhafiz/rcalc.git && cd rcalc make # places rcalc in /usr/bin/local rcalc # launches interactive shell $ rcalc> ... ``` ### Features Currently, `rcalc` supports * Addition, subtraction, multiplication, division * Floating-point (fractional) exponentiation * Unary Operators * Accepted operand precedence * An interactive shell for computation Todo * [x] `CLI` Access to input history * [x] `CLI` Hiding of control characters * [x] `LOGIC` Integer division * [x] `LOGIC` Modulo operator * [x] `LOGIC` Factorial operator * [ ] `LOGIC` Trigonometric functions * [ ] `OTHER` More to come! ### Structure `rcalc` is both a binary and a library. This makes it trivial to use the `rcalc` library in any other application. The [library](./src/lib.rs) is hosted under one namespace, with separate modules for independent components of the calculator "interpreter". The [binary](./src/main.rs) is entirely dependent on the library. ### Why? I was interested in learning (1) Rust and (2) how to create a programming language. I started off with [Ruslan Spivak's tutorial](https://ruslanspivak.com/lsbasi-part1/) on the latter matter, eventually deciding to work a bit more on his calculator application in the pursuit of making something fairly formidable and original in Rust. This repository is the result of that effort. Hopefully, the quality of Rust code in this application will reflect my progressive improvement in the language.