@q Copyright 2012-2020, Alexander Shibakov@>
@q This file is part of SPLinT@>
@q SPLinT is free software: you can redistribute it and/or modify@>
@q it under the terms of the GNU General Public License as published by@>
@q the Free Software Foundation, either version 3 of the License, or@>
@q (at your option) any later version.@>
@q SPLinT is distributed in the hope that it will be useful,@>
@q but WITHOUT ANY WARRANTY; without even the implied warranty of@>
@q MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the@>
@q GNU General Public License for more details.@>
@q You should have received a copy of the GNU General Public License@>
@q along with SPLinT. If not, see .@>
@*1\eatone{Bison}\bison\ specific routines.
The placeholder code left blank in the common routines is filed in
with the code relevant to the output of parser tables in the following sections.
@*2Tables. \namedspot{bsfile}Here are all the parser table names. Some tables are not output but adding
one to the list in the future will be easy: it does not even have to
be done here.
@=
_register_table_d(yytranslate)@;
_register_table_d(yyr1)@;
_register_table_d(yyr2)@;
_register_table_d(yydefact)@;
_register_table_d(yydefgoto)@;
_register_table_d(yypact)@;
_register_table_d(yypgoto)@;
_register_table_d(yytable)@;
_register_table_d(yycheck)@;
_register_table_d(yytoknum)@;
_register_table_d(yystos)@;
_register_table_d(yytname)@;
_register_table_d(yyprhs)@;
_register_table_d(yyrhs)@;
@ One special table requires a little bit more preparation. This is a
table that lists the depth of the stack before an implicit terminal. It
is not one of the tables that is used by \bison\ itself but is needed
if the symbolic name processing is to be implemented (\bison\ has
access to this information `on the fly'). The `new' \bison\ (starting
with version~\.{3.0}) does not generate |yyprhs| and |yyrhs| or any
other arrays that contain similar information, so we fake them here if
such a crippled version of \bison\ is used.
@=
unsigned int yyrthree[YYNRULES + 1] = { 0 };
#ifdef BISON_IS_CRIPPLED
unsigned int yyrhs[YYNRULES + 1] = { -1 };
unsigned int yyprhs[YYNRULES + 1] = { 0 };
#endif
@ We populate this table below $\ldots$
@=
#ifndef BISON_IS_CRIPPLED
assert( YYNRULES + 1 == sizeof(yyprhs)/sizeof(yyprhs[0]) );
{ int i, j;
for ( i = 1; i <= YYNRULES; i++ ) {
for ( j = 0; yyrhs[ yyprhs[i] + j ] != -1; j++ ) {
assert( yyprhs[i] + j < sizeof(yyrhs) );
assert( j < yyr1[i] );
if ( @ ) {
@@;
}
}
}
}
#endif
@ @=
( strlen( yytname[ yyrhs[yyprhs[i]+j] ] ) > 1 ) &&
( yytname[ yyrhs[yyprhs[i]+j] ][0] == '$' ) &&
( yytname[ yyrhs[yyprhs[i]+j] ][1] == '@@' )
@ @=
int rule_number;
for ( rule_number = 1; rule_number < YYNRULES; rule_number++ ) {
if ( yyr1[rule_number] == yyrhs[yyprhs[i]+j] ) {
yyrthree[rule_number] = j;
break;
}
}
assert( rule_number < YYNRULES );
@ $\ldots$ and add its name to the list.
@=
_register_table_d(yyrthree)@;
@*2Actions. There are several ways of making |yyparse()| execute all portions of
the action code. The one chosen here makes sure that none of the
tables gets written past its last element. To see how it works, it
might be helpful to `walk through' \bison's output to see how each
change affects the generated parser.
@