Replace yychar with a Boolean.

* data/lalr1.cc (parse::yychar): Replace by...
	(parse::yyempty): this.
This commit is contained in:
Akim Demaille
2008-08-18 22:31:13 +02:00
parent a2e3fa7768
commit 39be90223b
2 changed files with 21 additions and 23 deletions

View File

@@ -1,3 +1,9 @@
2008-11-11 Akim Demaille <demaille@gostai.com>
Replace yychar with a Boolean.
* data/lalr1.cc (parse::yychar): Replace by...
(parse::yyempty): this.
2008-11-11 Akim Demaille <demaille@gostai.com> 2008-11-11 Akim Demaille <demaille@gostai.com>
Factor the tables. Factor the tables.

View File

@@ -815,12 +815,12 @@ b4_percent_code_get[]dnl
#endif /* !YYDEBUG */ #endif /* !YYDEBUG */
#define yyerrok (yyerrstatus_ = 0) #define yyerrok (yyerrstatus_ = 0)
#define yyclearin (yychar = yyempty_) #define yyclearin (yyempty = true)
#define YYACCEPT goto yyacceptlab #define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab #define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab #define YYERROR goto yyerrorlab
#define YYRECOVERING() (!!yyerrstatus_) #define YYRECOVERING() (!!yyerrstatus_)
]b4_namespace_open[ ]b4_namespace_open[
@@ -1080,8 +1080,8 @@ b4_percent_code_get[]dnl
int int
]b4_parser_class_name[::parse () ]b4_parser_class_name[::parse ()
{ {
/// Coded type of the lookahead. /// Whether yyla contains a lookahead.
int yychar = yyempty_; bool yyempty = true;
/* State. */ /* State. */
int yyn; int yyn;
@@ -1142,18 +1142,14 @@ m4_popdef([b4_at_dollar])])dnl
goto yydefault; goto yydefault;
/* Read a lookahead token. */ /* Read a lookahead token. */
if (yychar == yyempty_) if (yyempty)
{ {
YYCDEBUG << "Reading a token: "; YYCDEBUG << "Reading a token: ";
yychar = ]b4_c_function_call([yylex], [int], yyla.type = yytranslate_ (]b4_c_function_call([yylex], [int],
[[YYSTYPE*], [&yyla.value]][]dnl [[YYSTYPE*], [&yyla.value]][]dnl
b4_locations_if([, [[location*], [&yyla.location]]])dnl b4_locations_if([, [[location*], [&yyla.location]]])dnl
m4_ifdef([b4_lex_param], [, ]b4_lex_param))[; m4_ifdef([b4_lex_param], [, ]b4_lex_param))[);
// Convert token to internal form. yyempty = false;
yyla.type = yytranslate_ (yychar);
// Beware that yylex may return -2 to mean EOF, but which
// turns out to the be value of YYEMPTY.
yychar = !yyempty_;
} }
YY_SYMBOL_PRINT ("Next token is", yyla); YY_SYMBOL_PRINT ("Next token is", yyla);
@@ -1175,7 +1171,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
} }
/* Discard the token being shifted. */ /* Discard the token being shifted. */
yychar = yyempty_; yyempty = true;
/* Count tokens shifted since error; after three, turn off error /* Count tokens shifted since error; after three, turn off error
status. */ status. */
@@ -1282,13 +1278,9 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
if (yyla.type == yyeof_) if (yyla.type == yyeof_)
YYABORT; YYABORT;
else else
{]b4_assert_if([ {
// Previous version of this code was ready to handle
// yychar == yyempty_ (actually yychar <= yyeof_). Can it
// really be triggered?
assert (yychar != yyempty_);])[
yy_destroy_ ("Error: discarding", yyla); yy_destroy_ ("Error: discarding", yyla);
yychar = yyempty_; yyempty = true;
} }
} }
@@ -1368,7 +1360,7 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[;
goto yyreturn; goto yyreturn;
yyreturn: yyreturn:
if (yychar != yyempty_) if (!yyempty)
yy_destroy_ ("Cleanup: discarding lookahead", yyla); yy_destroy_ ("Cleanup: discarding lookahead", yyla);
/* Do not reclaim the symbols of the rule which action triggered /* Do not reclaim the symbols of the rule which action triggered