mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
* 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.
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2002-04-25 Robert Anisko <robert@lrde.epita.fr>
|
||||||
|
|
||||||
|
* 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 <akim@epita.fr>
|
2002-04-25 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* tests/sets.at (AT_EXTRACT_SETS): Sed portability issue: no space
|
* tests/sets.at (AT_EXTRACT_SETS): Sed portability issue: no space
|
||||||
|
|||||||
32
src/reader.c
32
src/reader.c
@@ -332,6 +332,28 @@ get_type_name (int n, symbol_list *rule)
|
|||||||
return rp->sym->type_name;
|
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 |
|
| Dump the string from FIN to OOUT if non null. MATCH is the |
|
||||||
| delimiter of the string (either ' or "). |
|
| delimiter of the string (either ' or "). |
|
||||||
@@ -359,14 +381,14 @@ copy_string2 (FILE *fin, struct obstack *oout, int match, int store)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
obstack_1grow (oout, c);
|
copy_character (oout, c);
|
||||||
|
|
||||||
if (c == '\\')
|
if (c == '\\')
|
||||||
{
|
{
|
||||||
c = getc (fin);
|
c = getc (fin);
|
||||||
if (c == EOF)
|
if (c == EOF)
|
||||||
fatal (_("unterminated string at end of file"));
|
fatal (_("unterminated string at end of file"));
|
||||||
obstack_1grow (oout, c);
|
copy_character (oout, c);
|
||||||
|
|
||||||
if (c == '\n')
|
if (c == '\n')
|
||||||
++lineno;
|
++lineno;
|
||||||
@@ -463,7 +485,7 @@ copy_comment (FILE *fin, struct obstack *oout)
|
|||||||
fatal (_("unterminated comment"));
|
fatal (_("unterminated comment"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
obstack_1grow (oout, c);
|
copy_character (oout, c);
|
||||||
c = getc (fin);
|
c = getc (fin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -634,7 +656,7 @@ copy_definition (struct obstack *oout)
|
|||||||
fatal ("%s", _("unterminated `%{' definition"));
|
fatal ("%s", _("unterminated `%{' definition"));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
obstack_1grow (oout, c);
|
copy_character (oout, c);
|
||||||
}
|
}
|
||||||
|
|
||||||
c = getc (finput);
|
c = getc (finput);
|
||||||
@@ -1666,7 +1688,7 @@ read_additionnal_code (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ((c = getc (finput)) != EOF)
|
while ((c = getc (finput)) != EOF)
|
||||||
obstack_1grow (&el_obstack, c);
|
copy_character (&el_obstack, c);
|
||||||
|
|
||||||
obstack_1grow (&el_obstack, 0);
|
obstack_1grow (&el_obstack, 0);
|
||||||
muscle_insert ("epilogue", obstack_finish (&el_obstack));
|
muscle_insert ("epilogue", obstack_finish (&el_obstack));
|
||||||
|
|||||||
@@ -38,9 +38,12 @@ static char *yyoutname = NULL;
|
|||||||
yylineno = 1;
|
yylineno = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"@<:@" fputc ('[', yyout);
|
||||||
|
"@:>@" fputc (']', yyout);
|
||||||
|
|
||||||
"__oline__" fprintf (yyout, "%d", yylineno);
|
"__oline__" fprintf (yyout, "%d", yylineno);
|
||||||
"__ofile__" fprintf (yyout, "%s", yyoutname);
|
"__ofile__" fprintf (yyout, "%s", yyoutname);
|
||||||
[^_\n]+ ECHO;
|
[^@_\n]+ ECHO;
|
||||||
\n+ yylineno += yyleng; ECHO;
|
\n+ yylineno += yyleng; ECHO;
|
||||||
. ECHO;
|
. ECHO;
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ typedef int value_t;
|
|||||||
|
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
/* Exercise M4 quoting: '@:>@@:>@', 0. */
|
||||||
|
|
||||||
/* Also exercise %union. */
|
/* Also exercise %union. */
|
||||||
%union
|
%union
|
||||||
{
|
{
|
||||||
@@ -76,6 +78,9 @@ typedef int value_t;
|
|||||||
/* Exercise post-prologue dependency to %union. */
|
/* Exercise post-prologue dependency to %union. */
|
||||||
%{
|
%{
|
||||||
static void id (YYSTYPE *lval);
|
static void id (YYSTYPE *lval);
|
||||||
|
|
||||||
|
/* Exercise quotes in declarations. */
|
||||||
|
char quote[] = "@:>@@:>@,";
|
||||||
%}
|
%}
|
||||||
|
|
||||||
/* Bison Declarations */
|
/* Bison Declarations */
|
||||||
@@ -83,6 +88,9 @@ static void id (YYSTYPE *lval);
|
|||||||
%token <ival> NUM "number"
|
%token <ival> NUM "number"
|
||||||
%type <ival> exp
|
%type <ival> exp
|
||||||
|
|
||||||
|
/* Exercise quotes in strings. */
|
||||||
|
%token "fake @>:@@>:@,"
|
||||||
|
|
||||||
%nonassoc '=' /* comparison */
|
%nonassoc '=' /* comparison */
|
||||||
%left '-' '+'
|
%left '-' '+'
|
||||||
%left '*' '/'
|
%left '*' '/'
|
||||||
@@ -100,9 +108,14 @@ input:
|
|||||||
|
|
||||||
line:
|
line:
|
||||||
'\n'
|
'\n'
|
||||||
| exp '\n' {}
|
| exp '\n'
|
||||||
|
{
|
||||||
|
/* Exercise quotes in braces. */
|
||||||
|
char tmp[] = "@>:@@:>@,";
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
/* Exercise M4 quoting: '@:>@@:>@', 1. */
|
||||||
exp:
|
exp:
|
||||||
NUM { $$ = $1; }
|
NUM { $$ = $1; }
|
||||||
| exp '=' exp
|
| exp '=' exp
|
||||||
@@ -124,6 +137,7 @@ exp:
|
|||||||
/* The input. */
|
/* The input. */
|
||||||
FILE *yyin;
|
FILE *yyin;
|
||||||
|
|
||||||
|
/* Exercise M4 quoting: '@:>@@:>@', 2. */
|
||||||
static void
|
static void
|
||||||
yyerror (const char *s)
|
yyerror (const char *s)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user