]> git.saurik.com Git - bison.git/commitdiff
* src/getargs.c (longopts): Declare --defines and --graph as options
authorMarc Autret <autret_m@epita.fr>
Mon, 17 Sep 2001 23:00:01 +0000 (23:00 +0000)
committerMarc Autret <autret_m@epita.fr>
Mon, 17 Sep 2001 23:00:01 +0000 (23:00 +0000)
with optional arguments.
* src/files.h: Add extern declarations.
* src/files.c (spec_graph_file, spec_defines_file): New.
(output_files): Update.
Remove CPP-outed code.

ChangeLog
src/files.c
src/files.h
src/getargs.c

index 13b1dd61fa9e4d25d9da84c06243cb62b6275d6c..adf7058d0bb3f3c7bf947d6180d2720e73f4bd9b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2001-09-18  Marc Autret  <autret_m@epita.fr>
+       
+       * src/getargs.c (longopts): Declare --defines and --graph as options
+       with optional arguments.
+       * src/files.h: Add extern declarations.
+       * src/files.c (spec_graph_file, spec_defines_file): New.
+       (output_files): Update.
+       Remove CPP-outed code.
+
 2001-09-18  Marc Autret  <autret_m@epita.fr>
 
        Turn off %{source,header}_extension feature.
 2001-09-18  Marc Autret  <autret_m@epita.fr>
 
        Turn off %{source,header}_extension feature.
index 35cd872dd43d83083b47bc8834f2b41cabc31f96..f9cb6f3312dac431f8b49baf19fdb8224f4bb902 100644 (file)
@@ -39,6 +39,8 @@ struct obstack graph_obstack;
 char *spec_outfile = NULL;     /* for -o. */
 char *spec_file_prefix = NULL; /* for -b. */
 char *spec_name_prefix = NULL; /* for -p. */
 char *spec_outfile = NULL;     /* for -o. */
 char *spec_file_prefix = NULL; /* for -b. */
 char *spec_name_prefix = NULL; /* for -p. */
+char *spec_graph_file = NULL;   /* for -g. */
+char *spec_defines_file = NULL; /* for --defines. */
 
 char *infile = NULL;
 char *attrsfile = NULL;
 
 char *infile = NULL;
 char *attrsfile = NULL;
@@ -418,14 +420,14 @@ output_files (void)
 
   compute_base_names ();
 
 
   compute_base_names ();
 
-#if 0
-  /* Set default extensions */
-  if (!src_extension)
-    src_extension = ".c";
-  if (!header_extension)
-    header_extension = ".h";
-#endif
-
+  /* It the defines filename if not given, we create it.  */
+  if (!spec_defines_file)
+    spec_defines_file = stringappend (base_name, header_extension);
+  
+  /* It the graph filename if not given, we create it.  */
+  if (!spec_graph_file)
+    spec_graph_file = stringappend (short_base_name, ".vcg");
+  
   attrsfile = stringappend (short_base_name, EXT_STYPE_H);
 #ifndef MSDOS
   stringappend (attrsfile, header_extension);
   attrsfile = stringappend (short_base_name, EXT_STYPE_H);
 #ifndef MSDOS
   stringappend (attrsfile, header_extension);
@@ -439,7 +441,7 @@ output_files (void)
 
   /* Output the header file if wanted. */
   if (defines_flag)
 
   /* Output the header file if wanted. */
   if (defines_flag)
-    defines_obstack_save (stringappend (base_name, header_extension));
+    defines_obstack_save (spec_defines_file);
 
   /* If we output only the table, dump the actions in ACTFILE. */
   if (no_parser_flag)
 
   /* If we output only the table, dump the actions in ACTFILE. */
   if (no_parser_flag)
@@ -466,5 +468,5 @@ output_files (void)
                  stringappend (short_base_name, EXT_OUTPUT));
 
   if (graph_flag)
                  stringappend (short_base_name, EXT_OUTPUT));
 
   if (graph_flag)
-    obstack_save (&graph_obstack, stringappend (short_base_name, ".vcg"));
+    obstack_save (&graph_obstack, spec_graph_file);
 }
 }
index 7ffaf9580e149bb6e84e1aba4934e7bca1a6dc15..1d540f2c2b6188544e7cb8d53a69e4089df9ddbb 100644 (file)
@@ -33,10 +33,16 @@ extern char *spec_name_prefix;
 /* File name pfx specified with -b, or 0 if no -b.  */
 extern char *spec_file_prefix;
 
 /* File name pfx specified with -b, or 0 if no -b.  */
 extern char *spec_file_prefix;
 
+/* File name specified for the output VCG graph.  */
+extern char *spec_graph_file;
+/* File name specified with --defines.  */
+extern char *spec_defines_file;
 
 /* Read grammar specifications. */
 extern FILE *finput;
 
 
 /* Read grammar specifications. */
 extern FILE *finput;
 
+
 /* Output all the action code; precise form depends on which parser. */
 extern struct obstack action_obstack;
 
 /* Output all the action code; precise form depends on which parser. */
 extern struct obstack action_obstack;
 
index 70f0d32c624253a02920ec6ef9ace45d1088e758..4bcd3775634694d9e83828ff2a8833ece1965484 100644 (file)
@@ -60,11 +60,11 @@ static struct option longopts[] =
   {"token-table",      no_argument,            0, 'k'},
 
   /* Output. */
   {"token-table",      no_argument,            0, 'k'},
 
   /* Output. */
-  {"defines",          no_argument,            0, 'd'},
+  {"defines",          optional_argument,      0, 'd'},
   {"verbose",          no_argument,            0, 'v'},
   {"file-prefix",      required_argument,      0, 'b'},
   {"output-file",      required_argument,      0, 'o'},
   {"verbose",          no_argument,            0, 'v'},
   {"file-prefix",      required_argument,      0, 'b'},
   {"output-file",      required_argument,      0, 'o'},
-  {"graph",            no_argument,            0, 'g'},
+  {"graph",            optional_argument,      0, 'g'},
 
   /* Hidden. */
   {"statistics",       no_argument,    &statistics_flag, 1},
 
   /* Hidden. */
   {"statistics",       no_argument,    &statistics_flag, 1},
@@ -183,7 +183,9 @@ getargs (int argc, char *argv[])
        exit (0);
 
       case 'g':
        exit (0);
 
       case 'g':
+       /* Here, the -g and --graph=FILE options are differentiated.  */        
        graph_flag = 1;
        graph_flag = 1;
+       spec_graph_file = optarg;
        break;
 
       case 'v':
        break;
 
       case 'v':
@@ -195,7 +197,9 @@ getargs (int argc, char *argv[])
        break;
 
       case 'd':
        break;
 
       case 'd':
+       /* Here, the -d and --defines options are differentiated.  */
        defines_flag = 1;
        defines_flag = 1;
+       spec_defines_file = optarg;
        break;
 
       case 'l':
        break;
 
       case 'l':