Using ANTLR3 in a C++ program <p>I'm currently working on an application that takes a string (a function of a single variable ' x') as input and outputs the derivative of that function. The latter half of the program is not the problem at the moment, the only thing I am having trouble with is "reading" a function from a string. I am using ANTLRv3 for C to try to achieve this goal, but I can't seem to get it to work. Currently I am missing the "antlr3.h" header file, which I can't seem to find anywhere. My second problem is invoking the generated parser, what would the C(++) code for that be (the ANTLR code is posted below)? How do I get it to work?</p> <p>Thanks in advance,</p> <p>Ties</p> <pre><code>grammar Expression; options { language = C; } @header { #ifndef PI #define PI 3.1415926535897 #endif // PI #ifndef E #define E 2.7182818284590 #endif // E #include "ExpressionTree.h" #include &lt;vector&gt; #include &lt;cstdlib&gt;} parse returns [Functor* func] : e=addExp EOF {func = $e.func;} ; addExp returns [Functor* func] @init {std::vector&lt;Functor*&gt; addList; std::vector&lt;bool&gt; opList;} : e1=multExp {addList.push_back($e1.func);} (o=('+'|'-') e2=multExp {opList.push_back($o.text == '+'); addList.push_back($e2.func);})* { if(addList.size() == 1) { func = addList[0]; } else { Functor* current = addList[0]; for(int i = 0; i&lt;opList.size(); i++) { if(opList[i]) { current = new Plus(current, addList[i+1]); } else { current = new Minus(current, addList[i+1]); } } func = current; }}; multExp returns [Functor* func] @init { std::vector&lt;Functor*&gt; mulList; std::vector&lt;bool&gt; opList;} : e1=powExp {mulList.push_back($e1.func);} (o=('*'|'/') e2=powExp {opList.push_back($o.text == '*'); mulList.push_back($e2.func);})* { if(mulList.size() == 1) { func = addList[0]; } else { Functor* current = mulList[0]; for(int i = 0; i&lt;opList.size(); i++) { if(opList[i]) { current = new Times(current, mulList[i+1]); } else { current = new Divides(current, mulList[i+1]); } } func = current; }}; powExp returns [Functor* func] @init { std::vector&lt;Functor*&gt; expList; } : e1=unarExp {expList.push_back($e1.func);} ('^' e2=unarExp {expList.push_back($e2.func);})? { if(expList.size() == 1) { func = expList[0]; } else { func = new Power(expList[0], expList[1]); }}; unarExp returns [Functor* func] : SQRT '(' e=addExp ')' {func = new Sqrt($e.func);} | SIN '(' e=addExp ')' {func = new Sin($e.func);} | COS '(' e=addExp ')' {func = new Cos($e.func);} | TAN '(' e=addExp ')' {func = new Tan($e.func);} | EXP '(' e=addExp ')' {func = new Exp($e.func);} | LOG '(' e=addExp ')' {func = new Log($e.func);} | ABS '(' e=addExp ')' {func = new Abs($e.func);} | MAX '(' e1=addExp ',' e2=addExp ')' {func = new Max($e1.func,$e2.func);} | MIN '(' e1=addExp ',' e2=addExp ')' {func = new Min($e1.func,$e2.func);} | e=atom {func = $e.func;} ; atom returns [Functor* func] : INT {func = new Constant(atoi($INT.text));} | FLOAT {func = new Constant(atof($FLOAT.text));} | 'pi' {func = new Constant(PI);} | 'e' {func = new Constant(E);} | 'x' {func = new Variable();} | '(' e=addExp ')' {func = $e.func;} ; SQRT: 'Sqrt'; SIN : 'Sin'; COS : 'Cos'; TAN : 'Tan'; EXP : 'Exp'; LOG : 'Log'; ABS : 'Abs'; MAX : 'Max'; MIN : 'Min'; INT : '0'..'9'+; FLOAT : ('0'..'9')+ '.' ('0'..'9')* EXPONENT? | '.' ('0'..'9')+ EXPONENT? | ('0'..'9')+ EXPONENT ; WS : ( ' ' | '\t') {$channel=HIDDEN;}; fragment EXPONENT : ('e'|'E') ('+'|'-')? ('0'..'9')+ ; </code></pre>