Skip to content

Instantly share code, notes, and snippets.

@alexandervasyuk
Last active August 29, 2015 14:07
Show Gist options
  • Save alexandervasyuk/26fd6a57649af5e887f7 to your computer and use it in GitHub Desktop.
Save alexandervasyuk/26fd6a57649af5e887f7 to your computer and use it in GitHub Desktop.
simpleShuntingYardPseudo
While there are tokens to be read:
Read a token.
If the token is a number, then add it to the output queue.
If the token is an operator, o1, then:
while there is an operator token, o2, at the top of the operator stack, and
o1 has precedence less than or equal to that of o2,
pop o2 off the stack, onto the output queue;
push o1 onto the stack.
When there are no more tokens to read:
While there are still operator tokens in the stack:
Pop the operator onto the output queue.
Exit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment