mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* NEWS: Bison-generated C parsers now use the _ macro to
translate strings. * data/yacc.c (_) [!defined _]: New macro. All English strings wrapped inside this macro. * doc/bison.texinfo (Bison Parser): Document _. * po/POTFILES.in: Include src/parse-gram.c, since it now includes translateable strings that parse-gram.y doesn't.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
|||||||
|
2005-04-13 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
* NEWS: Bison-generated C parsers now use the _ macro to
|
||||||
|
translate strings.
|
||||||
|
* data/yacc.c (_) [!defined _]: New macro.
|
||||||
|
All English strings wrapped inside this macro.
|
||||||
|
* doc/bison.texinfo (Bison Parser): Document _.
|
||||||
|
* po/POTFILES.in: Include src/parse-gram.c, since it now
|
||||||
|
includes translateable strings that parse-gram.y doesn't.
|
||||||
|
|
||||||
2005-04-12 Paul Eggert <eggert@cs.ucla.edu>
|
2005-04-12 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
* src/symtab.c (symbol_make_alias): Call symbol_type_set,
|
* src/symtab.c (symbol_make_alias): Call symbol_type_set,
|
||||||
|
|||||||
8
NEWS
8
NEWS
@@ -1,6 +1,12 @@
|
|||||||
Bison News
|
Bison News
|
||||||
----------
|
----------
|
||||||
|
|
||||||
|
Changes in version 2.0a, ????-??-??:
|
||||||
|
|
||||||
|
* Bison-generated C parsers use the _ macro to translate strings from
|
||||||
|
English to the user's language, e.g., _("syntax error"). By default,
|
||||||
|
_ is defined to be a no-op macro so the strings are not translated.
|
||||||
|
|
||||||
Changes in version 2.0, 2004-12-25:
|
Changes in version 2.0, 2004-12-25:
|
||||||
|
|
||||||
* Possibly-incompatible changes
|
* Possibly-incompatible changes
|
||||||
@@ -593,7 +599,7 @@ End:
|
|||||||
|
|
||||||
-----
|
-----
|
||||||
|
|
||||||
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
|
Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is part of Bison, the GNU Compiler Compiler.
|
This file is part of Bison, the GNU Compiler Compiler.
|
||||||
|
|||||||
53
data/yacc.c
53
data/yacc.c
@@ -375,6 +375,11 @@ static const char *const yytname[] =
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* INFRINGES ON USER NAME SPACE */
|
||||||
|
#ifndef _
|
||||||
|
# define _(msgid) msgid
|
||||||
|
#endif
|
||||||
|
|
||||||
# ifdef YYPRINT
|
# ifdef YYPRINT
|
||||||
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
|
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
|
||||||
token YYLEX-NUM. */
|
token YYLEX-NUM. */
|
||||||
@@ -492,7 +497,7 @@ do \
|
|||||||
} \
|
} \
|
||||||
else \
|
else \
|
||||||
{ \
|
{ \
|
||||||
yyerror (]b4_yyerror_args["syntax error: cannot back up");\
|
yyerror (]b4_yyerror_args[_("syntax error: cannot back up")); \
|
||||||
YYERROR; \
|
YYERROR; \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
@@ -586,7 +591,7 @@ do { \
|
|||||||
[[short int *bottom], [bottom]],
|
[[short int *bottom], [bottom]],
|
||||||
[[short int *top], [top]])[
|
[[short int *top], [top]])[
|
||||||
{
|
{
|
||||||
YYFPRINTF (stderr, "Stack now");
|
YYFPRINTF (stderr, _("Stack now"));
|
||||||
for (/* Nothing. */; bottom <= top; ++bottom)
|
for (/* Nothing. */; bottom <= top; ++bottom)
|
||||||
YYFPRINTF (stderr, " %d", *bottom);
|
YYFPRINTF (stderr, " %d", *bottom);
|
||||||
YYFPRINTF (stderr, "\n");
|
YYFPRINTF (stderr, "\n");
|
||||||
@@ -608,7 +613,7 @@ do { \
|
|||||||
{
|
{
|
||||||
int yyi;
|
int yyi;
|
||||||
unsigned int yylno = yyrline[yyrule];
|
unsigned int yylno = yyrline[yyrule];
|
||||||
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
|
YYFPRINTF (stderr, _("Reducing stack by rule %d (line %u), "),
|
||||||
yyrule - 1, yylno);
|
yyrule - 1, yylno);
|
||||||
/* Print the symbols being reduced, and their result. */
|
/* Print the symbols being reduced, and their result. */
|
||||||
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
|
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
|
||||||
@@ -877,7 +882,7 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
|||||||
data in use in that stack, in bytes. This used to be a
|
data in use in that stack, in bytes. This used to be a
|
||||||
conditional around just the two extra args, but that might
|
conditional around just the two extra args, but that might
|
||||||
be undefined if yyoverflow is a macro. */
|
be undefined if yyoverflow is a macro. */
|
||||||
yyoverflow ("parser stack overflow",
|
yyoverflow (_("parser stack overflow"),
|
||||||
&yyss1, yysize * sizeof (*yyssp),
|
&yyss1, yysize * sizeof (*yyssp),
|
||||||
&yyvs1, yysize * sizeof (*yyvsp),
|
&yyvs1, yysize * sizeof (*yyvsp),
|
||||||
]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[
|
]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[
|
||||||
@@ -917,14 +922,14 @@ b4_syncline([@oline@], [@ofile@])])dnl
|
|||||||
yyvsp = yyvs + yysize - 1;
|
yyvsp = yyvs + yysize - 1;
|
||||||
]b4_location_if([ yylsp = yyls + yysize - 1;])[
|
]b4_location_if([ yylsp = yyls + yysize - 1;])[
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
YYDPRINTF ((stderr, _("Stack size increased to %lu\n"),
|
||||||
(unsigned long int) yystacksize));
|
(unsigned long int) yystacksize));
|
||||||
|
|
||||||
if (yyss + yystacksize - 1 <= yyssp)
|
if (yyss + yystacksize - 1 <= yyssp)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
YYDPRINTF ((stderr, _("Entering state %d\n"), yystate));
|
||||||
|
|
||||||
goto yybackup;
|
goto yybackup;
|
||||||
|
|
||||||
@@ -948,19 +953,19 @@ yybackup:
|
|||||||
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
|
/* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */
|
||||||
if (yychar == YYEMPTY)
|
if (yychar == YYEMPTY)
|
||||||
{
|
{
|
||||||
YYDPRINTF ((stderr, "Reading a token: "));
|
YYDPRINTF ((stderr, _("Reading a token: ")));
|
||||||
yychar = YYLEX;
|
yychar = YYLEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yychar <= YYEOF)
|
if (yychar <= YYEOF)
|
||||||
{
|
{
|
||||||
yychar = yytoken = YYEOF;
|
yychar = yytoken = YYEOF;
|
||||||
YYDPRINTF ((stderr, "Now at end of input.\n"));
|
YYDPRINTF ((stderr, _("Now at end of input.\n")));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yytoken = YYTRANSLATE (yychar);
|
yytoken = YYTRANSLATE (yychar);
|
||||||
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
YY_SYMBOL_PRINT (_("Next token is"), yytoken, &yylval, &yylloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||||
@@ -981,7 +986,7 @@ yybackup:
|
|||||||
YYACCEPT;
|
YYACCEPT;
|
||||||
|
|
||||||
/* Shift the look-ahead token. */
|
/* Shift the look-ahead token. */
|
||||||
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
|
YY_SYMBOL_PRINT (_("Shifting"), yytoken, &yylval, &yylloc);
|
||||||
|
|
||||||
/* Discard the token being shifted unless it is eof. */
|
/* Discard the token being shifted unless it is eof. */
|
||||||
if (yychar != YYEOF)
|
if (yychar != YYEOF)
|
||||||
@@ -1091,7 +1096,7 @@ yyerrlab:
|
|||||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||||
int yycount = 0;
|
int yycount = 0;
|
||||||
|
|
||||||
yyprefix = ", expecting ";
|
yyprefix = _(", expecting ");
|
||||||
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
||||||
{
|
{
|
||||||
@@ -1103,34 +1108,34 @@ yyerrlab:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yysize += (sizeof ("syntax error, unexpected ")
|
yysize += (strlen (_("syntax error, unexpected "))
|
||||||
+ yystrlen (yytname[yytype]));
|
+ yystrlen (yytname[yytype]) + 1);
|
||||||
yymsg = (char *) YYSTACK_ALLOC (yysize);
|
yymsg = (char *) YYSTACK_ALLOC (yysize);
|
||||||
if (yymsg != 0)
|
if (yymsg != 0)
|
||||||
{
|
{
|
||||||
char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
|
char *yyp = yystpcpy (yymsg, _("syntax error, unexpected "));
|
||||||
yyp = yystpcpy (yyp, yytname[yytype]);
|
yyp = yystpcpy (yyp, yytname[yytype]);
|
||||||
|
|
||||||
if (yycount < 5)
|
if (yycount < 5)
|
||||||
{
|
{
|
||||||
yyprefix = ", expecting ";
|
yyprefix = _(", expecting ");
|
||||||
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||||
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
|
||||||
{
|
{
|
||||||
yyp = yystpcpy (yyp, yyprefix);
|
yyp = yystpcpy (yyp, yyprefix);
|
||||||
yyp = yystpcpy (yyp, yytname[yyx]);
|
yyp = yystpcpy (yyp, yytname[yyx]);
|
||||||
yyprefix = " or ";
|
yyprefix = _(" or ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
yyerror (]b4_yyerror_args[yymsg);
|
yyerror (]b4_yyerror_args[yymsg);
|
||||||
YYSTACK_FREE (yymsg);
|
YYSTACK_FREE (yymsg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
yyerror (]b4_yyerror_args["syntax error; also virtual memory exhausted");
|
yyerror (]b4_yyerror_args[_("syntax error; also virtual memory exhausted"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif /* YYERROR_VERBOSE */
|
#endif /* YYERROR_VERBOSE */
|
||||||
yyerror (]b4_yyerror_args["syntax error");
|
yyerror (]b4_yyerror_args[_("syntax error"));
|
||||||
}
|
}
|
||||||
|
|
||||||
]b4_location_if([[ yyerror_range[0] = yylloc;]])[
|
]b4_location_if([[ yyerror_range[0] = yylloc;]])[
|
||||||
@@ -1151,13 +1156,13 @@ yyerrlab:
|
|||||||
YYPOPSTACK;
|
YYPOPSTACK;
|
||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
yydestruct ("Error: popping",
|
yydestruct (_("Error: popping"),
|
||||||
yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
yydestruct ("Error: discarding", yytoken, &yylval]b4_location_if([, &yylloc])[);
|
yydestruct (_("Error: discarding"), yytoken, &yylval]b4_location_if([, &yylloc])[);
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1211,7 +1216,7 @@ yyerrlab1:
|
|||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
]b4_location_if([[ yyerror_range[0] = *yylsp;]])[
|
]b4_location_if([[ yyerror_range[0] = *yylsp;]])[
|
||||||
yydestruct ("Error: popping", yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
|
yydestruct (_("Error: popping"), yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
|
||||||
YYPOPSTACK;
|
YYPOPSTACK;
|
||||||
yystate = *yyssp;
|
yystate = *yyssp;
|
||||||
YY_STACK_PRINT (yyss, yyssp);
|
YY_STACK_PRINT (yyss, yyssp);
|
||||||
@@ -1229,7 +1234,7 @@ yyerrlab1:
|
|||||||
*++yylsp = yyloc;]])[
|
*++yylsp = yyloc;]])[
|
||||||
|
|
||||||
/* Shift the error token. */
|
/* Shift the error token. */
|
||||||
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
|
YY_SYMBOL_PRINT (_("Shifting"), yystos[yyn], yyvsp, yylsp);
|
||||||
|
|
||||||
yystate = yyn;
|
yystate = yyn;
|
||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
@@ -1246,7 +1251,7 @@ yyacceptlab:
|
|||||||
| yyabortlab -- YYABORT comes here. |
|
| yyabortlab -- YYABORT comes here. |
|
||||||
`-----------------------------------*/
|
`-----------------------------------*/
|
||||||
yyabortlab:
|
yyabortlab:
|
||||||
yydestruct ("Error: discarding lookahead",
|
yydestruct (_("Error: discarding lookahead"),
|
||||||
yytoken, &yylval]b4_location_if([, &yylloc])[);
|
yytoken, &yylval]b4_location_if([, &yylloc])[);
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
yyresult = 1;
|
yyresult = 1;
|
||||||
@@ -1257,7 +1262,7 @@ yyabortlab:
|
|||||||
| yyoverflowlab -- parser overflow comes here. |
|
| yyoverflowlab -- parser overflow comes here. |
|
||||||
`----------------------------------------------*/
|
`----------------------------------------------*/
|
||||||
yyoverflowlab:
|
yyoverflowlab:
|
||||||
yyerror (]b4_yyerror_args["parser stack overflow");
|
yyerror (]b4_yyerror_args[_("parser stack overflow"));
|
||||||
yyresult = 2;
|
yyresult = 2;
|
||||||
/* Fall through. */
|
/* Fall through. */
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1166,7 +1166,14 @@ start with a function called @code{main}; you have to provide this, and
|
|||||||
arrange for it to call @code{yyparse} or the parser will never run.
|
arrange for it to call @code{yyparse} or the parser will never run.
|
||||||
@xref{Interface, ,Parser C-Language Interface}.
|
@xref{Interface, ,Parser C-Language Interface}.
|
||||||
|
|
||||||
Aside from the token type names and the symbols in the actions you
|
If your code defines a C preprocessor macro @code{_} (a single
|
||||||
|
underscore), Bison assumes that it can be used to translate
|
||||||
|
English-language strings to the user's preferred language using a
|
||||||
|
function-like syntax, e.g., @code{_("syntax error")}. Otherwise,
|
||||||
|
Bison defines a no-op macro by that name that merely returns its
|
||||||
|
argument, so strings are not translated.
|
||||||
|
|
||||||
|
Aside from @code{_} and the token type names and the symbols in the actions you
|
||||||
write, all symbols defined in the Bison parser file itself
|
write, all symbols defined in the Bison parser file itself
|
||||||
begin with @samp{yy} or @samp{YY}. This includes interface functions
|
begin with @samp{yy} or @samp{YY}. This includes interface functions
|
||||||
such as the lexical analyzer function @code{yylex}, the error reporting
|
such as the lexical analyzer function @code{yylex}, the error reporting
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ src/files.c
|
|||||||
src/getargs.c
|
src/getargs.c
|
||||||
src/gram.c
|
src/gram.c
|
||||||
src/main.c
|
src/main.c
|
||||||
|
src/parse-gram.c
|
||||||
src/parse-gram.y
|
src/parse-gram.y
|
||||||
src/print.c
|
src/print.c
|
||||||
src/reader.c
|
src/reader.c
|
||||||
|
|||||||
Reference in New Issue
Block a user