diff -u src.orig/defs.h src/defs.h --- src.orig/defs.h 2002-11-30 14:26:13.000000000 -0500 +++ src/defs.h 2005-12-14 03:35:50.000000000 -0500 @@ -228,12 +228,14 @@ extern char *prolog_file_name; extern char *local_file_name; extern char *verbose_file_name; +extern char *template_file_name; extern FILE *action_file; extern FILE *input_file; extern FILE *prolog_file; extern FILE *local_file; extern FILE *verbose_file; +extern FILE *template_file; extern int nitems; extern int nrules; diff -u src.orig/main.c src/main.c --- src.orig/main.c 2002-12-13 07:48:25.000000000 -0500 +++ src/main.c 2005-12-14 03:38:07.000000000 -0500 @@ -62,6 +62,7 @@ char *prolog_file_name; char *local_file_name; char *verbose_file_name; +char *template_file_name; FILE *action_file; /* a temp file, used to save actions associated */ /* with rules until the parser is written */ @@ -69,6 +70,7 @@ FILE *prolog_file; /* temp files, used to save text until all */ FILE *local_file; /* symbols have been defined */ FILE *verbose_file; /* y.output */ +FILE *template_file; int nitems; int nrules; @@ -210,8 +212,12 @@ } no_more_options:; - if (i + 1 != argc) usage(); +#ifndef DEFAULT_TEMPLATE_FILE +#define DEFAULT_TEMPLATE_FILE "-" +#endif + if (i + 1 > argc || i + 2 < argc) usage(); input_file_name = argv[i]; + template_file_name = i + 2 > argc ? DEFAULT_TEMPLATE_FILE : argv[i+1]; } @@ -317,6 +323,11 @@ if (verbose_file == 0) open_error(verbose_file_name); } + + template_file = strcmp(template_file_name,"-")==0 ? stdin : fopen(template_file_name, "r"); + if(template_file == NULL) { + open_error(template_file_name); + } } diff -u src.orig/makefile src/makefile --- src.orig/makefile 2004-07-25 04:14:49.000000000 -0400 +++ src/makefile 2005-12-14 05:26:37.000000000 -0500 @@ -5,20 +5,35 @@ # make will create jay.exe with GNU C. # make CC=c89 will create jay.exe with Visual C++. -CC = `if [ -n "$$COMSPEC" ]; then echo gcc; else echo cc; fi` -CFLAGS = -s # -g +CC = mips-unknown-elf-gcc +CFLAGS = -DDEFAULT_TEMPLATE_FILE='"/resource/edu/rit/ats/jay/skeleton.java"' c = closure.c error.c lalr.c lr0.c main.c mkpar.c output.c reader.c \ symtab.c verbose.c warshall.c -e = `if [ -n "$$COMSPEC" ]; then echo jay.exe; else echo jay; fi` +e = jay.mips + +all: jay.jar +clean: + rm -f *.o + rm -rf edu + rm jay.jar -all: jay -clean: ; rm -f *.o dist: all distclean: clean ; rm -f jay jay.exe test: all -jay: $(c:.c=.o) ; $(CC) -o $e $(CFLAGS) $(c:.c=.o) +$(e): $(c:.c=.o) ; $(CC) -o $e $(CFLAGS) $(c:.c=.o) + +edu/rit/ats/jay/Main.class: $(e) + @mkdir -p `dirname $@` + java org.ibex.nestedvm.Compiler -o unixruntime -outfile edu/rit/ats/jay/Main.class edu.rit.ats.jay.Main $(e) + +jay.jar: edu/rit/ats/jay/Main.class + cp ../java/skeleton.java edu/rit/ats/jay + cp ../cs/skeleton.cs edu/rit/ats/jay + cp ${HOME}/Work/nestedvm/unix_runtime.jar $@ + printf "Main-Class: edu.rit.ats.jay.Main\n" > .manifest + jar umf .manifest $@ edu/rit/ats/jay depend: $c ; $(CC) -MM $(CFLAGS) $c > $@ -include depend diff -u src.orig/output.c src/output.c --- src.orig/output.c 2004-07-24 02:50:16.000000000 -0400 +++ src/output.c 2005-12-14 03:30:40.000000000 -0500 @@ -65,7 +65,7 @@ free_shifts(); free_reductions(); - while (fgets(buf, sizeof buf, stdin) != NULL) { + while (fgets(buf, sizeof buf, template_file) != NULL) { char * cp; ++ lno; if (buf[strlen(buf)-1] != '\n')