Help Me Implement Infix to Postfix Expression Converter (Shunting Yard Algorithm) in PHP

Job ID: 36855017

Budget: $20 – $21 USD

I am trying to debug a PHP function that converts a regular mathematical or logical expression (infix notation) into postfix notation using the Dijkstra Shunting Yard Algorithm. There is no precedence. It is left to right evaluation. Ideally there will be trailing unary operators.

~P^~Q => P ~ Q ~ ^

The specific algorithm I am using is:

OPS = Operator Stack. OUT = Output Stack

Atom: Add to OUT.
Left Paren ( : Add to OPS.
Operator: Move OPS to OUT. OPS becomes new Operator.
Right Paren ) : Move OPS to OUT until ( is encountered [error if no ( is found]
At the end: OPS is moved to OUT [error if ( is found]

Example:

(~P)

( : OPS = (
~ : OPS is moved to OUT so OUT is ( and you’re f’d.

I will want to test it for a while before I accept it. I should be able to find problems pretty quickly, though - until it is presumably perfect.

Charlie