rcalc 0.1.2

Glorified calculator with a lexer, parser, and interpreter written in Rust.
Documentation
  • Coverage
  • 31.58%
    6 out of 19 items documented3 out of 3 items with examples
  • Size
  • Source code size: 37.72 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.74 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 27s Average build duration of successful builds.
  • all releases: 27s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ayazhafiz

rcalc

Build Status Coverage Status

rcalc is a glorified calculator written in Rust that incorporates the fundamentals of building any programming language, including a lexer, parser, Abstract Syntax Tree, and AST traverser.

Try it

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

  • CLI Access to input history
  • CLI Hiding of control characters
  • LOGIC Integer division
  • LOGIC Modulo operator
  • 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 is hosted under one namespace, with separate modules for independent components of the calculator "interpreter".

The binary 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 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.