104 |
#include "conflicts.h" |
#include "conflicts.h" |
105 |
#include "muscle_tab.h" |
#include "muscle_tab.h" |
106 |
|
|
|
/* From lib/readpipe.h. */ |
|
|
FILE *readpipe PARAMS ((const char *, ...)); |
|
|
|
|
107 |
/* From src/scan-skel.l. */ |
/* From src/scan-skel.l. */ |
108 |
int skel_lex PARAMS ((void)); |
void m4_invoke PARAMS ((const char *definitions)); |
|
extern FILE *skel_in; |
|
109 |
|
|
110 |
static int nvectors; |
static int nvectors; |
111 |
static int nentries; |
static int nentries; |
890 |
{ |
{ |
891 |
int i; |
int i; |
892 |
|
|
|
order = XCALLOC (short, nvectors); |
|
893 |
nentries = 0; |
nentries = 0; |
894 |
|
|
895 |
for (i = 0; i < nvectors; i++) |
for (i = 0; i < nvectors; i++) |
1051 |
XFREE (conflict_tos[i]); |
XFREE (conflict_tos[i]); |
1052 |
} |
} |
1053 |
|
|
1054 |
XFREE (froms); |
free (froms); |
1055 |
XFREE (tos); |
free (tos); |
1056 |
XFREE (conflict_tos); |
free (conflict_tos); |
1057 |
XFREE (pos); |
free (pos); |
1058 |
} |
} |
1059 |
|
|
1060 |
/* the following functions output yytable, yycheck, yyconflp, yyconfl, |
/* the following functions output yytable, yycheck, yyconflp, yyconfl, |
1119 |
`-----------------------------------------------------------------*/ |
`-----------------------------------------------------------------*/ |
1120 |
|
|
1121 |
static void |
static void |
1122 |
output_actions (void) |
prepare_actions (void) |
1123 |
{ |
{ |
1124 |
/* That's a poor way to make sure the sizes are properly corelated, |
/* That's a poor way to make sure the sizes are properly corelated, |
1125 |
in particular the signedness is not taking into account, but it's |
in particular the signedness is not taking into account, but it's |
1144 |
XFREE (from_state); |
XFREE (from_state); |
1145 |
XFREE (to_state); |
XFREE (to_state); |
1146 |
|
|
1147 |
|
order = XCALLOC (short, nvectors); |
1148 |
sort_actions (); |
sort_actions (); |
1149 |
pack_table (); |
pack_table (); |
1150 |
|
free (order); |
1151 |
|
|
1152 |
|
free (tally); |
1153 |
|
free (width); |
1154 |
|
|
1155 |
output_base (); |
output_base (); |
1156 |
output_table (); |
output_table (); |
1160 |
} |
} |
1161 |
|
|
1162 |
|
|
|
/*----------------------. |
|
|
| Run our backend, M4. | |
|
|
`----------------------*/ |
|
|
|
|
|
static void |
|
|
m4_invoke (const char *definitions) |
|
|
{ |
|
|
/* Invoke m4 on the definition of the muscles, and the skeleton. */ |
|
|
const char *bison_pkgdatadir = getenv ("BISON_PKGDATADIR"); |
|
|
const char *m4 = getenv ("M4"); |
|
|
int pkg_data_len; |
|
|
char *full_skeleton; |
|
|
|
|
|
if (!m4) |
|
|
m4 = M4; |
|
|
if (!bison_pkgdatadir) |
|
|
bison_pkgdatadir = PKGDATADIR; |
|
|
pkg_data_len = strlen (bison_pkgdatadir); |
|
|
full_skeleton = XMALLOC (char, pkg_data_len + strlen (skeleton) + 2); |
|
|
if (bison_pkgdatadir[pkg_data_len-1] == '/') |
|
|
sprintf (full_skeleton, "%s%s", bison_pkgdatadir, skeleton); |
|
|
else |
|
|
sprintf (full_skeleton, "%s/%s", bison_pkgdatadir, skeleton); |
|
|
if (trace_flag) |
|
|
fprintf (stderr, |
|
|
"running: %s -I %s m4sugar/m4sugar.m4 %s %s\n", |
|
|
m4, bison_pkgdatadir, definitions, full_skeleton); |
|
|
skel_in = readpipe (m4, |
|
|
"-I", bison_pkgdatadir, |
|
|
"m4sugar/m4sugar.m4", |
|
|
definitions, |
|
|
full_skeleton, |
|
|
NULL); |
|
|
XFREE (full_skeleton); |
|
|
if (!skel_in) |
|
|
error (EXIT_FAILURE, errno, "cannot run m4"); |
|
|
skel_lex (); |
|
|
} |
|
|
|
|
|
|
|
1163 |
/*---------------------------. |
/*---------------------------. |
1164 |
| Call the skeleton parser. | |
| Call the skeleton parser. | |
1165 |
`---------------------------*/ |
`---------------------------*/ |
1272 |
prepare_tokens (); |
prepare_tokens (); |
1273 |
prepare_rules (); |
prepare_rules (); |
1274 |
prepare_states (); |
prepare_states (); |
1275 |
output_actions (); |
prepare_actions (); |
1276 |
|
|
1277 |
prepare (); |
prepare (); |
1278 |
|
|