4 comments

[ 3.9 ms ] story [ 22.3 ms ] thread
A while back I saw this video (link in the readme) showing the shunting yard algorithm and I decided to implement it in JavaScript.

Here's the link to the repository https://github.com/victorqribeiro/shuntingYard

Let me know what you think

I like how simple it is. Thanks for sharing.

By the way, I found one or two bugs.

The empty parentheses alone are treated as undefined:

  > ()
  undefined
And I think any equation using empty parentheses as an expression gets treated as NaN:

  > 5 + ()
  NaN
Empty parentheses should probably just be a parse error.
Oh, thank you. I'll write some rules to fix that. Appreciate the bug report