[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FYI] m4-quadrigraphs.patch
From: |
Robert Anisko |
Subject: |
[FYI] m4-quadrigraphs.patch |
Date: |
Thu, 25 Apr 2002 16:46:11 +0200 (CEST) |
Index: ChangeLog
===================================================================
RCS file: /cvsroot/bison/bison/ChangeLog,v
retrieving revision 1.645
diff -u -r1.645 ChangeLog
--- ChangeLog 25 Apr 2002 10:30:27 -0000 1.645
+++ ChangeLog 25 Apr 2002 14:34:49 -0000
@@ -1,3 +1,17 @@
+2002-04-25 Robert Anisko <address@hidden>
+
+ * src/scan-skel.l: Postprocess quadrigraphs.
+
+ * src/reader.c (copy_character): New function, used to output
+ single characters while replacing `[' and `]' with quadrigraphs, to
+ avoid troubles with M4 quotes.
+ (copy_comment): Output characters with copy_character.
+ (read_additionnal_code): Likewise.
+ (copy_string2): Likewise.
+ (copy_definition): Likewise.
+
+ * tests/calc.at: Exercise M4 quoting.
+
2002-04-25 Akim Demaille <address@hidden>
* tests/sets.at (AT_EXTRACT_SETS): Sed portability issue: no space
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.169
diff -u -r1.169 reader.c
--- src/reader.c 24 Apr 2002 16:22:57 -0000 1.169
+++ src/reader.c 25 Apr 2002 14:34:49 -0000
@@ -332,6 +332,28 @@
return rp->sym->type_name;
}
+/*------------------------------------------------------------------.
+| Copy the character C to OOUT, and insert quadigraphs when needed. |
+`------------------------------------------------------------------*/
+
+static inline void
+copy_character (struct obstack *oout, int c)
+{
+ switch (c)
+ {
+ case '[':
+ obstack_sgrow (oout, "@<:@");
+ break;
+
+ case ']':
+ obstack_sgrow (oout, "@:>@");
+ break;
+
+ default:
+ obstack_1grow (oout, c);
+ }
+}
+
/*------------------------------------------------------------.
| Dump the string from FIN to OOUT if non null. MATCH is the |
| delimiter of the string (either ' or "). |
@@ -359,14 +381,14 @@
continue;
}
- obstack_1grow (oout, c);
+ copy_character (oout, c);
if (c == '\\')
{
c = getc (fin);
if (c == EOF)
fatal (_("unterminated string at end of file"));
- obstack_1grow (oout, c);
+ copy_character (oout, c);
if (c == '\n')
++lineno;
@@ -463,7 +485,7 @@
fatal (_("unterminated comment"));
else
{
- obstack_1grow (oout, c);
+ copy_character (oout, c);
c = getc (fin);
}
}
@@ -634,7 +656,7 @@
fatal ("%s", _("unterminated `%{' definition"));
default:
- obstack_1grow (oout, c);
+ copy_character (oout, c);
}
c = getc (finput);
@@ -1666,7 +1688,7 @@
}
while ((c = getc (finput)) != EOF)
- obstack_1grow (&el_obstack, c);
+ copy_character (&el_obstack, c);
obstack_1grow (&el_obstack, 0);
muscle_insert ("epilogue", obstack_finish (&el_obstack));
Index: src/scan-skel.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-skel.l,v
retrieving revision 1.8
diff -u -r1.8 scan-skel.l
--- src/scan-skel.l 8 Apr 2002 12:31:15 -0000 1.8
+++ src/scan-skel.l 25 Apr 2002 14:34:49 -0000
@@ -38,9 +38,12 @@
yylineno = 1;
}
+"@<:@" fputc ('[', yyout);
+"@:>@" fputc (']', yyout);
+
"__oline__" fprintf (yyout, "%d", yylineno);
"__ofile__" fprintf (yyout, "%s", yyoutname);
-[^_\n]+ ECHO;
address@hidden ECHO;
\n+ yylineno += yyleng; ECHO;
. ECHO;
Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.20
diff -u -r1.20 calc.at
--- tests/calc.at 24 Apr 2002 16:22:57 -0000 1.20
+++ tests/calc.at 25 Apr 2002 14:34:50 -0000
@@ -67,6 +67,8 @@
%}
+/* Exercise M4 quoting: '@:>@@:>@', 0. */
+
/* Also exercise %union. */
%union
{
@@ -76,6 +78,9 @@
/* Exercise post-prologue dependency to %union. */
%{
static void id (YYSTYPE *lval);
+
+/* Exercise quotes in declarations. */
+char quote[] = "@:>@@:>@,";
%}
/* Bison Declarations */
@@ -83,6 +88,9 @@
%token <ival> NUM "number"
%type <ival> exp
+/* Exercise quotes in strings. */
+%token "fake @>:@@>:@,"
+
%nonassoc '=' /* comparison */
%left '-' '+'
%left '*' '/'
@@ -100,9 +108,14 @@
line:
'\n'
-| exp '\n' {}
+| exp '\n'
+ {
+ /* Exercise quotes in braces. */
+ char tmp[] = "@>:@@:>@,";
+ }
;
+/* Exercise M4 quoting: '@:>@@:>@', 1. */
exp:
NUM { $$ = $1; }
| exp '=' exp
@@ -124,6 +137,7 @@
/* The input. */
FILE *yyin;
+/* Exercise M4 quoting: '@:>@@:>@', 2. */
static void
yyerror (const char *s)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [FYI] m4-quadrigraphs.patch,
Robert Anisko <=