Coder Social home page Coder Social logo

calculator's Introduction

Calculator

Join the chat at https://gitter.im/kvirund/calculator build status

Calculator which has been written on C++ using re2c and lemon. Currently implemented simple operation on four different types:

  1. integer
  2. float
  3. boolean
  4. string

Also calculator makes possible to use variables. One predefined constant is 'pi'

At this time implemented following operations:

  1. add (+)
  2. sub (-)
  3. division (/)
  4. mod (%)
  5. times (*)
  6. All relationship operations (<, <=, >, >=, ==, !=)
  7. Negative (-)
  8. logical AND, OR and NOT
  9. Assignment ([variable name]=[variable value])

Requirements

For building project usually you need only cmake. But if you want to regenerate scanner and syntax analyzer, you should have re2c and lemon utilities accordingly.

Building

Just type following commands from root of project directory:

$ mkdir build
$ cd build
$ cmake ..
$ make

To perform tests, from build directory run test/test.it.pl:

$ ../test/test.it.pl

You must see something like:

$ ../test/test.it.pl
(Expressions parser) Escape string                                     [PASSED]
(Expressions parser) Constants test                                    [PASSED]
(Expressions parser) Sum test                                          [PASSED]
(WHERE parser) Escape string                                           [PASSED]
(WHERE parser) Constants test                                          [PASSED]
(WHERE parser) Compare test                                            [PASSED]
(WHERE parser) Unary minus and NOT                                     [PASSED]
(WHERE parser) LIKE operator                                           [PASSED]
(WHERE parser) Booleans test                                           [PASSED]
(WHERE parser) Sum test                                                [PASSED]
(WHERE parser) Mul test                                                [PASSED]
(WHERE parser) Div test                                                [PASSED]
(WHERE parser) Null test                                               [PASSED]
(WHERE parser) IS and IS NOT test                                      [PASSED]
(Expressions parser) Compare test                                      [PASSED]
(Expressions parser) Unary minus and NOT                               [PASSED]
(Expressions parser) Booleans test                                     [PASSED]
(Expressions parser) Mul test                                          [PASSED]
(Expressions parser) Variable test                                     [PASSED]
(Expressions parser) Div test                                          [PASSED]
(Expressions parser) Fake assignment test                              [PASSED]
(WHERE parser) Variable test                                           [PASSED]
$ 

vim: set ts=2 sw=2 tw=0 et syntax=markdown :

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.