Header y.tab.h not found during compilation of lex.yy.c
<p>I am trying to create a basic compiler and I am facing some problems. </p>

<p>My flex code:</p>

<pre><code>%{
    #include &lt;stdio.h&gt;
    #include "SymbolTable.h"
    #include &lt;y.tab.h&gt;

    //extern "C"
    //{
    //   extern int yylex(void);
    //   extern int yyparse(void);
    //}

    int line_count = 1;
    SymbolTable table;
    static int yywrap(void);

    void insert(const char* token, char* yytext) {
    ////printf ("%s: %s ", token, yytext);
    //printf ("%s ", token);
    SymbolInfo symbolInfo(yytext, token);
    table.insert(symbolInfo, line_count);
    }
    %}

    newLine         \n
    delim           [  \t]
    digit           [0-9]
    unsigned        {digit}+
    exponent        [eE][+-]?{unsigned}
    number          [-+]?({unsigned}|{unsigned}\.{unsigned}?|{unsigned}?\.{unsigned}){exponent}?
    letter          [A-Za-z]
    keyword         program|if|not|end|begin|else|then|do|while|function|Procedure|integer|real|var|oh|array|write|include
    id              (_|{letter})({letter}|{digit}|_)*
    header          {id}\.h
    sin_comment     \/\/.*
    mul_comment     "/*"(([^*]|(("*"+)[^*/]))*)("*"+)"/"
    string          \"(\\.|[^"])*\"
    char            \'(\\.|[^'])*\'
    addop           [\+-]|or
    mulop           [\*\/]|div|mod|and
    orop            ||
    leop            &lt;=
    geop            &gt;=
    eqop            ==
    neop            !=
    assignop        :=
    dotdot          \.\.
    brace           [\[\]\(\)]
    other           [,;:]
    hash            #
    err_dotdot      [0-9]+\.([0-9]+\.){1,}
    err_id          {digit}+{id}
    leftcurl        {
    rightcurl       }



    %%
    {newLine} {
    line_count++;
    }

    {string} {
    //printf ("str: %s\n", yytext);
    //printf ("line no: %d\n",line_count);
    //fprintf(tokenout,"\n&lt;STRING, %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: STRING &lt;%s&gt; found\n",line_count,yytext);
    }

    {char} {
    //printf ("str: %s\n", yytext);
    //printf ("line no: %d\n",line_count);
    //fprintf(tokenout,"\n&lt;CHAR, %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: CHAR &lt;%s&gt; found\n",line_count,yytext);
    }

    {keyword} {

    ////printf ("keyword");
    //fprintf(tokenout,"\n&lt;KEYWORD, %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: KEYWORD &lt;%s&gt; found\n",line_count,yytext);

    }

    {header} {
    insert("header",yytext);
    //fprintf(tokenout,"\n&lt;HEADER %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: HEADER &lt;%s&gt; found\n",line_count,yytext);

    }

    {id} {
    SymbolInfo symbolInfo(yytext, "ID");
    table.insert(symbolInfo, line_count);
    //printf ("id: %s\n", yytext); 
    //fprintf(tokenout,"&lt;ID, %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: ID &lt;%s&gt; found\n",line_count,yytext);
    }

    {sin_comment} {
    //printf ("\nSingleline comment found: %s\n",yytext);
    //fprintf(logout,"\nLine no %d: SINGLELINECOMMENTP &lt;%s&gt; found\n",line_count,yytext);
    }

    {mul_comment} {
    //printf ("\nMultiline comment found: %s\n",yytext);
    //fprintf(logout,"\nLine no %d: MULTILINECOMMENT &lt;%s&gt; found\n",line_count,yytext);
    }

    {number} {
    //printf ("number:%s\n",yytext);
    //printf ("line no: %d\n",line_count);
    SymbolInfo symbolInfo(yytext, "NUMBER");
    table.insert(symbolInfo, line_count);
    //fprintf(tokenout,"&lt;NUMBER, %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: NUMBER &lt;%s&gt; found\n",line_count,yytext);
    return NUMBER;

    }

    {addop} {
    insert("ADDOP", yytext);
    //printf ("line no: %d\n",line_count);
    //fprintf(tokenout,"\n&lt;ADDOP, %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: ADDOP &lt;%s&gt; found\n",line_count,yytext);
    return ADDOP;
    }

    {mulop} {
    insert("MULOP", yytext);
    //printf ("line no: %d\n",line_count);
    //fprintf(tokenout,"\n&lt;MULOP, %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: MULOP &lt;%s&gt; found\n",line_count,yytext);
    }

    {assignop} {
    insert("ASSIGNOP", yytext);
    //printf ("line no: %d\n",line_count);
    //fprintf(tokenout,"\n&lt;ASSIGNOP, %s&gt;\n",yytext);
    //fprintf(logout,"\nLine no %d: ASSIGNOP &lt;%s&gt; found\n",line_count,yytext);
    }


    {dotdot} {
    insert("DOTDOT", yytext);
    //printf ("line no: %d\n",line_count);
    }   
    {hash}  {
    insert("#",yytext);
    }

    {delim}+ {}

    {err_dotdot} {
    //printf ("Illegal usage of decimal\n");
    //fprintf(logout,"\nLine no %d: Illegal usage of decimal &lt;%s&gt; found\n",line_count,yytext);
    }

    {err_id} {
    //printf ("Illegal id\n");
    //fprintf(logout,"\nLine no %d: Illegal usage of id &lt;%s&gt; found\n",line_count,yytext);
    }

    %%
</code></pre>

<p>I can happily create lex.yy.c by 
 <code>lex -o lex.yy.c lex.l</code>.</p>

<p>But when I try to create lex object file using <code>g++ -c -w -o lexer.o lex.yy.c</code> it says </p>

<pre><code>lex.l:4:19: fatal error: y.tab.h: No such file or directory
</code></pre>

<p>I have already parsed the parser using <code>bison -d -y grammar.y</code></p>