mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 00:33:03 +00:00
user_toknums' is output as a short[]' in `output.c', while it is
defined as a `int[]' in `reader.c'. For consistency with the other output tables, `user_toknums' is now defined as a table of shorts. * src/reader.c (user_toknums): Be a short table instead of an int table. Adjust dependencies. Factor the short table outputs. * src/output.c (output_short_table): New function. * src/output.c (output_gram, output_stos, output_rule_data) (output_base, output_table, output_check): Use it.
This commit is contained in:
17
ChangeLog
17
ChangeLog
@@ -1,3 +1,20 @@
|
|||||||
|
2000-10-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
`user_toknums' is output as a `short[]' in `output.c', while it is
|
||||||
|
defined as a `int[]' in `reader.c'. For consistency with the
|
||||||
|
other output tables, `user_toknums' is now defined as a table of
|
||||||
|
shorts.
|
||||||
|
|
||||||
|
* src/reader.c (user_toknums): Be a short table instead of an int
|
||||||
|
table.
|
||||||
|
Adjust dependencies.
|
||||||
|
|
||||||
|
Factor the short table outputs.
|
||||||
|
|
||||||
|
* src/output.c (output_short_table): New function.
|
||||||
|
* src/output.c (output_gram, output_stos, output_rule_data)
|
||||||
|
(output_base, output_table, output_check): Use it.
|
||||||
|
|
||||||
2000-10-02 Akim Demaille <akim@epita.fr>
|
2000-10-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* src/output.c (output): Topological sort of the functions, in
|
* src/output.c (output): Topological sort of the functions, in
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ static int failure;
|
|||||||
/* The name this program was run with, for messages. */
|
/* The name this program was run with, for messages. */
|
||||||
char *program_name;
|
char *program_name;
|
||||||
|
|
||||||
|
extern void berror PARAMS((const char *));
|
||||||
|
|
||||||
extern char *printable_version PARAMS ((int));
|
extern char *printable_version PARAMS ((int));
|
||||||
|
|
||||||
extern void openfiles PARAMS ((void));
|
extern void openfiles PARAMS ((void));
|
||||||
|
|||||||
270
src/output.c
270
src/output.c
@@ -99,8 +99,10 @@
|
|||||||
#include "complain.h"
|
#include "complain.h"
|
||||||
#include "output.h"
|
#include "output.h"
|
||||||
|
|
||||||
|
extern void berror PARAMS((const char *));
|
||||||
|
|
||||||
extern char **tags;
|
extern char **tags;
|
||||||
extern int *user_toknums;
|
extern short *user_toknums;
|
||||||
extern int tokensetsize;
|
extern int tokensetsize;
|
||||||
extern int final_state;
|
extern int final_state;
|
||||||
extern core **state_table;
|
extern core **state_table;
|
||||||
@@ -136,6 +138,44 @@ static int high;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
output_short_table (FILE *out,
|
||||||
|
const char *table_name,
|
||||||
|
short *short_table,
|
||||||
|
short first_value,
|
||||||
|
short begin, short end)
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
fprintf (out, "static const short %s[] = {%6d", table_name, first_value);
|
||||||
|
|
||||||
|
j = 10;
|
||||||
|
for (i = begin; i < end; i++)
|
||||||
|
{
|
||||||
|
putc (',', out);
|
||||||
|
|
||||||
|
if (j >= 10)
|
||||||
|
{
|
||||||
|
putc ('\n', out);
|
||||||
|
j = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (out, "%6d", short_table[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf (out, "\n};\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*--------------------------------------------------------------.
|
||||||
|
| output_headers -- Output constant strings to the beginning of |
|
||||||
|
| certain files. |
|
||||||
|
`--------------------------------------------------------------*/
|
||||||
|
|
||||||
#define GUARDSTR \
|
#define GUARDSTR \
|
||||||
"\n\
|
"\n\
|
||||||
#include \"%s\"\n\
|
#include \"%s\"\n\
|
||||||
@@ -171,11 +211,6 @@ register YYLTYPE *yylsp;\n\
|
|||||||
|
|
||||||
#define ACTSTR_SIMPLE "\n switch (yyn) {\n"
|
#define ACTSTR_SIMPLE "\n switch (yyn) {\n"
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------.
|
|
||||||
| Output constant strings to the beginning of certain files. |
|
|
||||||
`------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void
|
void
|
||||||
output_headers (void)
|
output_headers (void)
|
||||||
{
|
{
|
||||||
@@ -274,7 +309,6 @@ output_token_translations (void)
|
|||||||
static void
|
static void
|
||||||
output_gram (void)
|
output_gram (void)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int j;
|
int j;
|
||||||
short *sp;
|
short *sp;
|
||||||
|
|
||||||
@@ -282,29 +316,10 @@ output_gram (void)
|
|||||||
yyprhs and yyrhs are needed only for yydebug. */
|
yyprhs and yyrhs are needed only for yydebug. */
|
||||||
/* With the noparser option, all tables are generated */
|
/* With the noparser option, all tables are generated */
|
||||||
if (!semantic_parser && !noparserflag)
|
if (!semantic_parser && !noparserflag)
|
||||||
fprintf (ftable, "\n#if YYDEBUG != 0");
|
fprintf (ftable, "\n#if YYDEBUG != 0\n");
|
||||||
|
|
||||||
fprintf (ftable, "\nstatic const short yyprhs[] = { 0");
|
output_short_table (ftable, "yyprhs", rrhs,
|
||||||
|
0, 1, nrules + 1);
|
||||||
j = 10;
|
|
||||||
for (i = 1; i <= nrules; i++)
|
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
|
|
||||||
if (j >= 10)
|
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "%6d", rrhs[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "\n};\n");
|
|
||||||
|
|
||||||
fprintf (ftable, "\nstatic const short yyrhs[] = {%6d", ritem[0]);
|
fprintf (ftable, "\nstatic const short yyrhs[] = {%6d", ritem[0]);
|
||||||
|
|
||||||
@@ -339,30 +354,8 @@ output_gram (void)
|
|||||||
static void
|
static void
|
||||||
output_stos (void)
|
output_stos (void)
|
||||||
{
|
{
|
||||||
int i;
|
output_short_table (ftable, "yystos", accessing_symbol,
|
||||||
int j;
|
0, 1, nstates);
|
||||||
|
|
||||||
fprintf (ftable, "\nstatic const short yystos[] = { 0");
|
|
||||||
|
|
||||||
j = 10;
|
|
||||||
for (i = 1; i < nstates; i++)
|
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
|
|
||||||
if (j >= 10)
|
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "%6d", accessing_symbol[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "\n};\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -374,27 +367,13 @@ output_rule_data (void)
|
|||||||
|
|
||||||
fputs ("\n\
|
fputs ("\n\
|
||||||
#if YYDEBUG != 0\n\
|
#if YYDEBUG != 0\n\
|
||||||
/* YYRLINE[yyn]: source line where rule number YYN was defined. */\n\
|
/* YYRLINE[yyn]: source line where rule number YYN was defined. */\n",
|
||||||
static const short yyrline[] = { 0", ftable);
|
ftable);
|
||||||
|
|
||||||
j = 10;
|
output_short_table (ftable, "yyrline", rline,
|
||||||
for (i = 1; i <= nrules; i++)
|
0, 1, nrules + 1);
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
|
|
||||||
if (j >= 10)
|
fputs ("#endif\n\n", ftable);
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "%6d", rline[i]);
|
|
||||||
}
|
|
||||||
fprintf (ftable, "\n};\n#endif\n\n");
|
|
||||||
|
|
||||||
if (toknumflag || noparserflag)
|
if (toknumflag || noparserflag)
|
||||||
{
|
{
|
||||||
@@ -477,49 +456,19 @@ static const short yyrline[] = { 0", ftable);
|
|||||||
/* Output YYTOKNUM. */
|
/* Output YYTOKNUM. */
|
||||||
if (toknumflag)
|
if (toknumflag)
|
||||||
{
|
{
|
||||||
fprintf (ftable, "static const short yytoknum[] = { 0");
|
output_short_table (ftable, "yytoknum", user_toknums,
|
||||||
j = 10;
|
0, 1, ntokens + 1);
|
||||||
for (i = 1; i <= ntokens; i++)
|
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
if (j >= 10)
|
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
j++;
|
|
||||||
fprintf (ftable, "%6d", user_toknums[i]);
|
|
||||||
}
|
|
||||||
fprintf (ftable, "\n};\n\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Output YYR1. */
|
/* Output YYR1. */
|
||||||
fputs ("\
|
fputs ("\
|
||||||
/* YYR1[YYN]: Symbol number of symbol that rule YYN derives. */\n\
|
/* YYR1[YYN]: Symbol number of symbol that rule YYN derives. */\n", ftable);
|
||||||
static const short yyr1[] = { 0", ftable);
|
|
||||||
|
|
||||||
j = 10;
|
output_short_table (ftable, "yyr1", rlhs,
|
||||||
for (i = 1; i <= nrules; i++)
|
0, 1, nrules + 1);
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
|
|
||||||
if (j >= 10)
|
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "%6d", rlhs[i]);
|
|
||||||
}
|
|
||||||
FREE (rlhs + 1);
|
FREE (rlhs + 1);
|
||||||
fputs ("\n\
|
|
||||||
};\n\
|
putc ('\n', ftable);
|
||||||
\n", ftable);
|
|
||||||
|
|
||||||
/* Output YYR2. */
|
/* Output YYR2. */
|
||||||
fputs ("\
|
fputs ("\
|
||||||
@@ -1179,51 +1128,14 @@ pack_table (void)
|
|||||||
static void
|
static void
|
||||||
output_base (void)
|
output_base (void)
|
||||||
{
|
{
|
||||||
int i;
|
output_short_table (ftable, "yypact", base,
|
||||||
int j;
|
base[0], 1, nstates);
|
||||||
|
|
||||||
fprintf (ftable, "\nstatic const short yypact[] = {%6d", base[0]);
|
putc ('\n', ftable);
|
||||||
|
|
||||||
j = 10;
|
output_short_table (ftable, "yypgoto", base,
|
||||||
for (i = 1; i < nstates; i++)
|
base[nstates], nstates + 1, nvectors);
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
|
|
||||||
if (j >= 10)
|
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "%6d", base[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "\n};\n\nstatic const short yypgoto[] = {%6d",
|
|
||||||
base[nstates]);
|
|
||||||
|
|
||||||
j = 10;
|
|
||||||
for (i = nstates + 1; i < nvectors; i++)
|
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
|
|
||||||
if (j >= 10)
|
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "%6d", base[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "\n};\n");
|
|
||||||
FREE (base);
|
FREE (base);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1231,31 +1143,9 @@ output_base (void)
|
|||||||
static void
|
static void
|
||||||
output_table (void)
|
output_table (void)
|
||||||
{
|
{
|
||||||
int i;
|
fprintf (ftable, "\n\n#define\tYYLAST\t\t%d\n\n\n", high);
|
||||||
int j;
|
output_short_table (ftable, "yytable", table,
|
||||||
|
table[0], 1, high + 1);
|
||||||
fprintf (ftable, "\n\n#define\tYYLAST\t\t%d\n\n", high);
|
|
||||||
fprintf (ftable, "\nstatic const short yytable[] = {%6d", table[0]);
|
|
||||||
|
|
||||||
j = 10;
|
|
||||||
for (i = 1; i <= high; i++)
|
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
|
|
||||||
if (j >= 10)
|
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "%6d", table[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "\n};\n");
|
|
||||||
FREE (table);
|
FREE (table);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1263,30 +1153,8 @@ output_table (void)
|
|||||||
static void
|
static void
|
||||||
output_check (void)
|
output_check (void)
|
||||||
{
|
{
|
||||||
int i;
|
output_short_table (ftable, "yycheck", check,
|
||||||
int j;
|
check[0], 1, high + 1);
|
||||||
|
|
||||||
fprintf (ftable, "\nstatic const short yycheck[] = {%6d", check[0]);
|
|
||||||
|
|
||||||
j = 10;
|
|
||||||
for (i = 1; i <= high; i++)
|
|
||||||
{
|
|
||||||
putc (',', ftable);
|
|
||||||
|
|
||||||
if (j >= 10)
|
|
||||||
{
|
|
||||||
putc ('\n', ftable);
|
|
||||||
j = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "%6d", check[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf (ftable, "\n};\n");
|
|
||||||
FREE (check);
|
FREE (check);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1318,8 +1186,10 @@ output_actions (void)
|
|||||||
|
|
||||||
sort_actions ();
|
sort_actions ();
|
||||||
pack_table ();
|
pack_table ();
|
||||||
|
putc ('\n', ftable);
|
||||||
output_base ();
|
output_base ();
|
||||||
output_table ();
|
output_table ();
|
||||||
|
putc ('\n', ftable);
|
||||||
output_check ();
|
output_check ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
src/reader.c
10
src/reader.c
@@ -118,7 +118,7 @@ static int get_type PARAMS((void));
|
|||||||
|
|
||||||
int lineno;
|
int lineno;
|
||||||
char **tags;
|
char **tags;
|
||||||
int *user_toknums;
|
short *user_toknums;
|
||||||
static symbol_list *grammar;
|
static symbol_list *grammar;
|
||||||
static int start_flag;
|
static int start_flag;
|
||||||
static bucket *startval;
|
static bucket *startval;
|
||||||
@@ -296,8 +296,10 @@ copy_comment2 (FILE *in, FILE *out1, FILE* out2, int c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Dump the comment from FIN to FOUT. C is either `*' or `/',
|
/*------------------------------------------------------------.
|
||||||
depending upon the type of comments used. */
|
| Dump the comment from FIN to FOUT. C is either `*' or `/', |
|
||||||
|
| depending upon the type of comments used. |
|
||||||
|
`------------------------------------------------------------*/
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
copy_comment (FILE *fin, FILE *fout, int c)
|
copy_comment (FILE *fin, FILE *fout, int c)
|
||||||
@@ -1737,7 +1739,7 @@ packsymbols (void)
|
|||||||
|
|
||||||
tags = NEW2(nsyms + 1, char *);
|
tags = NEW2(nsyms + 1, char *);
|
||||||
tags[0] = DOLLAR;
|
tags[0] = DOLLAR;
|
||||||
user_toknums = NEW2(nsyms + 1, int);
|
user_toknums = NEW2(nsyms + 1, short);
|
||||||
user_toknums[0] = 0;
|
user_toknums[0] = 0;
|
||||||
|
|
||||||
sprec = NEW2(nsyms, short);
|
sprec = NEW2(nsyms, short);
|
||||||
|
|||||||
Reference in New Issue
Block a user