This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
How I made flex and bison work with nmake and VC++5.
- To: gnu-win32 at cygnus dot com
- Subject: How I made flex and bison work with nmake and VC++5.
- From: "Tony Stratton" <tonys at apprentice dot com>
- Date: 28 Dec 1998 15:37:49 -0000
Here is how I mangle flex and bison to create a workable VC++ alternitive.
First a .l file called "st.l":
%{
#include "st.tab.h"
#include "unistd.h"
void yyerror(char *message)
{
}
%}
%%
STRINGTABLE {return STRINGTABLE;}
PRELOAD {return PRELOAD;}
DISCARDABLE {return DISCARDABLE;}
BEGIN {return BEGIN;}
END {return END;}
\"(\"\"|[^\"])*\" {return QUOTEDSTRING;}
[A-Za-z][A-Z0-9_]* {return IDNAME;}
[\/\n\t ]* ;
%%
Then a .y file called "st.y":
%{
/* variable declarations. */
extern void yyerror(char *message);
#include "malloc.h"
#include "unistd.h"
%}
%token STRINGTABLE PRELOAD DISCARDABLE BEGIN END IDNAME QUOTEDSTRING
%start strings
%%
strings: string_table_list
;
string_table_list: string_table_list string_table_entry
| string_table_entry
;
string_table_entry: header BEGIN qs_list END
;
header: STRINGTABLE PRELOAD DISCARDABLE
| STRINGTABLE DISCARDABLE
;
qs_list: qs_item
| qs_list qs_item
;
qs_item: IDNAME QUOTEDSTRING
;
%%
void main()
{
yyparse();
}
Finally, a make (actually nmake) file:
CC = cl
CCFLAGS = /nologo /link libfl.a
LEX = flex
YACC = bison
start: all
st.l.o:
$(LEX) -d st.l
st.tab.o:
$(YACC) -d -v st.y -S d:\lt\bison.simple
all: st.l.o st.tab.o
$(CC) -o st.exe st.tab.c lex.yy.c $(CCFLAGS)
Comments:
The libfl.a file is a file located in
D:\cygnus\cygwin-b20\H-i586-cygwin32\lib, or some similiar directory
in your installation. I had to add this path to the set LIB line in
VCVARS32.bat.
This is just a quick example concocted to get this ball rolling.
Happy flexing, and bisoning.
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".