Git Product home page Git Product logo

minicalculatorinterpreter's Introduction

Mini Calculator Interpreter

Tiny calculator interpreter supporting Mathematical functions using Python.

Mini Calculator Interpreter python

Features

  • Variable
  • Mathematical Constants
  • Mathematical Functions

Mathematical Constants

  • pi
  • e

Mathematical Functions

  • sin
  • cos
  • log
  • log10
  • log2
  • exp
  • sqrt
  • acos
  • atan
  • radians
  • sinh
  • cosh
  • tanh
  • asin
  • ceil
  • fabs
  • factorial
  • floor
  • copysign
  • pow

Download

git clone https://github.com/BaseMax/MiniCalculatorInterpreter
cd MiniCalculatorInterpreter
sudo pip3 install ply
python calculator.py

Grammar

S -> statement

statement -> NAME EQUALS expression
statement -> expression

expression -> expression PLUS expression
expression -> expression MINUS expression
expression -> expression DIVIDE expression
expression -> expression TIMES expression
expression -> MINUS expression
expression -> LPAREN expression RPAREN

expressions -> expressions COLON expression
expressions -> expression
expressions -> <empty>

expression -> NAME LPAREN expressions RPAREN
expression -> NUMBER_INT
expression -> NUMBER_DOUBLE
expression -> NAME

Using

> 5+5
10
> 5*6
30
> pow(5,2)
25.0
> pi*2  
6.283185307179586
> e/2
1.3591409142295225
> log10(10)
1.0
> badFunction(10)
Undefined function 'badFunction'
None
> log2(10)
3.321928094887362
> log(10)
2.302585092994046
> test=5+6+sin(pi/2)
> test*test+5
149.0
> test=test*5
> test
60.0

Acknowledgments

It's been a few years since I have worked with the ply library And I really forgot about that name. Professor Ahmad Yoosofan was the one who reminded me of this library again. Thanks so much. (Video: Working with ply on YouTube)

Similar Projects

Installing Dependencies

Depends on ply and python.


Max Base

My nickname is Max, Programming language developer, Full-stack programmer. I love computer scientists, researchers, and compilers. (Max Base)

Asrez Team

A team includes some programmer, developer, designer, researcher(s) especially Max Base.

Asrez Team

minicalculatorinterpreter's People

Contributors

nibble-4bits avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.