# New Ticket Created by Andy Dougherty # Please include the string: [perl #16941] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=16941 >
The following patch changes the build system to use pre-generated files for languages/imcc. A special target 'make regen_all' has to be invoked to run bison and flex. This removes the requirement that the build system has bison and flex installed. As examples of the sorts of problems this avoids, and to record somewhere what I had to do in case someone else wants to pursue it further, here are the main problems I had in using Sun's yacc and lex: 0. Configure.pl needs to determine whether or not you have bison, byacc, or yacc, and flex or lex. There's currently no built-in method to do that, though searching through File::Spec::path isn't too bad. 1. yacc puts its output into non-portable files, y.tab.[ch] on Unix systems. This would require Configure/Makefile hackery to handle portably. Similarly, lex uses yy.lex.c. 2. Sun's yacc doesn't put the appropriate token #defines early enough in the generated file, so imcparser.c has to #include "imcparser.h". This causes an error however due to a redeclaration of a union. Further cpp hijinks are required to get around that. 3. The lex-generated gives errors for the flex-specific %option lines. These all have to be deleted before even running lex. More Makefile hackery. 4. The lex-generated parser didn't work because the input lines are too long. It's possible to get around this by manually adding #define DYYMLMAX 8192 to the top of imclexer.c, but this is more annoying Makefile hackery. 5. The lex-generated parser would need additional work because Sun's lex doesn't appear to have anything similar to flex's YY_CURRENT_BUFFER used in yywrap(). I suspect it'd have to be re-written specifically for lex. All in all, I judged it better to simply supply the generated files with parrot. That's what this patch enables. I don't really know how to work cvs well. I think the first hunk is needed so that the appropriate files get exported. The remaining hunks do the actual work. I'd appreciate folks trying this out and verifying that it works. --- parrot-orig/languages/imcc/.cvsignore Tue Aug 27 04:07:45 2002 +++ parrot-andy/languages/imcc/.cvsignore Mon Sep 2 15:44:45 2002 @@ -1,6 +1,3 @@ imcc -imclexer.c -imcparser.c -imcparser.h imcparser.output Makefile diff -r -u parrot-orig/MANIFEST parrot-andy/MANIFEST --- parrot-orig/MANIFEST Thu Aug 29 16:56:27 2002 +++ parrot-andy/MANIFEST Mon Sep 2 12:32:08 2002 @@ -321,6 +321,9 @@ languages/imcc/imc.h languages/imcc/imcc.l languages/imcc/imcc.y +languages/imcc/imcparser.c +languages/imcc/imcparser.h +languages/imcc/imclexer.c languages/imcc/instructions.c languages/imcc/instructions.h languages/imcc/sets.c diff -r -u parrot-orig/config/gen/makefiles/imcc.in parrot-andy/config/gen/makefiles/imcc.in --- parrot-orig/config/gen/makefiles/imcc.in Tue Aug 27 01:02:28 2002 +++ parrot-andy/config/gen/makefiles/imcc.in Mon Sep 2 15:35:13 2002 @@ -23,8 +23,6 @@ CC = ${cc} PERL = ${perl} MAKE_F=${make} -YACC = bison -v -y -LEX = flex LD = ${ld} LD_SHARED = ${ld_shared} @@ -33,11 +31,17 @@ all : imcc cd ../.. && $(MAKE) shared && $(RM_F) parrot${exe} && $(MAKE) -imcparser.c imcparser.h : imcc.y - $(YACC) -d -o imcparser.c imcc.y +.PHONY: run_bison run_flex -imclexer.c : imcc.l $(HEADERS) - $(LEX) imcc.l +# We now supply imcparser.[ch] and imclexer.c, so only run the +# following commands if imcc.l or imcc.y is changed. +regen_all: run_bison run_flex + +run_bison: + bison -v -d -o imcparser.c imcc.y + +run_flex: + flex imcc.l .c$(O): $(CC) $(CFLAGS) ${cc_exe_out}$@ -c $< @@ -50,8 +54,6 @@ realclean: clean $(RM_F) a.pasm - $(RM_F) imcparser.* - $(RM_F) imclexer.* imcc: $(O_FILES) $(LD) $(LD_OUT)imcc $(LDFLAGS) $(O_FILES) $(C_LIBS) diff -r -u parrot-orig/languages/imcc/imcc.l parrot-andy/languages/imcc/imcc.l --- parrot-orig/languages/imcc/imcc.l Tue Aug 27 10:09:00 2002 +++ parrot-andy/languages/imcc/imcc.l Mon Sep 2 15:32:27 2002 @@ -22,6 +22,7 @@ %} %option outfile="imclexer.c" +%option nounput LETTER [a-zA-Z_] DIGIT [0-9] -- Andy Dougherty [EMAIL PROTECTED] Dept. of Physics Lafayette College, Easton PA 18042