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:
-
-
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.
In addition, consider setting up the default directory ( C: \ Dev-Cpp )
< 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:
If this statistic is not in good resolution, then you see You can.
Open a prompt, send the CD to the directory where you have ".l" and ".y", and compile them with: < Ol>
Flex hello.l
Bison-D hello. Or
GCC lex.yy .c y.tab.c -o hello.exe
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
Post a Comment