title: Expression evaluation
body: <p>I'm doing an expression valuation program, just like <a href="https://stackoverflow.com/questions/1545403/math-expression-evaluation">this</a>. My problem is that I can't figure out how to handle operation precedences. I used recursion to find the innermost couple of parenthesis and, when found, solve the expression inside them, like this:</p>
  
  <pre><code>Evaluate("2 + (3 * 5)")
  </code></pre>
  
  <p>will re-call itself this way:</p>
  
  <pre><code>Evaluate("3 * 5")
  </code></pre>
  
  <p>now, since there aren't parenthesis, it calculates the result and calls itself another time:</p>
  
  <pre><code>Evaluate("2 + 15")
  </code></pre>
  
  <p>Ok, the return value is 17, as expected. But if I call <code>Evaluate("2 + 3 * 5")</code> the result is:</p>
  
  <pre><code>Evaluate("2 + 3 * 5")
  Evaluate("5 * 5")
  </code></pre>
  
  <p>Which is clearly wrong.<br>
  Basically I'm solving operations from left to right. How can I chose the operations that must be performed first? I was thinking to add a couple of parenthesis surrounding every operation, but it doesn't look so good.<br>
  So, do I need to parse the whole expression first o there's another way?</p>