commit 529f7404f3cc22b9f89a1c72d7921d5891c38d5e
Author: Ryan Cahoon <ryan.cahoon@zoox.com>
Date:   Sun Mar 7 11:19:05 2021 -0800

    generated_file_prefix_argument

diff --git a/Src/main.c b/Src/main.c
index 586cd11..5b67ae8 100644
--- a/Src/main.c
+++ b/Src/main.c
@@ -21,6 +21,7 @@
 #endif
 #include "y.tab.h"
 
+extern char	*pan_file_prefix;
 extern int	DstepStart, lineno, tl_terse;
 extern FILE	*yyin, *yyout, *tl_out;
 extern Symbol	*context;
@@ -917,7 +918,10 @@ main(int argc, char *argv[])
 	while (argc > 1 && argv[1][0] == '-')
 	{	switch (argv[1][1]) {
 		case 'A': export_ast = 1; break;
-		case 'a': analyze = 1; break;
+		case 'a': if (argv[1][2] != '\0')
+			  {	pan_file_prefix = (char*) &argv[1][2];
+			  }
+			  analyze = 1; break;
 		case 'B': no_wrapup = 1; break;
 		case 'b': no_print = 1; break;
 		case 'C': Caccess = 1; break;
diff --git a/Src/pangen2.c b/Src/pangen2.c
index c8b7e8f..039eacf 100644
--- a/Src/pangen2.c
+++ b/Src/pangen2.c
@@ -39,6 +39,7 @@ extern char	*NextLab[64];	/* must match value in dstep.c:18 */
 int	 	 buzzed;
 FILE		*fd_tc, *fd_th, *fd_tt, *fd_tb;
 static FILE	*fd_tm;
+char		*pan_file_prefix = "pan";
 
 int	OkBreak = -1, has_hidden = 0; /* has_hidden set in sym.c and structs.c */
 short	nocast=0;	/* to turn off casts in lvalues */
@@ -197,13 +198,20 @@ tt_predef_np(void)
 static struct {
 	char *nm[3];
 } Cfile[] = {
-	{ { "pan.c", "pan_s.c", "pan_t.c" } },
-	{ { "pan.h", "pan_s.h", "pan_t.h" } },
-	{ { "pan.t", "pan_s.t", "pan_t.t" } },
-	{ { "pan.m", "pan_s.m", "pan_t.m" } },
-	{ { "pan.b", "pan_s.b", "pan_t.b" } }
+	{ { ".c", "_s.c", "_t.c" } },
+	{ { ".h", "_s.h", "_t.h" } },
+	{ { ".t", "_s.t", "_t.t" } },
+	{ { ".m", "_s.m", "_t.m" } },
+	{ { ".b", "_s.b", "_t.b" } }
 };
 
+FILE* fopen_pan_file(const char *suffix, const char *mode)
+{	char filename[512];
+	strcpy(filename, pan_file_prefix);
+	strcat(filename, suffix);
+	return fopen(filename, mode);
+}
+
 void
 gensrc(void)
 {	ProcList *p;
@@ -211,11 +219,11 @@ gensrc(void)
 
 	disambiguate();		/* avoid name-clashes between scopes */
 
-	if (!(fd_tc = fopen(Cfile[0].nm[separate], MFLAGS))		/* main routines */
-	||  !(fd_th = fopen(Cfile[1].nm[separate], MFLAGS))		/* header file   */
-	||  !(fd_tt = fopen(Cfile[2].nm[separate], MFLAGS))		/* transition matrix */
-	||  !(fd_tm = fopen(Cfile[3].nm[separate], MFLAGS))		/* forward  moves */
-	||  !(fd_tb = fopen(Cfile[4].nm[separate], MFLAGS)))	/* backward moves */
+	if (!(fd_tc = fopen_pan_file(Cfile[0].nm[separate], MFLAGS))		/* main routines */
+	||  !(fd_th = fopen_pan_file(Cfile[1].nm[separate], MFLAGS))		/* header file   */
+	||  !(fd_tt = fopen_pan_file(Cfile[2].nm[separate], MFLAGS))		/* transition matrix */
+	||  !(fd_tm = fopen_pan_file(Cfile[3].nm[separate], MFLAGS))		/* forward  moves */
+	||  !(fd_tb = fopen_pan_file(Cfile[4].nm[separate], MFLAGS)))	/* backward moves */
 	{	printf("spin: cannot create pan.[chtmfb]\n");
 		alldone(1);
 	}
@@ -466,9 +474,9 @@ doless:
 	plunk_c_decls(fd_tc);	/* types can be refered to in State */
 
 	switch (separate) {
-	case 0:	fprintf(fd_tc, "#include \"pan.h\"\n"); break;
-	case 1:	fprintf(fd_tc, "#include \"pan_s.h\"\n"); break;
-	case 2:	fprintf(fd_tc, "#include \"pan_t.h\"\n"); break;
+	case 0:	fprintf(fd_tc, "#include \"%s.h\"\n", pan_file_prefix); break;
+	case 1:	fprintf(fd_tc, "#include \"%s_s.h\"\n", pan_file_prefix); break;
+	case 2:	fprintf(fd_tc, "#include \"%s_t.h\"\n", pan_file_prefix); break;
 	}
 
 	if (separate != 2)
@@ -656,15 +664,15 @@ doless:
 	{	ntimes(fd_tt, 0, 1, Tail);
 		genheader();
 		if (separate == 1)
-		{	fprintf(fd_th, "#define FORWARD_MOVES\t\"pan_s.m\"\n");
-			fprintf(fd_th, "#define BACKWARD_MOVES\t\"pan_s.b\"\n");
+		{	fprintf(fd_th, "#define FORWARD_MOVES\t\"%s_s.m\"\n", pan_file_prefix);
+			fprintf(fd_th, "#define BACKWARD_MOVES\t\"%s_s.b\"\n", pan_file_prefix);
 			fprintf(fd_th, "#define SEPARATE\n");
-			fprintf(fd_th, "#define TRANSITIONS\t\"pan_s.t\"\n");
+			fprintf(fd_th, "#define TRANSITIONS\t\"%s_s.t\"\n", pan_file_prefix);
 			fprintf(fd_th, "extern void ini_claim(int, int);\n");
 		} else
-		{	fprintf(fd_th, "#define FORWARD_MOVES\t\"pan.m\"\n");
-			fprintf(fd_th, "#define BACKWARD_MOVES\t\"pan.b\"\n");
-			fprintf(fd_th, "#define TRANSITIONS\t\"pan.t\"\n");
+		{	fprintf(fd_th, "#define FORWARD_MOVES\t\"%s.m\"\n", pan_file_prefix);
+			fprintf(fd_th, "#define BACKWARD_MOVES\t\"%s.b\"\n", pan_file_prefix);
+			fprintf(fd_th, "#define TRANSITIONS\t\"%s.t\"\n", pan_file_prefix);
 		}
 		genaddproc();
 		genother();
@@ -692,9 +700,9 @@ doless:
 		}
 	} else
 	{	genheader();
-		fprintf(fd_th, "#define FORWARD_MOVES\t\"pan_t.m\"\n");
-		fprintf(fd_th, "#define BACKWARD_MOVES\t\"pan_t.b\"\n");
-		fprintf(fd_th, "#define TRANSITIONS\t\"pan_t.t\"\n");
+		fprintf(fd_th, "#define FORWARD_MOVES\t\"%s_t.m\"\n", pan_file_prefix);
+		fprintf(fd_th, "#define BACKWARD_MOVES\t\"%s_t.b\"\n", pan_file_prefix);
+		fprintf(fd_th, "#define TRANSITIONS\t\"%s_t.t\"\n", pan_file_prefix);
 		fprintf(fd_tc, "extern int Maxbody;\n");
 		fprintf(fd_tc, "#if VECTORSZ>32000\n");
 		fprintf(fd_tc, "	extern int *proc_offset;\n");
@@ -726,7 +734,7 @@ doless:
 		fprintf(fd_tc, "{	int forw = t->forw; int _m = 0; extern char *noptr; int II=0;\n");
 		fprintf(fd_tc, "	extern State now;\n");
 		fprintf(fd_tc, "#define continue	return 0\n");
-		fprintf(fd_tc, "#include \"pan_t.m\"\n");
+		fprintf(fd_tc, "#include \"%s_t.m\"\n", pan_file_prefix);
 		fprintf(fd_tc, "P999:\n\treturn _m;\n}\n");
 		fprintf(fd_tc, "#undef continue\n");
 		fprintf(fd_tc, "int\nrev_claim(int backw)\n{ return 0; }\n");
@@ -753,7 +761,7 @@ doless:
 	fclose(fd_tm);
 	fclose(fd_tb);
 
-	if (!(fd_th = fopen("pan.p", MFLAGS)))
+	if (!(fd_th = fopen_pan_file(".p", MFLAGS)))
 	{	printf("spin: cannot create pan.p for -DBFS_PAR\n");
 		return; 	/* we're done anyway */
 	}
@@ -764,7 +772,7 @@ doless:
 	fprintf(fd_tc, "\nTrans *t_id_lkup[%d];\n\n", globmax+1); 
 
 	if (separate != 2)
-	{	fprintf(fd_tc, "\n#ifdef BFS_PAR\n\t#include \"pan.p\"\n#endif\n");
+	{	fprintf(fd_tc, "\n#ifdef BFS_PAR\n\t#include \"%s.p\"\n#endif\n", pan_file_prefix);
 	}
 	fprintf(fd_tc, "\n/* end of pan.c */\n");
 	fclose(fd_tc);
