[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: i18n for yacc backend messages
From: |
Paul Eggert |
Subject: |
Re: i18n for yacc backend messages |
Date: |
Fri, 15 Apr 2005 23:38:37 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
Jan Nieuwenhuizen <address@hidden> writes:
> Ok, see patch below.
Thanks, but your patch was incomplete, as it didn't contain any fixes
to lib/quotearg.c.
I installed this patch instead. It doesn't require any changes to
quotearg (a shared module) so it's better in that respect.
Quoting is a pain to get right, I'm afraid. I wouldn't be surprised
at all if the code is still buggy after this patch.
2005-04-15 Paul Eggert <address@hidden>
* src/parse-gram.y: Include quotearg.h.
(string_as_id): Quote $1 before using it as a key, since the
lexer no longer quotes it for us.
(string_content): Don't strip quotes, since lexer no longer
quotes it for us.
* src/scan-gram.l: Include quotearg.h.
("\""): Omit quote.
("'"<SC_ESCAPED_CHARACTER>): Quote symbol before using it as
a key, since the rest of the lexer doesn't quote it.
* src/symtab.c (symbol_get): Don't quote symbol; caller does it now.
* tests/regression.at (Token definitions): Check for backslashes
in token strings.
Index: src/parse-gram.y
===================================================================
RCS file: /cvsroot/bison/bison/src/parse-gram.y,v
retrieving revision 1.52
diff -p -u -r1.52 parse-gram.y
--- src/parse-gram.y 6 Oct 2004 15:52:24 -0000 1.52
+++ src/parse-gram.y 16 Apr 2005 06:14:42 -0000
@@ -1,6 +1,6 @@
%{/* Bison Grammar Parser -*- C -*-
- Copyright (C) 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -29,6 +29,7 @@
#include "gram.h"
#include "muscle_tab.h"
#include "output.h"
+#include "quotearg.h"
#include "reader.h"
#include "symlist.h"
@@ -403,25 +404,23 @@ symbol:
action:
BRACED_CODE
- { $$ = $1; }
+ { $$ = $1; }
;
-/* A string used as an ID: we have to keep the quotes. */
+/* A string used as an ID: quote it. */
string_as_id:
STRING
{
- $$ = symbol_get ($1, @1);
+ $$ = symbol_get (quotearg_style (c_quoting_style, $1), @1);
symbol_class_set ($$, token_sym, @1);
}
;
-/* A string used for its contents. Strip the quotes. */
+/* A string used for its contents. Don't quote it. */
string_content:
STRING
- {
- $$ = $1 + 1;
- $$[strlen ($$) - 1] = '\0';
- };
+ { $$ = $1; }
+;
epilogue.opt:
Index: src/scan-gram.l
===================================================================
RCS file: /cvsroot/bison/bison/src/scan-gram.l,v
retrieving revision 1.71
diff -p -u -r1.71 scan-gram.l
--- src/scan-gram.l 7 Mar 2005 06:41:39 -0000 1.71
+++ src/scan-gram.l 16 Apr 2005 06:14:42 -0000
@@ -34,6 +34,7 @@
#include "files.h"
#include "getargs.h"
#include "gram.h"
+#include "quotearg.h"
#include "reader.h"
#include "uniqstr.h"
@@ -249,7 +250,7 @@ splice (\\[ \f\t\v]*\n)*
"'" STRING_GROW; token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
/* Strings. */
- "\"" STRING_GROW; token_start = loc->start; BEGIN SC_ESCAPED_STRING;
+ "\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
/* Prologue. */
"%{" code_start = loc->start; BEGIN SC_PROLOGUE;
@@ -360,7 +361,6 @@ splice (\\[ \f\t\v]*\n)*
<SC_ESCAPED_STRING>
{
"\"" {
- STRING_GROW;
STRING_FINISH;
loc->start = token_start;
val->chars = last_string;
@@ -384,7 +384,9 @@ splice (\\[ \f\t\v]*\n)*
STRING_GROW;
STRING_FINISH;
loc->start = token_start;
- val->symbol = symbol_get (last_string, *loc);
+ val->symbol = symbol_get (quotearg_style (escape_quoting_style,
+ last_string),
+ *loc);
symbol_class_set (val->symbol, token_sym, *loc);
last_string_1 = last_string[1];
symbol_user_token_number_set (val->symbol, last_string_1, *loc);
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.60
diff -p -u -r1.60 symtab.c
--- src/symtab.c 12 Apr 2005 22:38:20 -0000 1.60
+++ src/symtab.c 16 Apr 2005 06:14:42 -0000
@@ -475,8 +475,7 @@ symbol_get (const char *key, location lo
symbol probe;
symbol *entry;
- /* Keep the symbol in a printable form. */
- key = uniqstr_new (quotearg_style (escape_quoting_style, key));
+ key = uniqstr_new (key);
probe.tag = key;
entry = hash_lookup (symbol_table, &probe);
Index: tests/regression.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/regression.at,v
retrieving revision 1.88
diff -p -u -r1.88 regression.at
--- tests/regression.at 26 Mar 2005 01:12:59 -0000 1.88
+++ tests/regression.at 16 Apr 2005 06:14:42 -0000
@@ -314,20 +314,44 @@ AT_SETUP([Token definitions])
# Bison managed, when fed with `%token 'f' "f"' to #define 'f'!
AT_DATA_GRAMMAR([input.y],
[%{
-void yyerror (const char *s);
+#include <stdio.h>
+void yyerror (char const *s);
int yylex (void);
%}
-[%token MYEOF 0 "end of file"
+[%error-verbose
+%token MYEOF 0 "end of file"
%token 'a' "a"
%token B_TOKEN "b"
%token C_TOKEN 'c'
%token 'd' D_TOKEN
+%token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\377\x001\x0000ff"
+%%
+exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\377\x001\x0000ff";
%%
-exp: "a";
+void
+yyerror (char const *s)
+{
+ fprintf (stderr, "%s\n", s);
+}
+
+int
+yylex (void)
+{
+ return SPECIAL;
+}
+
+int
+main (void)
+{
+ return yyparse ();
+}
]])
AT_CHECK([bison -o input.c input.y])
-AT_COMPILE([input.o], [-c input.c])
+AT_COMPILE([input])
+AT_PARSER_CHECK([./input], 1, [],
+[syntax error, unexpected "\\'?\"\a\b\f\n\r\t\v\001\377\001\377", expecting "a"
+])
AT_CLEANUP
- Re: i18n for yacc backend messages, (continued)
- Re: i18n for yacc backend messages, Paul Eggert, 2005/04/16
- Re: i18n for yacc backend messages, Jan Nieuwenhuizen, 2005/04/16
- Re: i18n for yacc backend messages, Hans Aberg, 2005/04/16
- Re: i18n for yacc backend messages, Akim Demaille, 2005/04/18
- Re: i18n for yacc backend messages, Hans Aberg, 2005/04/18
- Re: i18n for yacc backend messages, Akim Demaille, 2005/04/18
- Re: i18n for yacc backend messages, Hans Aberg, 2005/04/18
- Re: i18n for yacc backend messages, Jan Nieuwenhuizen, 2005/04/14
- Re: i18n for yacc backend messages, Hans Aberg, 2005/04/14
- Re: i18n for yacc backend messages, Jan Nieuwenhuizen, 2005/04/14
- Re: i18n for yacc backend messages,
Paul Eggert <=
- Re: i18n for yacc backend messages, Jan Nieuwenhuizen, 2005/04/16
- Re: i18n for yacc backend messages, Paul Eggert, 2005/04/16
- Re: i18n for yacc backend messages, Jan Nieuwenhuizen, 2005/04/16
- Re: i18n for yacc backend messages, Hans Aberg, 2005/04/16
- Re: i18n for yacc backend messages, Paul Eggert, 2005/04/17
- Re: i18n for yacc backend messages, Hans Aberg, 2005/04/17
- Re: i18n for yacc backend messages, Jan Nieuwenhuizen, 2005/04/18
- Re: i18n for yacc backend messages, Akim Demaille, 2005/04/14
Re: i18n for yacc backend messages, Akim Demaille, 2005/04/14