* src/gram.h (TIEM_NUMBER_MAX): New.

(item_number_of_rule_number, rule_number_of_item_number): Rename
as...
(rule_number_as_item_number, item_number_as_rule_number): these.
Adjust dependencies.
* src/output.c (vector_number_t, VECTOR_NUMBER_MAX)
(VECTOR_NUMBER_MIN, state_number_to_vector_number)
(symbol_number_to_vector_number): New.
(order): Of vector_number_t* type.
(base_t, BASE_MAX, BASE_MIN): New.
(froms, tos, width, pos, check): Of base_t type.
(action_number_t, ACTION_MIN, ACTION_MAX): New.
(actrow): Of action_number_t type.
(conflrow): Of unsigned int type.
(table_ninf, base_ninf): New.
(GENERATE_MUSCLE_INSERT_TABLE): Also output the `*_min' value.
(muscle_insert_int_table, muscle_insert_base_table)
(muscle_insert_rule_number_table): New.
(prepare_tokens): Output `toknum' as int_table.
(action_row): Returns a rule_number_t.
Use ACTION_MIN, not SHRT_MIN.
(token_actions): yydefact is rule_number_t*.
(table_ninf_remap): New.
(pack_table): Use it for `base' and `table'.
* data/yacc.c, data/glr.c, data/lalr1.cc (YYFLAG): Remove,
replaced with...
(YYPACT_NINF, YYTABLE_NINF): these.
(yypact, yytable): Compute their types instead of hard-coded
`short'.
* tests/regression.at (Web2c Actions): Adjust.
This commit is contained in:
Akim Demaille
2002-07-25 17:30:44 +00:00
parent 5dde258a9e
commit 12b0043a6d
10 changed files with 327 additions and 139 deletions

View File

@@ -310,7 +310,7 @@ static const short yydefact[] =
]b4_defact[
};
/* YYPGOTO[NTERM-NUM]. */
/* YYPDEFGOTO[NTERM-NUM]. */
static const short yydefgoto[] =
{
]b4_defgoto[
@@ -318,7 +318,8 @@ static const short yydefgoto[] =
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const short yypact[] =
#define YYPACT_NINF ]b4_pact_ninf[
static const ]b4_sint_type(b4_pact_max)[ yypact[] =
{
]b4_pact[
};
@@ -332,7 +333,8 @@ static const short yypgoto[] =
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says. */
static const short yytable[] =
#define YYTABLE_NINF ]b4_table_ninf[
static const ]b4_sint_type(b4_table_max)[ yytable[] =
{
]b4_table[
};
@@ -389,10 +391,10 @@ int yyparse (void);
#define YYRHSLOC(yyRhs,YYK) (yyRhs[YYK].yystate.yyloc)
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) \
yyCurrent.yyfirst_line = YYRHSLOC(yyRhs,1).yyfirst_line; \
yyCurrent.yyfirst_column = YYRHSLOC(yyRhs,1).yyfirst_column; \
yyCurrent.yylast_line = YYRHSLOC(yyRhs,YYN).yylast_line; \
# define YYLLOC_DEFAULT(yyCurrent, yyRhs, YYN) \
yyCurrent.yyfirst_line = YYRHSLOC(yyRhs,1).yyfirst_line; \
yyCurrent.yyfirst_column = YYRHSLOC(yyRhs,1).yyfirst_column; \
yyCurrent.yylast_line = YYRHSLOC(yyRhs,YYN).yylast_line; \
yyCurrent.yylast_column = YYRHSLOC(yyRhs,YYN).yylast_column;
#endif
@@ -676,7 +678,7 @@ yylhsNonterm (yyRuleNum yyrule)
static inline bool
yyisDefaultedState (yyStateNum yystate)
{
return yypact[yystate] == YYFLAG;
return yypact[yystate] == YYPACT_NINF;
}
/** The default reduction for STATE, assuming it has one. */
@@ -731,7 +733,7 @@ yyisShiftAction (int yyaction)
static inline bool
yyisErrorAction (int yyaction)
{
return yyaction == 0 || yyaction == YYFLAG;
return yyaction == 0 || yyaction == YYPACT_NINF;
}
/* GLRStates */
@@ -1497,7 +1499,7 @@ yyreportParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
char* yyp;
char* yymsg;
yyn = yypact[yystack->yytops.yystates[0]->yylrState];
if (yyn > YYFLAG && yyn < YYLAST)
if (YYPACT_NINF < yyn && yyn < YYLAST)
{
yycount = 0;
/* Start YYX at -YYN if negative to avoid negative indexes in
@@ -1563,7 +1565,7 @@ yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
*yytokenp = YYTRANSLATE (yychar);
YYDPRINTF ((stderr, "Read token %s\n", yytokenName (*yytokenp)));
yyj = yypact[yystack->yytops.yystates[0]->yylrState];
if (yyj == YYFLAG)
if (yyj == YYPACT_NINF)
/* Something's not right; we shouldn't be here */
yyFail (yystack, NULL);
yyj += *yytokenp;
@@ -1572,7 +1574,7 @@ yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
if (yydefact[yystack->yytops.yystates[0]->yylrState] != 0)
return;
}
else if (yytable[yyj] != 0 && yytable[yyj] != YYFLAG)
else if (yytable[yyj] != 0 && yytable[yyj] != YYTABLE_NINF)
return;
} while (yytrue);
}
@@ -1592,7 +1594,7 @@ yyrecoverParseError (yyGLRStack* yystack, YYSTYPE* yylvalp, YYLTYPE* yyllocp)
while (yystack->yytops.yystates[0] != NULL)
{
yyj = yypact[yystack->yytops.yystates[0]->yylrState] + YYTERROR;
if (yyj != YYFLAG + YYTERROR && yyj >= 0 && yyj <= YYLAST &&
if (yyj != YYPACT_NINF + YYTERROR && yyj >= 0 && yyj <= YYLAST &&
yycheck[yyj] == YYTERROR && yyisShiftAction (yytable[yyj]))
{
yyglrShift (yystack, 0, yytable[yyj],

View File

@@ -223,11 +223,13 @@ namespace yy
LocationStack location_stack_;
/* Tables. */
static const short pact_[[]];
static const b4_sint_type(b4_pact_max) pact_[[]];
static const b4_sint_type(b4_pact_max) pact_ninf_;
static const short defact_[[]];
static const short pgoto_[[]];
static const short defgoto_[[]];
static const short table_[[]];
static const b4_sint_type(b4_table_max) table_[[]];
static const b4_sint_type(b4_table_max) table_ninf_;
static const short check_[[]];
static const b4_uint_type(b4_r1_max) r1_[[]];
static const b4_uint_type(b4_r2_max) r2_[[]];
@@ -251,7 +253,6 @@ namespace yy
/* Constants. */
static const int eof_;
static const int last_;
static const int flag_;
static const int nnts_;
static const int empty_;
static const int final_;
@@ -336,7 +337,7 @@ yy::b4_name::parse ()
/* Try to take a decision without lookahead. */
n_ = pact_[[state_]];
if (n_ == flag_)
if (n_ == pact_ninf_)
goto yydefault;
/* Read a lookahead token. */
@@ -375,7 +376,7 @@ yy::b4_name::parse ()
n_ = table_[[n_]];
if (n_ < 0)
{
if (n_ == flag_)
if (n_ == table_ninf_)
goto yyerrlab;
else
{
@@ -492,7 +493,7 @@ yy::b4_name::parse ()
#if YYERROR_VERBOSE
n_ = pact_[[state_]];
if (n_ > flag_ && n_ < last_)
if (pact_ninf_ < n_ && n_ < last_)
{
message = "parse error, unexpected ";
message += name_[[ilooka_]];
@@ -543,7 +544,7 @@ yy::b4_name::parse ()
for (;;)
{
n_ = pact_[[state_]];
if (n_ != flag_)
if (n_ != pact_ninf_)
{
n_ += terror_;
if (0 <= n_ && n_ <= last_ && check_[[n_]] == terror_)
@@ -628,7 +629,8 @@ yy::b4_name::lex_ ()
/* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
STATE-NUM. */
const short
const b4_sint_type(b4_pact_max) yy::b4_name::pact_ninf_ = b4_pact_ninf;
const b4_sint_type(b4_pact_max)
yy::b4_name::pact_[[]] =
{
b4_pact
@@ -660,7 +662,8 @@ yy::b4_name::defgoto_[[]] =
/* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says. */
const short
const b4_sint_type(b4_table_max) yy::b4_name::table_ninf_ = b4_table_ninf;
const b4_sint_type(b4_table_max)
yy::b4_name::table_[[]] =
{
b4_table
@@ -757,7 +760,6 @@ yy::b4_name::translate_ (int token)
const int yy::b4_name::eof_ = 0;
const int yy::b4_name::last_ = b4_last;
const int yy::b4_name::flag_ = b4_flag;
const int yy::b4_name::nnts_ = b4_nterms_number;
const int yy::b4_name::empty_ = -2;
const int yy::b4_name::final_ = b4_final_state_number;

View File

@@ -2,7 +2,8 @@ m4_divert(-1) -*- C -*-
m4_include([c.m4])
# Yacc compatible skeleton for Bison
# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002
# Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -303,7 +304,6 @@ b4_location_if(
/* YYFINAL -- State number of the termination state. */
#define YYFINAL b4_final_state_number
#define YYFLAG b4_flag
#define YYLAST b4_last
/* YYNTOKENS -- Number of terminals. */
@@ -385,7 +385,7 @@ static const short yydefact[[]] =
b4_defact
};
/* YYPGOTO[[NTERM-NUM]]. */
/* YYDEFGOTO[[NTERM-NUM]]. */
static const short yydefgoto[[]] =
{
b4_defgoto
@@ -393,7 +393,8 @@ static const short yydefgoto[[]] =
/* YYPACT[[STATE-NUM]] -- Index in YYTABLE of the portion describing
STATE-NUM. */
static const short yypact[[]] =
#define YYPACT_NINF b4_pact_ninf
static const b4_sint_type(b4_pact_max) yypact[[]] =
{
b4_pact
};
@@ -407,7 +408,8 @@ static const short yypgoto[[]] =
/* YYTABLE[[YYPACT[STATE-NUM]]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero, do what YYDEFACT says. */
static const short yytable[[]] =
#define YYTABLE_NINF b4_table_ninf
static const b4_sint_type(b4_table_max) yytable[[]] =
{
b4_table
};
@@ -820,7 +822,7 @@ yybackup:
/* First try to decide what to do without reference to lookahead token. */
yyn = yypact[yystate];
if (yyn == YYFLAG)
if (yyn == YYPACT_NINF)
goto yydefault;
/* Not known => get a lookahead token if don't already have one. */
@@ -855,7 +857,7 @@ yybackup:
}
yyn += yychar1;
if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yychar1)
goto yydefault;
yyn = yytable[yyn];
@@ -869,7 +871,7 @@ yybackup:
if (yyn < 0)
{
if (yyn == YYFLAG)
if (yyn == YYTABLE_NINF)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
@@ -980,7 +982,7 @@ yyreduce:
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
@@ -1000,7 +1002,7 @@ yyerrlab:
#if YYERROR_VERBOSE
yyn = yypact[yystate];
if (yyn > YYFLAG && yyn < YYLAST)
if (YYPACT_NINF < yyn && yyn < YYLAST)
{
YYSIZE_T yysize = 0;
char *yymsg;
@@ -1090,7 +1092,7 @@ yyerrlab1:
for (;;)
{
yyn = yypact[yystate];
if (yyn != YYFLAG)
if (yyn != YYPACT_NINF)
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)