bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bison-1_29-branch] files.patch


From: marc-alexandre autret
Subject: [bison-1_29-branch] files.patch
Date: Mon, 10 Sep 2001 14:54:40 +0000 (GMT)

Hello,

Here a patch to Remove %header and %source extension.

It also allow to specify the graph and the defines 
output filenames.

The patch to update the doc and tests will follow.


Index: ChangeLog
===================================================================
RCS file: /cvsroot/bison/bison/ChangeLog,v
retrieving revision 1.173.2.31
diff -u -r1.173.2.31 ChangeLog
--- ChangeLog   2001/09/10 09:59:39     1.173.2.31
+++ ChangeLog   2001/09/10 12:42:57
@@ -1,3 +1,25 @@
+2001-09-10  Marc Autret  <address@hidden>
+
+       Remove %{source,header}_extension features.
+       Add possibility to specify a filename for graph output and 
+       defines output.
+       
+       * src/files.h: Update extern declaration.
+       * src/files.c (spec_defines_file, spec_graph_file): New char*.
+       (compute_exts_from_gf): Update.
+       (compute_exts_from_src): Update.
+       (compute_base_names): Add computation of header_extension from
+       spec_defines_file.
+       Update filenames computations for defines and graph.
+       * src/getargs.c (longopts): Declare --defines and --graph as options
+       with optional arguments.
+       * src/reader.c (parse_header_extension_decl): Remove.
+       (parse_source_extension_decl): Remove.
+       (parse_dquoted_param): CPP-out.
+       (read_declarations): Remove tok_{src,hdr} cases.
+       * src/lex.h (token_t): Remove tok_{src,hdr}.
+       * src/lex.c (percent_table): Remove %{header,source}_extension.
+
 2001-09-10  Akim Demaille  <address@hidden>
 
        * tests/output.at (AT_CHECK_BISON_FLAGS, AT_CHECK_BISON_PERCENT):
Index: src/files.c
===================================================================
RCS file: /cvsroot/bison/bison/src/files.c,v
retrieving revision 1.51
diff -u -r1.51 files.c
--- src/files.c 2001/08/15 08:53:15     1.51
+++ src/files.c 2001/09/10 12:42:57
@@ -39,6 +39,8 @@
 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;
@@ -260,16 +262,9 @@
 static void
 compute_exts_from_gf (const char *ext)
 {
-  /* Checks if SRC_EXTENSION is NULL. In the other case, %source_extension
-     was specified in the grammar file.  */
-  if (src_extension == NULL)
-    {
-      src_extension = tr (ext, 'y', 'c');
-      src_extension = tr (src_extension, 'Y', 'C');
-    }
-  /* Checks if HEADER_EXTENSION is NULL. In the other case,
-     %header_extension was specified in the grammar file.  */
-  if (header_extension == NULL)
+  src_extension = tr (ext, 'y', 'c');
+  src_extension = tr (src_extension, 'Y', 'C');
+  if (!header_extension)
     {
       header_extension = tr (ext, 'y', 'h');
       header_extension = tr (header_extension, 'Y', 'H');
@@ -280,12 +275,12 @@
 static void
 compute_exts_from_src (const char *ext)
 {
-  /* We use this function when the user specifies `-o' or `--output',
-     so the extenions must be computed unconditionally from the file name
-     given by this option.  */
   src_extension = xstrdup (ext);
-  header_extension = tr (ext, 'c', 'h');
-  header_extension = tr (header_extension, 'C', 'H');
+  if (!header_extension)
+    {
+      header_extension = tr (ext, 'c', 'h');
+      header_extension = tr (header_extension, 'C', 'H');
+    }
 }
 
 /* FIXME: Should use xstrndup. */
@@ -296,6 +291,17 @@
   size_t base_length;
   size_t short_base_length;
   size_t ext_index;
+  
+  /* If --defines=FILE is used.  */
+  if (spec_defines_file)
+    {
+      ext_index = get_extension_index (spec_defines_file);
+      if (ext_index)
+       ext_index = 
+         (strspn (spec_defines_file + ext_index + 1, "hH")) ? ext_index : 0;
+      if (ext_index)
+       header_extension = xstrdup (spec_defines_file + ext_index);
+  }
 
   /* If --output=foo.c was specified (SPEC_OUTFILE == foo.c),
      BASE_NAME and SHORT_BASE_NAME are `foo'.
@@ -447,7 +453,9 @@
 
   /* Output the header file if wanted. */
   if (defines_flag)
-    defines_obstack_save (stringappend (base_name, header_extension));
+    defines_obstack_save (spec_defines_file ?
+                         spec_defines_file : stringappend (base_name, 
+                                                           header_extension));
 
   /* If we output only the table, dump the actions in ACTFILE. */
   if (no_parser_flag)
@@ -474,5 +482,6 @@
                  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 ? 
+                 spec_graph_file : stringappend (short_base_name, ".vcg"));
 }
Index: src/files.h
===================================================================
RCS file: /cvsroot/bison/bison/src/files.h,v
retrieving revision 1.18
diff -u -r1.18 files.h
--- src/files.h 2001/08/06 09:22:33     1.18
+++ src/files.h 2001/09/10 12:42:57
@@ -33,7 +33,12 @@
 /* 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;
 
@@ -61,9 +66,6 @@
 
 extern char *infile;
 extern char *attrsfile;
-
-extern const char *src_extension;
-extern const char *header_extension;
 
 void open_files PARAMS((void));
 
Index: src/getargs.c
===================================================================
RCS file: /cvsroot/bison/bison/src/getargs.c,v
retrieving revision 1.24.2.1
diff -u -r1.24.2.1 getargs.c
--- src/getargs.c       2001/08/16 18:50:04     1.24.2.1
+++ src/getargs.c       2001/09/10 12:42:57
@@ -60,11 +60,11 @@
   {"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'},
-  {"graph",            no_argument,            0, 'g'},
+  {"graph",            optional_argument,      0, 'g'},
 
   /* Hidden. */
   {"statistics",       no_argument,    &statistics_flag, 1},
@@ -183,7 +183,9 @@
        exit (0);
 
       case 'g':
+       /* Here, the -g and --graph=FILE options are differentiated.  */
        graph_flag = 1;
+       spec_graph_file = optarg;
        break;
 
       case 'v':
@@ -195,7 +197,9 @@
        break;
 
       case 'd':
+       /* Here, the -d and --defines options are differentiated.  */
        defines_flag = 1;
+       spec_defines_file = optarg;
        break;
 
       case 'l':
Index: src/lex.c
===================================================================
RCS file: /cvsroot/bison/bison/src/lex.c,v
retrieving revision 1.33.2.2
diff -u -r1.33.2.2 lex.c
--- src/lex.c   2001/09/10 08:33:25     1.33.2.2
+++ src/lex.c   2001/09/10 12:42:57
@@ -555,8 +555,6 @@
   { "file_prefix",     &spec_file_prefix,      tok_setopt },   /* -b */
   { "name_prefix",     &spec_name_prefix,      tok_setopt },   /* -p */
 #endif
-  { "header_extension",        NULL,                   tok_hdrext },
-  { "source_extension",        NULL,                   tok_srcext },
   { "verbose",         &verbose_flag,          tok_noop },     /* -v */
   { "debug",           &debug_flag,            tok_noop },     /* -t */
   { "semantic_parser", &semantic_parser,       tok_noop },
Index: src/lex.h
===================================================================
RCS file: /cvsroot/bison/bison/src/lex.h,v
retrieving revision 1.13.2.1
diff -u -r1.13.2.1 lex.h
--- src/lex.h   2001/09/10 08:33:25     1.13.2.1
+++ src/lex.h   2001/09/10 12:42:57
@@ -48,8 +48,6 @@
     tok_number,
     tok_expect,
     tok_thong,
-    tok_hdrext,
-    tok_srcext,
     tok_noop,
     tok_setopt,
     tok_illegal,
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.72.2.3
diff -u -r1.72.2.3 reader.c
--- src/reader.c        2001/09/10 08:33:25     1.72.2.3
+++ src/reader.c        2001/09/10 12:42:58
@@ -874,10 +874,13 @@
   nsyms--;
 }
 
-/*--------------------------------------------------------------.
-| Parse what comes after %header_extension and %source_etension |
-`--------------------------------------------------------------*/
+/*-----------------------------------------------------------------------------.
+| Parse a double quoted parameter. It was used for %{source,header}_extension. 
|
+| For the moment, It is not used since extension features have been removed.   
|
+`-----------------------------------------------------------------------------*/
 
+#if 0
+
 static const char *
 parse_dquoted_param (const char *from)
 {
@@ -921,26 +924,8 @@
 
   return xstrdup (buff);
 }
-
-/* %header_extension case.  */
-static void
-parse_header_extension_decl (void)
-{
-  if (header_extension)
-    complain (_("multiple %%header_extension declarations"));
-
-  header_extension = parse_dquoted_param ("%header_extension");
-}
-
-/* %source_extension case.  */
-static void
-parse_source_extension_decl (void)
-{
-  if (src_extension)
-    complain (_("multiple %%source_extension declarations"));
 
-  src_extension = parse_dquoted_param ("%source_extension");
-}
+#endif
 
 /*----------------------------------------------------------------.
 | Read from finput until `%%' is seen.  Discard the `%%'.  Handle |
@@ -1009,14 +994,6 @@
 
            case tok_nonassoc:
              parse_assoc_decl (non_assoc);
-             break;
-
-           case tok_hdrext:
-             parse_header_extension_decl ();
-             break;
-
-           case tok_srcext:
-             parse_source_extension_decl ();
              break;
 
            case tok_noop:


-- 
Autret Marc (address@hidden)
Eleve Ingenieur en Informatique.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]