Skip to content

Instantly share code, notes, and snippets.

@toptensoftware
Last active October 26, 2016 03:23
Show Gist options
  • Select an option

  • Save toptensoftware/ddcba28e4ba45145b11b54c6329c6d2d to your computer and use it in GitHub Desktop.

Select an option

Save toptensoftware/ddcba28e4ba45145b11b54c6329c6d2d to your computer and use it in GitHub Desktop.
// No parens
Assert.AreEqual(Parser.Parse("10 + 20 * 30").Eval(), 610);
// Parens
Assert.AreEqual(Parser.Parse("(10 + 20) * 30").Eval(), 900);
// Parens and negative
Assert.AreEqual(Parser.Parse("-(10 + 20) * 30").Eval(), -900);
// Nested
Assert.AreEqual(Parser.Parse("-((10 + 20) * 5) * 30").Eval(), -4500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment