title: Need a way to parse algebraic expressions in C
body: <p>I need to parse algebraic expressions for an application I'm working on and am hoping to garnish a bit of collective wisdom before taking a crack at it and, possibly, heading down the wrong road.</p>
  
  <p>What I need to do is pretty straight forward: given a textual algebraic expression (3*x - 4(y - sin(pi))) create a object representation of the equation. The custom objects already exist, so I need a parser that creates a tree I can walk to instantiate the objects I need.</p>
  
  <p>The basic requirements would be:</p>
  
  <ol>
  <li><p>Ability to express the algebra as a grammar so I have control and can customize/extend it as necessary.</p></li>
  <li><p>The initial syntax will include integers, real numbers, constants, variables, arithmetic operators (+, - , *, /), powers (^), equations (=), parenthesis, precedence, and simple functions (sin(pi)). I'm hoping to extend my app fairly quickly to support functions proper (f(x) = 3x +2).</p></li>
  <li><p>Must compile in C as it needs to be integrated into my code.</p></li>
  </ol>
  
  <p>I DON'T need to evaluate the expression mathematically, so software that solves for a variable or performs the arithmetic is noise.</p>
  
  <p>I've done my Google homework and it looks like the best approach is to use a BNF grammar and software to generate a compiler in C. So my questions:</p>
  
  <ol>
  <li><p>Does a BNF grammar with corresponding parser generator for algebraic expressions (or better yet, LaTex) already exist? Someone has to have done this already. I REALLY want to avoid rolling my own, mainly because I don't want to test it. I'd be willing to pay a reasonable amount for a library (under $50)</p></li>
  <li><p>If not, which parser generator for C do you think is the easiest to learn/use here? Lex? YACC? Flex, Bison, Python/SymPy, Others? I'm not familiar with any of these.</p></li>
  </ol>