negative short int. Used to flag ?? */
#include "system.h"
+#include "bitsetv.h"
#include "quotearg.h"
#include "error.h"
#include "getargs.h"
{
int i;
short *values = XCALLOC (short, nrules + 1);
- for (i = 0; i < nrules + 1; ++i)
- values[i] = rules[i].rhs;
+ for (i = 1; i < nrules + 1; ++i)
+ values[i] = rules[i].rhs - ritem;
output_table_data (&format_obstack, values,
0, 1, nrules + 1);
XFREE (values);
static void
output_stos (void)
{
- int i;
+ size_t i;
short *values = (short *) alloca (sizeof (short) * nstates);
for (i = 0; i < nstates; ++i)
values[i] = states[i]->accessing_symbol;
{
short *values = XCALLOC (short, nrules + 1);
- for (i = 0; i < nrules + 1; ++i)
+ for (i = 1; i < nrules + 1; ++i)
values[i] = rules[i].line;
output_table_data (&format_obstack, values,
0, 1, nrules + 1);
/* Output YYR1. */
{
short *values = XCALLOC (short, nrules + 1);
- for (i = 0; i < nrules + 1; ++i)
- values[i] = rules[i].lhs;
+ for (i = 1; i < nrules + 1; ++i)
+ values[i] = rules[i].lhs->number;
output_table_data (&format_obstack, values,
0, 1, nrules + 1);
muscle_insert ("r1", obstack_finish (&format_obstack));
short_tab = XMALLOC (short, nrules + 1);
for (i = 1; i < nrules; i++)
short_tab[i] = rules[i + 1].rhs - rules[i].rhs - 1;
- short_tab[nrules] = nritems - rules[nrules].rhs - 1;
+ short_tab[nrules] = nritems - (rules[nrules].rhs - ritem) - 1;
output_table_data (&format_obstack, short_tab,
0, 1, nrules + 1);
muscle_insert ("r2", obstack_finish (&format_obstack));
for (j = 0; j < ntokens; j++)
/* and record this rule as the rule to use if that
token follows. */
- if (BITISSET (LA (state->lookaheadsp + i), j))
+ if (bitset_test (LA[state->lookaheadsp + i], j))
actrow[j] = -LAruleno[state->lookaheadsp + i];
}
static void
token_actions (void)
{
- int i;
+ size_t i;
short *yydefact = XCALLOC (short, nstates);
actrow = XCALLOC (short, ntokens);
token_definitions_output (FILE *out)
{
int i;
+ int first = 1;
for (i = 0; i < ntokens; ++i)
{
bucket *symbol = symbols[i];
if (number == SALIAS)
continue;
/* Skip error token. */
- if (symbol->value == error_token_number)
+ if (symbol->number == error_token_number)
continue;
if (symbol->tag[0] == '\'')
continue; /* skip literal character */
if (strchr (symbol->tag, '.') || strchr (symbol->tag, '$'))
continue;
- fprintf (out, "# define %s\t%d\n",
- symbol->tag, number);
+ fprintf (out, "%s [[[%s]], [%d]]",
+ first ? "" : ",\n", symbol->tag, number);
if (semantic_parser)
/* FIXME: This is probably wrong, and should be just as
above. --akim. */
- fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->value);
+ fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->number);
+ first = 0;
}
}
static int
default_goto (int symbol)
{
- int i;
- int m = goto_map[symbol];
- int n = goto_map[symbol + 1];
+ size_t i;
+ size_t m = goto_map[symbol];
+ size_t n = goto_map[symbol + 1];
int default_state = -1;
int max = 0;
int w;
int prev;
- if (i >= nstates)
+ if (i >= (int) nstates)
return -1;
t = tally[i];
static void
output_actions (void)
{
- int i;
+ size_t i;
nvectors = nstates + nvars;
froms = XCALLOC (short *, nvectors);
width = XCALLOC (short, nvectors);
token_actions ();
- XFREE (LA);
+ bitsetv_free (LA);
XFREE (LAruleno);
goto_actions ();
output_skeleton (void)
{
/* Store the definition of all the muscles. */
- char *tempdir = getenv ("TMPDIR");
+ const char *tempdir = getenv ("TMPDIR");
char *tempfile = NULL;
FILE *out = NULL;
- ssize_t bytes_read;
int fd;
if (tempdir == NULL)
guards_output (out);
fputs ("]])\n\n", out);
- fputs ("m4_define([b4_tokendef], \n[[", out);
+ fputs ("m4_define([b4_tokens], \n[", out);
token_definitions_output (out);
- fputs ("]])\n\n", out);
+ fputs ("])\n\n", out);
muscles_m4_output (out);
output_token_translations ();
output_gram ();
- XFREE (ritem);
if (semantic_parser)
output_stos ();
output_rule_data ();
/* Process the selected skeleton file. */
output_skeleton ();
- free (rules + 1);
obstack_free (&muscle_obstack, NULL);
obstack_free (&format_obstack, NULL);
obstack_free (&action_obstack, NULL);