Giter Site home page Giter Site logo

girish-io / shuntingyard Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 13 KB

An implementation of the shunting yard algorithm by Edsger Dijkstra and a postfix stack evaluator.

License: MIT License

Java 100.00%
algorithms pushdown-automaton shunting-yard edsger-dijkstra context-free-grammar

shuntingyard's Introduction

Shunting Yard Demo

A demo program for parsing and evaluating mathematical expressions using the Shunting Yard algorithm, implemented in Java.

It converts expressions from infix notation to postfix/Reverse Polish Notation (RPN) which can then be evaluated by a computer, taking into account the order of precedence of different operators such as parentheses, multiplication, division, subtraction (PEMDAS) etc.

Demo Video

Shunting Yard Algorithm Demonstration

Implementation Features

This implementation of the algorithm has been extended to support:

  • Variable declaration and evaluation
  • Functions
    • sin
    • cos
    • tan
  • Numeric values greater than 9
  • Negative values
  • Decimal values

Graphs

Graphs can be plotted using the plot command in the CLI tool.

It produces image files in PPM (Portable Pixmap) format with points generated by the provided function.

Example graph for a sine wave function (f(x) = 40 * sin(10*x))

Sine wave plot for f(x) = 40 * sin(10*x)

Build Instructions

Step 1) Build source files

javac src/main/java/io/girish/core/*.java src/main/java/io/girish/shuntingyard/*.java src/main/java/io/girish/shuntingyard/enums/*.java src/main/java/io/girish/cli/enums/*.java src/main/java/io/girish/cli/*.java src/main/java/io/girish/*.java -d bin

Step 2) Run the program

cd bin
java io.girish.Main

Optionally, you can create an executable JAR file:

cd bin
jar -cmvf ../META-INF/MANIFEST.MF ./notmatlab.jar .

java -jar notmatlab.jar

License

This project is licensed under the terms of the MIT License.

shuntingyard's People

Contributors

girish-io avatar

Stargazers

 avatar  avatar

Watchers

 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.