Coder Social home page Coder Social logo

math-parser's Introduction

Math Parser

Math Parser is a small little mathematical expression parser I wrote in C to test my language skills. It uses no external libraries other than the standard C library. The parser works in two stages. Lexical analysis and parsing. The lexical analysis stage reads the user's input and breaks it up into a set of tokens. These tokens contain a type (Number, addition, subtraction...) and in the case of a number, a string containing their value. These tokens are fed into the parser. The parser takes the tokens and converts them into reverse polish notation using the shunting yard algorithm. These new tokens are fed into the final parser which evaluates the expressions and spits out the results.

Building

CMake is used for the build system, but you could just as easily compile it directly from the command line since there aren't many files.

Usage

After executing the program in the command line, you can enter any standard mathematical expression. For example 11 + (5 - 6) / - 2. Would result in the output, 11.5. supported features are listed below.

Features

  1. Real number Ex. 1.0
  2. Addition (+)
  3. Subtraction (-)
  4. Multiplication (*)
  5. Division (/)
  6. Negation Ex. -1.0
  7. Exponentiation (^)
  8. Variables Ex. x = 3.14159 * 4^2

Planned Features

A list of planned features is given below.

  1. Standard functions
  2. Custom functions
  3. Comparisons

math-parser's People

Watchers

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