bison - How to compile LEX/YACC files on Windows? -


I get lex and YACC files to parse my files ( .l file and .y file).

How to compile those files and how to file them in the equivalent .c windows platform?

for today (2011-04-05) Latest version of:

  1. After that, without a blank in a name Install complete in your directory of priority. I recommend that C: \ GnuWin32 Install it No in Default (C: \ Program Files (x86) \ GnuWin32) because the bison has a problem with empty space in directory names, not brackets for the sake of saying.

  2. In addition, consider setting up the default directory ( C: \ Dev-Cpp )

  3. < P> After that, to include bin directories of gcc (in C: \ Dev-Cpp \ bin ) and flex \ bison Set the PATH variable to C: \ GnuWin32 \ bin \ / code>). To do this, copy this: ; C: \ Dev-Cpp \ bin; C: \ GnuWin32 \ bin \ / code> and add it at the end of the PATH variable, which is defined by this figure:
     To set the PATH variable under step-by-step Win-7.
    If this statistic is not in good resolution, then you see You can.
  4. Open a prompt, send the CD to the directory where you have ".l" and ".y", and compile them with: < Ol>

  5. Flex hello.l
  6. Bison-D hello. Or
  7. GCC lex.yy .c y.tab.c -o hello.exe

     command to make lexical analyzer, parser and executable.

    You will be able to run the program. I create a source for a simple test (notorious Hello World ):

    HelloL.
     % {#include < Stdlib h & gt; #include "y.tab.h"%} %% ("hi" | "oi") "\ n" {return HI; } ("Taichau" | "Bye") "\ n" {return BYE; } {Yyerror (); } %% int main (zero) {yyparse (); Return 0; } Int yywrap (zero) {return 0; } Int yyerror (zero) {printf ("error \ n"); Exit (1); }   

    Hello.e
     % {#include & lt; Stdio.h & gt; %}% Token HI BYE %% Program: Hi Bye; Hi: hi {printf ("hello world \ n"); }; Bye: BYE {printf ("By World"); Exit (0); };    

Comments