[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bison-1_29-branch] percent_parse.patch
From: |
marc-alexandre autret |
Subject: |
[bison-1_29-branch] percent_parse.patch |
Date: |
Thu, 16 Aug 2001 18:24:00 +0000 (GMT) |
New parse algorithm for %{source,header}_extension.
I must think more about the authorized characters in
the extension. If anyone has ideas, I take!
--- bison/src/reader.c Wed Aug 15 10:40:19 2001
+++ bison-modif/src/reader.c Thu Aug 16 17:11:50 2001
@@ -874,34 +874,72 @@
nsyms--;
}
-/*------------------------------------------.
-| Parse what comes after %header_extension. |
-`------------------------------------------*/
+/*--------------------------------------------------------------.
+| Parse what comes after %header_extension and %source_etension |
+`--------------------------------------------------------------*/
-static void
-parse_header_extension_decl (void)
+static const char *
+parse_dquoted_param (const char *from)
{
char buff[32];
+ int c;
+ int index;
+
+ c = skip_white_space ();
+
+ if (c != '"')
+ {
+ ungetc (c, finput);
+ complain (_("invalid %s declaration"), from);
+ return NULL;
+ }
+
+ c = getc (finput);
+ for (index = 0; (c >= '!') && (c <= '~'); index++)
+ {
+ if (c == '"')
+ break;
+
+ if (c == '\\')
+ {
+ c = getc (finput);
+ if ((c < '!') && (c > '~'))
+ break;
+ }
+
+ buff[index] = c;
+ c = getc (finput);
+ }
+ buff[index] = '\0';
+
+ if (c != '"')
+ {
+ ungetc (c, finput);
+ complain (_("invalid %s declaration"), from);
+ return NULL;
+ }
+ return xstrdup (buff);
+}
+
+/* %header_extension case. */
+static void
+parse_header_extension_decl (void)
+{
if (header_extension)
complain (_("multiple %%header_extension declarations"));
- fscanf (finput, "%s", buff);
- header_extension = xstrdup (buff);
-}
-/*------------------------------------------.
-| Parse what comes after %source_extension. |
-`------------------------------------------*/
+ header_extension = parse_dquoted_param ("%header_extension");
+}
+/* %source_extension case. */
static void
parse_source_extension_decl (void)
{
- char buff[32];
-
if (src_extension)
complain (_("multiple %%source_extension declarations"));
- fscanf (finput, "%s", buff);
- src_extension = xstrdup (buff);
+
+ src_extension = parse_dquoted_param ("%source_extension");
}
/*----------------------------------------------------------------.
--- bison/ChangeLog Wed Aug 15 10:44:16 2001
+++ bison-modif/ChangeLog Thu Aug 16 13:31:01 2001
@@ -1,3 +1,16 @@
+2001-08-16 Marc Autret <address@hidden>
+
+ * src/reader.c (parse_dquoted_param): New.
+ (parse_header_extension_decl): Use it.
+ (parse_source_extension_decl): Likewise.
+
2001-08-15 Akim Demaille <address@hidden>
Version 1.28c.
--
Autret Marc (address@hidden)
Eleve Ingenieur en Informatique
- [bison-1_29-branch] percent_parse.patch,
marc-alexandre autret <=