Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calc.js

The toy CLI calculator writed as an exercies. It uses Pratt's Top Down Operator Precedence technique also described in this article.

Capabilities

    ✓ 1 + 1 => 2
    ✓ 2 - 1 => 1
    ✓ -1 => -1
    ✓ +1 => 1
    ✓ 2 + 3*3 => 11
    ✓ 4/2 => 2
    ✓ 4 / 2^2 => 1
    ✓ 2 * (1 + 1) => 4
    ✓ pow(2, 2)^2 => 16
    ✓ a = 10; b = a + 5 => 15


  ✔ 10 tests complete (9ms)

Installation

$ npm install https://github.com/eldargab/calc.js

To run tests first install dev dependencies

$ npm install -d

then run

$ make test

To start repl:

$ make repl

or simply invoke calc executable.

License

MIT

About

Toy CLI calculator. Implementation of Pratt's top down operator precedence parsing technique.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages