title: How to recursively parse an expression?
body: <p>I'm writing a small language, and I'm really stuck on expression parsing. I've written a LR Recursive Descent Parser, it works, but now I need to parse expressions I'm finding it really difficult. I do not have a grammar defined, but if it helps, I kind of have an idea on how it works even without a grammar. Currently, my expression struct looks like this:</p>
  
  <pre><code>typedef struct s_ExpressionNode {
      Token *value;
      char expressionType;
  
      struct *s_ExpressionNode lhand;
      char operand;
      struct *s_ExpressionNode rhand;
  } ExpressionNode;
  </code></pre>
  
  <p>I'm trying to get it to parse something like:</p>
  
  <p><code>5 + 5 + 2 * (-3 / 2) * age</code></p>
  
  <p>I was reading <a href="http://www.engr.mun.ca/~theo/Misc/exp_parsing.htm" rel="nofollow">this</a> article on how to parse expressions. The first grammar I tried to implement but it didn't work out too well, then I noticed the second grammar, which appears to remove left recursion. However, I'm stuck trying to implement it since I don't understand what P, B means, and also U is a <code>-</code> but the <code>-</code> is also for a B? Also I'm not sure what <code>expect(end)</code> is supposed to mean either.</p>