Skip to content

A CLI calculator written in Rust that isn't blazingly fast.

Notifications You must be signed in to change notification settings

caseykneale/Calcamabob

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Calcamabob

  • A command line calculator
  • Is written in Rust
  • Is not blazing fast, and could be faster.
  • Calcamabob can interpret operator precedence. For example: calcamabob -e "2+3*4" will return 14(2+(3*4)), and not 20((2+3)*4).

Usage

Make the binary and execute it with the expression command line argument followed by an expression, like so:

calcamabob --expression "sin(pi)^2"
calcamabob -e "2+3*4"

Alternatively, provide a path to a file which contains an arithmetic expression inside of it and call the file command line argument.

calcamabob --file "/path/to/expression.txt"
calcamabob -f "/path/to/expression.txt"

Motivation

I never tried to make a programming language before, so a calculator is a good excercise to do that.

References:

I needed help getting a Pratt parser started and found a good tutorial for it: https://willspeak.me/2016/09/03/top-down-operator-precedence-parsing-in-rust.html

Warning:

This code hasn't be tested for every condition. Meaning, you might get an incorrect answer at some point.

About

A CLI calculator written in Rust that isn't blazingly fast.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages