Properly escape the symbols' TAG when outputting them.
+2002-04-07 Akim Demaille <akim@epita.fr>
+
+ * src/lalr.c, src/LR0.c, src/closure.c, src/gram.c, src/reduce.c:
+ Properly escape the symbols' TAG when outputting them.
+
2002-04-07 Akim Demaille <akim@epita.fr>
* src/lalr.h (LA): Is a bitsetv, not bitset*.
2002-04-07 Akim Demaille <akim@epita.fr>
* src/lalr.h (LA): Is a bitsetv, not bitset*.
#include "system.h"
#include "bitset.h"
#include "system.h"
#include "bitset.h"
#include "symtab.h"
#include "getargs.h"
#include "reader.h"
#include "symtab.h"
#include "getargs.h"
#include "reader.h"
if (trace_flag)
fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
if (trace_flag)
fprintf (stderr, "Entering new_state, state = %d, symbol = %d (%s)\n",
- nstates, symbol, symbols[symbol]->tag);
+ nstates, symbol, quotearg_style (escape_quoting_style,
+ symbols[symbol]->tag));
if (nstates >= MAXSHORT)
fatal (_("too many states (max %d)"), MAXSHORT);
if (nstates >= MAXSHORT)
fatal (_("too many states (max %d)"), MAXSHORT);
if (trace_flag)
fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
if (trace_flag)
fprintf (stderr, "Entering get_state, state = %d, symbol = %d (%s)\n",
- this_state->number, symbol, symbols[symbol]->tag);
+ this_state->number, symbol, quotearg_style (escape_quoting_style,
+ symbols[symbol]->tag));
/* Add up the target state's active item numbers to get a hash key.
*/
/* Add up the target state's active item numbers to get a hash key.
*/
if (trace_flag)
fprintf (stderr, "Processing state %d (reached by %s)\n",
this_state->number,
if (trace_flag)
fprintf (stderr, "Processing state %d (reached by %s)\n",
this_state->number,
- symbols[this_state->accessing_symbol]->tag);
+ quotearg_style (escape_quoting_style,
+ symbols[this_state->accessing_symbol]->tag));
/* Set up ruleset and itemset for the transitions out of this
state. ruleset gets a 1 bit for each rule that could reduce
now. itemset gets a vector of all the items that could be
/* Set up ruleset and itemset for the transitions out of this
state. ruleset gets a 1 bit for each rule that could reduce
now. itemset gets a vector of all the items that could be
02111-1307, USA. */
#include "system.h"
02111-1307, USA. */
#include "system.h"
#include "bitset.h"
#include "bitsetv.h"
#include "getargs.h"
#include "bitset.h"
#include "bitsetv.h"
#include "getargs.h"
short *rp;
fprintf (stderr, " %2d: .", array[i]);
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
short *rp;
fprintf (stderr, " %2d: .", array[i]);
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
- fprintf (stderr, " %s", symbols[*rp]->tag);
+ fprintf (stderr, " %s",
+ quotearg_style (escape_quoting_style, symbols[*rp]->tag));
fprintf (stderr, " (rule %d)\n", -*rp - 1);
}
fputs ("\n\n", stderr);
fprintf (stderr, " (rule %d)\n", -*rp - 1);
}
fputs ("\n\n", stderr);
fprintf (stderr, "FIRSTS\n");
for (i = ntokens; i < nsyms; i++)
{
fprintf (stderr, "FIRSTS\n");
for (i = ntokens; i < nsyms; i++)
{
- fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
+ fprintf (stderr, "\t%s firsts\n",
+ quotearg_style (escape_quoting_style, symbols[i]->tag));
for (j = 0; j < nvars; j++)
if (bitset_test (FIRSTS (i), j))
fprintf (stderr, "\t\t%d (%s)\n",
for (j = 0; j < nvars; j++)
if (bitset_test (FIRSTS (i), j))
fprintf (stderr, "\t\t%d (%s)\n",
- j + ntokens, symbols[j + ntokens]->tag);
+ j + ntokens,
+ quotearg_style (escape_quoting_style,
+ symbols[j + ntokens]->tag));
}
fprintf (stderr, "\n\n");
}
}
fprintf (stderr, "\n\n");
}
fprintf (stderr, "FDERIVES\n");
for (i = ntokens; i < nsyms; i++)
{
fprintf (stderr, "FDERIVES\n");
for (i = ntokens; i < nsyms; i++)
{
- fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
+ fprintf (stderr, "\t%s derives\n",
+ quotearg_style (escape_quoting_style, symbols[i]->tag));
for (j = 0; j < nrules + 1; j++)
if (bitset_test (FDERIVES (i), j))
{
short *rhsp;
fprintf (stderr, "\t\t%d:", j - 1);
for (rhsp = rules[j].rhs; *rhsp >= 0; ++rhsp)
for (j = 0; j < nrules + 1; j++)
if (bitset_test (FDERIVES (i), j))
{
short *rhsp;
fprintf (stderr, "\t\t%d:", j - 1);
for (rhsp = rules[j].rhs; *rhsp >= 0; ++rhsp)
- fprintf (stderr, " %s", symbols[*rhsp]->tag);
+ fprintf (stderr, " %s",
+ quotearg_style (escape_quoting_style,
+ symbols[*rhsp]->tag));
fputc ('\n', stderr);
}
}
fputc ('\n', stderr);
}
}
- Copyright 1984, 1989, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of Bison, the GNU Compiler Compiler.
#ifndef CLOSURE_H_
# define CLOSURE_H_
#ifndef CLOSURE_H_
# define CLOSURE_H_
-/* Subroutines of file LR0.c. */
-
/* Allocates the itemset and ruleset vectors, and precomputes useful
data so that closure can be called. n is the number of elements to
allocate for itemset. */
/* Allocates the itemset and ruleset vectors, and precomputes useful
data so that closure can be called. n is the number of elements to
allocate for itemset. */
/* Given the kernel (aka core) of a state (a vector of item numbers
/* Given the kernel (aka core) of a state (a vector of item numbers
- ITEMS, of length N), set up ruleset and itemset to indicate what
+ ITEMS, of length N), set up RULESET and ITEMSET to indicate what
rules could be run and which items could be accepted when those
items are the active ones.
rules could be run and which items could be accepted when those
items are the active ones.
- ruleset contains a bit for each rule. closure sets the bits for
+ RULESET contains a bit for each rule. CLOSURE sets the bits for
all rules which could potentially describe the next input to be
read.
ITEMSET is a vector of item numbers; NITEMSET is its size
all rules which could potentially describe the next input to be
read.
ITEMSET is a vector of item numbers; NITEMSET is its size
- 9actually, points to just beyond the end of the part of it that is
- significant). closure places there the indices of all items which
+ (actually, points to just beyond the end of the part of it that is
+ significant). CLOSURE places there the indices of all items which
represent units of input that could arrive next. */
void closure PARAMS ((short *items, int n));
represent units of input that could arrive next. */
void closure PARAMS ((short *items, int n));
-/* Frees itemset, ruleset and internal data. */
+/* Frees ITEMSET, RULESET and internal data. */
void free_closure PARAMS ((void));
void free_closure PARAMS ((void));
/* Allocate input grammar variables for bison,
/* Allocate input grammar variables for bison,
- Copyright 1984, 1986, 1989, 2001, 2002 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 2001, 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of Bison, the GNU Compiler Compiler.
#include "gram.h"
#include "symtab.h"
#include "reader.h"
#include "gram.h"
#include "symtab.h"
#include "reader.h"
fputs ("RITEM\n", out);
for (i = 0; i < nritems; ++i)
if (ritem[i] >= 0)
fputs ("RITEM\n", out);
for (i = 0; i < nritems; ++i)
if (ritem[i] >= 0)
- fprintf (out, " %s", symbols[ritem[i]]->tag);
+ fprintf (out, " %s", quotearg_style (escape_quoting_style,
+ symbols[ritem[i]]->tag));
else
fprintf (out, " (rule %d)\n", -ritem[i] - 1);
fputs ("\n\n", out);
else
fprintf (out, " (rule %d)\n", -ritem[i] - 1);
fputs ("\n\n", out);
#include "system.h"
#include "bitset.h"
#include "bitsetv.h"
#include "system.h"
#include "bitset.h"
#include "bitsetv.h"
#include "reader.h"
#include "types.h"
#include "LR0.h"
#include "reader.h"
#include "types.h"
#include "LR0.h"
for (j = 0; j < states[i]->nlookaheads; ++j)
for (k = 0; k < ntokens; ++k)
for (j = 0; j < states[i]->nlookaheads; ++j)
for (k = 0; k < ntokens; ++k)
- if (bitset_test (LA[states[i]->lookaheadsp + j], j))
+ if (bitset_test (LA[states[i]->lookaheadsp + j], k))
fprintf (out, " on %d (%s) -> rule %d\n",
fprintf (out, " on %d (%s) -> rule %d\n",
+ k, quotearg_style (escape_quoting_style, symbols[k]->tag),
LArule[states[i]->lookaheadsp + j]->number - 1);
}
fprintf (out, "Lookaheads: END\n");
LArule[states[i]->lookaheadsp + j]->number - 1);
}
fprintf (out, "Lookaheads: END\n");
/* Grammar reduction for Bison.
/* Grammar reduction for Bison.
- Copyright 1988, 1989, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1988, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
This file is part of Bison, the GNU Compiler Compiler.
user's parser. */
#include "system.h"
user's parser. */
#include "system.h"
#include "getargs.h"
#include "files.h"
#include "symtab.h"
#include "getargs.h"
#include "files.h"
#include "symtab.h"
int i;
fprintf (out, "%s\n\n", _("Useless nonterminals:"));
for (i = 0; i < nuseless_nonterminals; ++i)
int i;
fprintf (out, "%s\n\n", _("Useless nonterminals:"));
for (i = 0; i < nuseless_nonterminals; ++i)
- fprintf (out, " %s\n", symbols[nsyms + i]->tag);
+ fprintf (out, " %s\n", quotearg_style (escape_quoting_style,
+ symbols[nsyms + i]->tag));
if (!b)
fprintf (out, "%s\n\n", _("Terminals which are not used:"));
b = TRUE;
if (!b)
fprintf (out, "%s\n\n", _("Terminals which are not used:"));
b = TRUE;
- fprintf (out, " %s\n", symbols[i]->tag);
+ fprintf (out, " %s\n", quotearg_style (escape_quoting_style,
+ symbols[i]->tag));
}
if (b)
fputs ("\n\n", out);
}
if (b)
fputs ("\n\n", out);
{
rule r;
fprintf (out, "#%-4d ", rules[i].user_number - 1);
{
rule r;
fprintf (out, "#%-4d ", rules[i].user_number - 1);
- fprintf (out, "%s:", rules[i].lhs->tag);
+ fprintf (out, "%s:", quotearg_style (escape_quoting_style,
+ rules[i].lhs->tag));
for (r = rules[i].rhs; *r >= 0; r++)
for (r = rules[i].rhs; *r >= 0; r++)
- fprintf (out, " %s", symbols[*r]->tag);
+ fprintf (out, " %s", quotearg_style (escape_quoting_style,
+ symbols[*r]->tag));
fputs (";\n", out);
}
fputs ("\n\n", out);
fputs (";\n", out);
}
fputs ("\n\n", out);
for (i = ntokens; i < nsyms; i++)
fprintf (out, "%5d %5d %5d %s\n",
i,
for (i = ntokens; i < nsyms; i++)
fprintf (out, "%5d %5d %5d %s\n",
i,
- symbols[i]->prec, symbols[i]->assoc, symbols[i]->tag);
+ symbols[i]->prec, symbols[i]->assoc,
+ quotearg_style (escape_quoting_style, symbols[i]->tag));
fprintf (out, "\n\n");
fprintf (out, "Rules\n-----\n\n");
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
fprintf (out, "\n\n");
fprintf (out, "Rules\n-----\n\n");
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
fprintf (out, "Rules interpreted\n-----------------\n\n");
for (i = 1; i < nrules + nuseless_productions + 1; i++)
{
fprintf (out, "Rules interpreted\n-----------------\n\n");
for (i = 1; i < nrules + nuseless_productions + 1; i++)
{
- fprintf (out, "%-5d %s :", i, rules[i].lhs->tag);
+ fprintf (out, "%-5d %s :",
+ i, quotearg_style (escape_quoting_style, rules[i].lhs->tag));
for (r = rules[i].rhs; *r >= 0; r++)
for (r = rules[i].rhs; *r >= 0; r++)
- fprintf (out, " %s", symbols[*r]->tag);
+ fprintf (out, " %s",
+ quotearg_style (escape_quoting_style, symbols[*r]->tag));
fputc ('\n', out);
}
fprintf (out, "\n\n");
fputc ('\n', out);
}
fprintf (out, "\n\n");
if (!bitset_test (N, start_symbol - ntokens))
fatal (_("Start symbol %s does not derive any sentence"),
if (!bitset_test (N, start_symbol - ntokens))
fatal (_("Start symbol %s does not derive any sentence"),
- symbols[start_symbol]->tag);
+ quotearg_style (escape_quoting_style, symbols[start_symbol]->tag));
if (nuseless_productions > 0)
reduce_grammar_tables ();
if (nuseless_productions > 0)
reduce_grammar_tables ();