mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 02:03:03 +00:00
style: more uses of const
* src/print.c, src/state.h, src/state.c: here.
This commit is contained in:
16
src/print.c
16
src/print.c
@@ -60,9 +60,9 @@ max_length (size_t *width, const char *str)
|
|||||||
`--------------------------------*/
|
`--------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_core (FILE *out, state *s)
|
print_core (FILE *out, const state *s)
|
||||||
{
|
{
|
||||||
item_index *sitems = s->items;
|
const item_index *sitems = s->items;
|
||||||
size_t snritems = s->nitems;
|
size_t snritems = s->nitems;
|
||||||
/* Output all the items of a state, not only its kernel. */
|
/* Output all the items of a state, not only its kernel. */
|
||||||
if (report_flag & report_itemsets)
|
if (report_flag & report_itemsets)
|
||||||
@@ -100,7 +100,7 @@ print_core (FILE *out, state *s)
|
|||||||
`------------------------------------------------------------*/
|
`------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_transitions (state *s, FILE *out, bool display_transitions_p)
|
print_transitions (const state *s, FILE *out, bool display_transitions_p)
|
||||||
{
|
{
|
||||||
transitions *trans = s->transitions;
|
transitions *trans = s->transitions;
|
||||||
size_t width = 0;
|
size_t width = 0;
|
||||||
@@ -128,7 +128,7 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
|
|||||||
{
|
{
|
||||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||||
const char *tag = sym->tag;
|
const char *tag = sym->tag;
|
||||||
state *s1 = trans->states[i];
|
const state *s1 = trans->states[i];
|
||||||
|
|
||||||
fprintf (out, " %s", tag);
|
fprintf (out, " %s", tag);
|
||||||
for (int j = width - mbswidth (tag, 0); j > 0; --j)
|
for (int j = width - mbswidth (tag, 0); j > 0; --j)
|
||||||
@@ -146,7 +146,7 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
|
|||||||
`--------------------------------------------------------*/
|
`--------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_errs (FILE *out, state *s)
|
print_errs (FILE *out, const state *s)
|
||||||
{
|
{
|
||||||
errs *errp = s->errs;
|
errs *errp = s->errs;
|
||||||
size_t width = 0;
|
size_t width = 0;
|
||||||
@@ -208,7 +208,7 @@ print_reduction (FILE *out, size_t width,
|
|||||||
`-------------------------------------------*/
|
`-------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_reductions (FILE *out, state *s)
|
print_reductions (FILE *out, const state *s)
|
||||||
{
|
{
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
if (reds->num == 0)
|
if (reds->num == 0)
|
||||||
@@ -324,7 +324,7 @@ print_reductions (FILE *out, state *s)
|
|||||||
`--------------------------------------------------------------*/
|
`--------------------------------------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_actions (FILE *out, state *s)
|
print_actions (FILE *out, const state *s)
|
||||||
{
|
{
|
||||||
/* Print shifts. */
|
/* Print shifts. */
|
||||||
print_transitions (s, out, true);
|
print_transitions (s, out, true);
|
||||||
@@ -340,7 +340,7 @@ print_actions (FILE *out, state *s)
|
|||||||
`----------------------------------*/
|
`----------------------------------*/
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_state (FILE *out, state *s)
|
print_state (FILE *out, const state *s)
|
||||||
{
|
{
|
||||||
fputs ("\n\n", out);
|
fputs ("\n\n", out);
|
||||||
fprintf (out, _("State %d"), s->number);
|
fprintf (out, _("State %d"), s->number);
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ state_reductions_set (state *s, int num, rule **reds)
|
|||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
state_reduction_find (state *s, rule const *r)
|
state_reduction_find (state const *s, rule const *r)
|
||||||
{
|
{
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
for (int i = 0; i < reds->num; ++i)
|
for (int i = 0; i < reds->num; ++i)
|
||||||
@@ -260,7 +260,7 @@ state_errs_set (state *s, int num, symbol **tokens)
|
|||||||
`--------------------------------------------------*/
|
`--------------------------------------------------*/
|
||||||
|
|
||||||
void
|
void
|
||||||
state_rule_lookahead_tokens_print (state *s, rule const *r, FILE *out)
|
state_rule_lookahead_tokens_print (state const *s, rule const *r, FILE *out)
|
||||||
{
|
{
|
||||||
/* Find the reduction we are handling. */
|
/* Find the reduction we are handling. */
|
||||||
reductions *reds = s->reductions;
|
reductions *reds = s->reductions;
|
||||||
@@ -283,7 +283,7 @@ state_rule_lookahead_tokens_print (state *s, rule const *r, FILE *out)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
state_rule_lookahead_tokens_print_xml (state *s, rule const *r,
|
state_rule_lookahead_tokens_print_xml (state const *s, rule const *r,
|
||||||
FILE *out, int level)
|
FILE *out, int level)
|
||||||
{
|
{
|
||||||
/* Find the reduction we are handling. */
|
/* Find the reduction we are handling. */
|
||||||
@@ -395,7 +395,7 @@ state_hash_insert (state *s)
|
|||||||
`------------------------------------------------------------------*/
|
`------------------------------------------------------------------*/
|
||||||
|
|
||||||
state *
|
state *
|
||||||
state_hash_lookup (size_t nitems, item_index *core)
|
state_hash_lookup (size_t nitems, const item_index *core)
|
||||||
{
|
{
|
||||||
size_t items_size = nitems * sizeof *core;
|
size_t items_size = nitems * sizeof *core;
|
||||||
state *probe = xmalloc (offsetof (state, items) + items_size);
|
state *probe = xmalloc (offsetof (state, items) + items_size);
|
||||||
|
|||||||
@@ -247,15 +247,15 @@ void state_reductions_set (state *s, int num, rule **reds);
|
|||||||
|
|
||||||
/* The index of the reduction of state S that corresponds to rule R.
|
/* The index of the reduction of state S that corresponds to rule R.
|
||||||
Aborts if there is no reduction of R in S. */
|
Aborts if there is no reduction of R in S. */
|
||||||
int state_reduction_find (state *s, rule const *r);
|
int state_reduction_find (state const *s, rule const *r);
|
||||||
|
|
||||||
/* Set the errs of STATE. */
|
/* Set the errs of STATE. */
|
||||||
void state_errs_set (state *s, int num, symbol **errors);
|
void state_errs_set (state *s, int num, symbol **errors);
|
||||||
|
|
||||||
/* Print on OUT all the lookahead tokens such that this STATE wants to
|
/* Print on OUT all the lookahead tokens such that this STATE wants to
|
||||||
reduce R. */
|
reduce R. */
|
||||||
void state_rule_lookahead_tokens_print (state *s, rule const *r, FILE *out);
|
void state_rule_lookahead_tokens_print (state const *s, rule const *r, FILE *out);
|
||||||
void state_rule_lookahead_tokens_print_xml (state *s, rule const *r,
|
void state_rule_lookahead_tokens_print_xml (state const *s, rule const *r,
|
||||||
FILE *out, int level);
|
FILE *out, int level);
|
||||||
|
|
||||||
/* Create/destroy the states hash table. */
|
/* Create/destroy the states hash table. */
|
||||||
@@ -264,7 +264,7 @@ void state_hash_free (void);
|
|||||||
|
|
||||||
/* Find the state associated to the CORE, and return it. If it does
|
/* Find the state associated to the CORE, and return it. If it does
|
||||||
not exist yet, return NULL. */
|
not exist yet, return NULL. */
|
||||||
state *state_hash_lookup (size_t core_size, item_index *core);
|
state *state_hash_lookup (size_t core_size, const item_index *core);
|
||||||
|
|
||||||
/* Insert STATE in the state hash table. */
|
/* Insert STATE in the state hash table. */
|
||||||
void state_hash_insert (state *s);
|
void state_hash_insert (state *s);
|
||||||
|
|||||||
Reference in New Issue
Block a user