mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-22 10:43:02 +00:00
* src/parse-gram.y (char_name): New function.
(CHAR, STRING, string_content): For %printer, properly escape. (ID): Prefer fputs to fprintf. (id): Reindent to be consistent with other rules. Properly quote char.
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
2006-06-19 Paul Eggert <eggert@cs.ucla.edu>
|
2006-06-19 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
* src/parse-gram.y (char_name): New function.
|
||||||
|
(CHAR, STRING, string_content): For %printer, properly escape.
|
||||||
|
(ID): Prefer fputs to fprintf.
|
||||||
|
(id): Reindent to be consistent with other rules.
|
||||||
|
Properly quote char.
|
||||||
|
|
||||||
The Translation Project changed its way of publishing translations
|
The Translation Project changed its way of publishing translations
|
||||||
to maintainers. I haven't received any responses to my request
|
to maintainers. I haven't received any responses to my request
|
||||||
for supporting the old way, or for documenting the new way. I
|
for supporting the old way, or for documenting the new way. I
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ static void version_check (location const *loc, char const *version);
|
|||||||
gram_error (&yylloc, Msg)
|
gram_error (&yylloc, Msg)
|
||||||
static void gram_error (location const *, char const *);
|
static void gram_error (location const *, char const *);
|
||||||
|
|
||||||
|
static char const *char_name (char);
|
||||||
|
|
||||||
static void add_param (char const *, char *, location);
|
static void add_param (char const *, char *, location);
|
||||||
|
|
||||||
static symbol_class current_class = unknown_sym;
|
static symbol_class current_class = unknown_sym;
|
||||||
@@ -169,15 +171,16 @@ static int current_prec = 0;
|
|||||||
%token TYPE "type"
|
%token TYPE "type"
|
||||||
|
|
||||||
%type <character> CHAR
|
%type <character> CHAR
|
||||||
%printer { fprintf (stderr, "'%c' (%d)", $$, $$); } CHAR
|
%printer { fputs (char_name ($$), stderr); } CHAR
|
||||||
|
|
||||||
%type <chars> STRING string_content "{...}" PROLOGUE EPILOGUE
|
%type <chars> STRING string_content "{...}" PROLOGUE EPILOGUE
|
||||||
%printer { fprintf (stderr, "\"%s\"", $$); } STRING string_content
|
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
||||||
|
STRING string_content
|
||||||
%printer { fprintf (stderr, "{\n%s\n}", $$); } "{...}" PROLOGUE EPILOGUE
|
%printer { fprintf (stderr, "{\n%s\n}", $$); } "{...}" PROLOGUE EPILOGUE
|
||||||
|
|
||||||
%type <uniqstr> TYPE ID ID_COLON
|
%type <uniqstr> TYPE ID ID_COLON
|
||||||
%printer { fprintf (stderr, "<%s>", $$); } TYPE
|
%printer { fprintf (stderr, "<%s>", $$); } TYPE
|
||||||
%printer { fprintf (stderr, "%s", $$); } ID
|
%printer { fputs ($$, stderr); } ID
|
||||||
%printer { fprintf (stderr, "%s:", $$); } ID_COLON
|
%printer { fprintf (stderr, "%s:", $$); } ID_COLON
|
||||||
|
|
||||||
%type <integer> INT
|
%type <integer> INT
|
||||||
@@ -455,17 +458,18 @@ rhs:
|
|||||||
| Identifiers. |
|
| Identifiers. |
|
||||||
*---------------*/
|
*---------------*/
|
||||||
|
|
||||||
/* Identifiers are return as uniqstr by the scanner. Depending on
|
/* Identifiers are returned as uniqstr values by the scanner.
|
||||||
their use, we may need to make them genuine symbols. */
|
Depending on their use, we may need to make them genuine symbols. */
|
||||||
|
|
||||||
id:
|
id:
|
||||||
ID { $$ = symbol_get ($1, @1); }
|
ID
|
||||||
| CHAR { char cp[4] = { '\'', $1, '\'', 0 };
|
{ $$ = symbol_get ($1, @1); }
|
||||||
$$ = symbol_get (quotearg_style (escape_quoting_style, cp),
|
| CHAR
|
||||||
@1);
|
{
|
||||||
symbol_class_set ($$, token_sym, @1, false);
|
$$ = symbol_get (char_name ($1), @1);
|
||||||
symbol_user_token_number_set ($$, $1, @1);
|
symbol_class_set ($$, token_sym, @1, false);
|
||||||
}
|
symbol_user_token_number_set ($$, $1, @1);
|
||||||
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
id_colon:
|
id_colon:
|
||||||
@@ -609,3 +613,16 @@ token_name (int type)
|
|||||||
{
|
{
|
||||||
return yytname[YYTRANSLATE (type)];
|
return yytname[YYTRANSLATE (type)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char const *
|
||||||
|
char_name (char c)
|
||||||
|
{
|
||||||
|
if (c == '\'')
|
||||||
|
return "'\\''";
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char buf[4];
|
||||||
|
buf[0] = '\''; buf[1] = c; buf[2] = '\''; buf[3] = '\0';
|
||||||
|
return quotearg_style (escape_quoting_style, buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user