title: Compile error when specifying prefixes with Flex and Bison
body: <p>I am trying to compile a simple bison parser using a given prefix - as was resolved <a href="https://stackoverflow.com/questions/1634704/multiple-flex-bison-parsers">in this question</a>. I'm using Bison version 2.4.1 and flex version 2.5.35 (I can't use bison 2.6). I have been running into a compiler error that has me running around in circles:</p>
  
  <p>Namely:</p>
  
  <pre><code>make
  Making all in src
  make[1]: Entering directory `/stage/pool14/eholum/yacc_example/src'
  /bin/sh ../ylwrap parcalc.y y.tab.c parcalc.c y.tab.h parcalc.h y.output parcalc.output -- bison -y  -d -p="calcYY"
  ...yacc_example/src/parcalc.y:27.7-13: warning: type clash on default action: &lt;result&gt; != &lt;&gt;
  conflicts: 4 shift/reduce
  updating parcalc.h
  gcc -DPACKAGE_NAME=\"calculator\" -DPACKAGE_TARNAME=\"calculator\" -DPACKAGE_VERSION=\"1.0\" -DPACKAGE_STRING=\"calculator\ 1.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"calculator\" -DVERSION=\"1.0\" -I.     -g -O2 -MT parcalc.o -MD -MP -MF .deps/parcalc.Tpo -c -o parcalc.o parcalc.c
  parcalc.c:1053: error: expected identifier or ‘(’ before ‘=’ token
  parcalc.c:1061: error: expected identifier or ‘(’ before ‘=’ token
  parcalc.c:1064: error: expected identifier or ‘(’ before ‘=’ token
  parcalc.c:1067: error: expected identifier or ‘(’ before ‘=’ token
  parcalc.c:1089: error: expected identifier or ‘(’ before ‘=’ token
  parcalc.y:75:21: error: lexcalc.c: No such file or directory
  make[1]: *** [parcalc.o] Error 1
  </code></pre>
  
  <p>I'm currently using automake, but I get the same error if I build using flex and bison then try compiling with c. Here's my Makefile.am:</p>
  
  <pre><code>bin_PROGRAMS = calculator
  AM_YFLAGS = -d -p="calcYY"
  calculator_SOURCES = parcalc.y lexcalc.l
  </code></pre>
  
  <p>Where the lex code is is in lexcalc.l (note I'm using %option to specify the prefix, but I get the same error when I use the cl flag):</p>
  
  <pre><code>%{
  #include &lt;stdio.h&gt;
  #include "parcalc.h"
  %}
  
  %option noyywrap
  %option prefix="yy"
  
  %%
  
  [ \t] ; 
  
  [0-9]+\.[0-9]+ { 
      yylval.flval = atof(yytext);
      return FLOAT;
  }
  
  [0-9]+ {
      yylval.inval = atoi(yytext);
      return INT;
  }
  
  - { return MINUS; }
  
  \+ { return PLUS; }
  
  \n {
      yylineno++; 
      return NEWLINE; 
  }
  
  . ;
  
  %%
  </code></pre>
  
  <p>And the Bison code is in parcalc.y :</p>
  
  <pre><code>%{
  #include &lt;stdio.h&gt;
  %}
  
  %token INT FLOAT PLUS MINUS NEWLINE;
  
  %union {
      int inval;
      float flval;
      char oper;
      char result[100];
  }
  
  %type &lt;inval&gt; INT;
  %type &lt;flval&gt; calc FLOAT
  %type &lt;oper&gt; PLUS MINUS;
  %type &lt;result&gt; line;
  
  %%
  
  lines:
       line lines
      | line
      ;
  
  line:
        NEWLINE
      | calc NEWLINE {
          printf("Result = %f\n", $1);   
        }
      ;
  
  calc :
        calc PLUS calc { 
          ($$ = $1 + $3);
        }
      | calc MINUS calc { 
          ($$ = $1 - $3); 
        }
      | INT { 
          ($$ = $1);
        }
      | FLOAT { 
          ($$ = $1); 
        }
      ;
  
  %%
  
  extern int calcYYparse();
  extern FILE *calcYYin;
  
  int main() {
  
      FILE *myfile = fopen("infile.txt", "r");
  
      if (!myfile) {
          fprintf(stderr, "can't open infile.txt\n");
          return 1;
      }
  
      calcYYin = myfile;
  
      do {
          calcYYparse();
      } while (!feof(calcYYin));
  
      return 0;
  }
  
  void calcYYerror(const char *s) {
      fprintf(stderr, "Unrecognized format\n");
  }
  </code></pre>
  
  <p>I should note that everything seems to work fine when I discard the prefixes, so I'm guessing that there's something awry with how things are externally declared in the generated c files. Looking through those I haven't been able to figure it out yet. If anyone has messed around with multiple parsers and has some insight on how to make these things play nicely together I would really appreciate it.</p>