Skip to content

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

License

Notifications You must be signed in to change notification settings

girish-io/shuntingyard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages