title: Flex, Bison, C++ - compile error
body: <p>I'd like to make a program, that creates parse tree for functions.
  For instance: "f(g(x,h(y),v,k(l(c))))" could be a valid function call.</p>
  
  <p>h1.l</p>
  
  <pre><code>%{
  #include &lt;iostream&gt;
  #include &lt;list&gt;
  using namespace std;
  #include "h1.tab.hpp"
  
  %}
  
  %option noyywrap
  %option c++
  
  %%
  
  [a-z][a-zA-z0-9]*       { yylval.s = yytext; return (TERM_ID); }
  "("                     { return (OP); }
  ")"                     { return (CP); }
  ";"                     { return (COMMA); }
  
  %%
  </code></pre>
  
  <p>h1.ypp</p>
  
  <pre><code>%{
  
  #include &lt;list&gt;
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  using namespace std;
  
  
  extern "C" int yylex(); 
  extern "C" int yyerror(char *p) { cerr &lt;&lt; "Error!" &lt;&lt; endl; }
  
  struct ts {
      string                  *name;
      list&lt;struct ts*&gt;        *plist; /* NULL if the sturcture represents a variable, parameter list if the structure represents a function */
  };
  
  %}
  
  %union {
      struct ts *t;
      list&lt;struct ts *&gt; *tl;
      char *s;
  }
  
  %token &lt;s&gt; TERM_ID
  %token OP CP COMMA
  
  %type &lt;tl&gt; termlist
  %type &lt;t&gt; term
  
  
  %%
  
  term : TERM_ID OP termlist CP   { $$ = new struct ts(); $$-&gt;name = new string($1); $$-&gt;plist = $3; }
      | TERM_ID   { $$ = new struct ts(); $$-&gt;name = new string($1); $$-&gt;plist = NULL; }
  ;
  
  termlist : termlist COMMA term  { $$ = $1; $$-&gt;push_back($3); }
      | term  { $$ = new list&lt;struct ts*&gt;(); $$-&gt;push_back($1); }
  ;
  
  
  %%
  
  int main()
  {
      yyparse();
      return 0;
  }
  </code></pre>
  
  <p>Compiling:</p>
  
  <pre><code>$ bison -d h1.ypp
  $ flex h1.l 
  $ g++ h1.tab.cpp lex.yy.cc
  h1.tab.cpp: In function ‘int yyparse()’:
  h1.tab.cpp:1382: warning: deprecated conversion from string constant to ‘char*’
  h1.tab.cpp:1528: warning: deprecated conversion from string constant to ‘char*’
  Undefined symbols for architecture x86_64:
    "_yylex", referenced from:
        yyparse()    in ccmRHVKn.o
  ld: symbol(s) not found for architecture x86_64
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I dont know much about these tools, also I have never used cpp before.</p>
  
  <p>What should I change to make these things work?</p>