Giter Site home page Giter Site logo

calculator's Introduction

Simple realization of calculator

make: to make project
make run: to run

Some information about commands and syntax:

(@end)
To stop endless cycle
    Examples:
    >>> @end
    Finish state:
    Variable dictionary is empty

In the expression, it is allowed to skip the multiplication
sign before and after the brackets;
    Examples:
        >>> 2 (1 + 2)
        INT: 6
        >>> (2. * 1) 3
        FLOAT: 6.000000
        >>> (1 + 2) (2 + 3)
        INT: 15

You can add and change variables by this way
    Rule:
        >>> <variable name> = <expression>
    Examples:
        >>> a = 1
        >>> b = 1
        >>> a + b
        INT: 2
        >>> a = (1.0 + 1) * 1
        a + b
        FLOAT: 3.000000

An unlimited number of unary plus and minus signs are allowed
    Examples:
        >>> +++1
        INT: 1
        >>> ---1
        INT: -1
        >>> -+-1
        INT: 1

(@save, @use)
Added the ability to recalculate expressions with new variable values
(or with old ones) (Only one expression can be stored at a time)
    Examples:
        >>> a = 1
        >>> a = 2
        >>> a + b
        INT: 3
        >>> @save
        >>> a = 125.0
        >>> @use
        FLOAT: 127.000000

(@dict)
You can also print the current dictionary of variables
    Examples:
        >>> @dict
        Variable dictionary is empty
        >>> a = 1
        >>> b = 12.2
        >>> @dict
        Dictionary:
          1. NAME:      a, VALUE: INT: 1
          2. NAME:      b, VALUE: FLOAT: 12.200000



SIMPLE CALC LANGUAGE

<expression> = <term> [<3L sign> <term>]

<1L sign> = {'+', '-'} // unary
<2L sign> = {'*', '/'} // binary
<3L sign> = {'+', '-'} // binary

<term> = <term spec> [<term cont>]
<term> = <mul> [<term cont>]

<term spec> = (<expression>)<val>
<term spec> = (<expression>)<variable>
<term spec> = (<expression>)

<term cont> = <2L sign> <mul>
<term cont> = <term spec>

<mul> = <1L sign> <mul>
<mul> = (<expression>)
<mul> = <val>
<mul> = <variable>

<val> = <int>
<val> = <float>

<float> = <int>.[<int>]

<int> = <num>[<num>]

<num> = {0,1,2,3,4,5,6,7,8,9}

<variable> = <start correct sym> [<correct sym>]

<start correct sym> = <letter> or '_'
<correct sym> = <letter> or <num> or '_'
<letter> = {a...z, A...Z}

calculator's People

Contributors

leoqay avatar

Watchers

 avatar

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.