title: How to Compile Programs Built With Yacc and Lex?
body: <p>My Yacc source is in pos.yacc and my Lex source is in pos1.lex, as shown.</p>
  
  <h3>pos1.lex</h3>
  
  <pre><code>%{
  #include "y.tab.h"
  
  int yylval;
  %}
  DIGIT [0-9]+
  %%
  {DIGIT} {yylval=atoi(yytext);return DIGIT;}
  [\n ] {}
  . {return *yytext;}
  %%
  </code></pre>
  
  <h3>pos.yacc</h3>
  
  <pre><code>%token DIGIT
  %%
  s:e {printf("%d\n",$1);}
  e:DIGIT {$$=$1;}
  |e e "+" {$$=$1+$2;}
  |e e "*" {$$=$1*$2;}
  |e e "-" {$$=$1-$2;}
  |e e "/" {$$=$1/$2;}
  ;
  %%
  main() {
    yyparse();
  }
  yyerror() {
    printf("Error");
  }
  </code></pre>
  
  <h3>Compilation errors</h3>
  
  <p>While compiling I am getting errors like:</p>
  
  <pre><code>malathy@malathy:~$ cc lex.yy.c  y.tab.c -ly -ll
  pos.y: In function ‘yyerror’:
  pos.y:16: warning: incompatible implicit declaration of built-in function ‘printf’
  pos.y: In function ‘yyparse’:
  pos.y:4: warning: incompatible implicit declaration of built-in function ‘printf’
  </code></pre>
  
  <hr>
  
  <ul>
  <li>What causes those errors?</li>
  <li>How am I supposed to compile Lex and Yacc source code?</li>
  </ul>