mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
closure, gram: add missing const
* src/closure.h, src/closure.c, src/gram.h, src/gram.c: Add some missing const where appropriate.
This commit is contained in:
@@ -52,7 +52,7 @@ static bitsetv firsts = NULL;
|
||||
`-----------------*/
|
||||
|
||||
static void
|
||||
print_closure (char const *title, item_number *array, size_t size)
|
||||
print_closure (char const *title, item_number const *array, size_t size)
|
||||
{
|
||||
size_t i;
|
||||
fprintf (stderr, "Closure: %s\n", title);
|
||||
@@ -189,7 +189,7 @@ new_closure (unsigned int n)
|
||||
|
||||
|
||||
void
|
||||
closure (item_number *core, size_t n)
|
||||
closure (item_number const *core, size_t n)
|
||||
{
|
||||
/* Index over CORE. */
|
||||
size_t c;
|
||||
|
||||
@@ -44,7 +44,7 @@ void new_closure (unsigned int n);
|
||||
significant). CLOSURE places there the indices of all items which
|
||||
represent units of input that could arrive next. */
|
||||
|
||||
void closure (item_number *items, size_t n);
|
||||
void closure (item_number const *items, size_t n);
|
||||
|
||||
|
||||
/* Frees ITEMSET, RULESET and internal data. */
|
||||
|
||||
24
src/gram.c
24
src/gram.c
@@ -47,25 +47,25 @@ symbol_number *token_translations = NULL;
|
||||
int max_user_token_number = 256;
|
||||
|
||||
bool
|
||||
rule_useful_in_grammar_p (rule *r)
|
||||
rule_useful_in_grammar_p (rule const *r)
|
||||
{
|
||||
return r->number < nrules;
|
||||
}
|
||||
|
||||
bool
|
||||
rule_useless_in_grammar_p (rule *r)
|
||||
rule_useless_in_grammar_p (rule const *r)
|
||||
{
|
||||
return !rule_useful_in_grammar_p (r);
|
||||
}
|
||||
|
||||
bool
|
||||
rule_useless_in_parser_p (rule *r)
|
||||
rule_useless_in_parser_p (rule const *r)
|
||||
{
|
||||
return !r->useful && rule_useful_in_grammar_p (r);
|
||||
}
|
||||
|
||||
void
|
||||
rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out)
|
||||
rule_lhs_print (rule const *r, symbol const *previous_lhs, FILE *out)
|
||||
{
|
||||
fprintf (out, " %3d ", r->number);
|
||||
if (previous_lhs != r->lhs)
|
||||
@@ -82,13 +82,13 @@ rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out)
|
||||
}
|
||||
|
||||
void
|
||||
rule_lhs_print_xml (rule *r, FILE *out, int level)
|
||||
rule_lhs_print_xml (rule const *r, FILE *out, int level)
|
||||
{
|
||||
xml_printf (out, level, "<lhs>%s</lhs>", r->lhs->tag);
|
||||
}
|
||||
|
||||
size_t
|
||||
rule_rhs_length (rule *r)
|
||||
rule_rhs_length (rule const *r)
|
||||
{
|
||||
size_t res = 0;
|
||||
item_number *rhsp;
|
||||
@@ -98,7 +98,7 @@ rule_rhs_length (rule *r)
|
||||
}
|
||||
|
||||
void
|
||||
rule_rhs_print (rule *r, FILE *out)
|
||||
rule_rhs_print (rule const *r, FILE *out)
|
||||
{
|
||||
if (*r->rhs >= 0)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ rule_rhs_print (rule *r, FILE *out)
|
||||
}
|
||||
|
||||
static void
|
||||
rule_rhs_print_xml (rule *r, FILE *out, int level)
|
||||
rule_rhs_print_xml (rule const *r, FILE *out, int level)
|
||||
{
|
||||
if (*r->rhs >= 0)
|
||||
{
|
||||
@@ -133,7 +133,7 @@ rule_rhs_print_xml (rule *r, FILE *out, int level)
|
||||
}
|
||||
|
||||
static void
|
||||
rule_print (rule *r, FILE *out)
|
||||
rule_print (rule const *r, FILE *out)
|
||||
{
|
||||
fprintf (out, "%s:", r->lhs->tag);
|
||||
rule_rhs_print (r, out);
|
||||
@@ -263,10 +263,12 @@ grammar_dump (FILE *out, const char *title)
|
||||
fprintf (out, "Rules\n-----\n\n");
|
||||
{
|
||||
rule_number i;
|
||||
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
|
||||
fprintf (out,
|
||||
"Num (Prec, Assoc, Useful, Ritem Range) Lhs"
|
||||
" -> Rhs (Ritem range) [Num]\n");
|
||||
for (i = 0; i < nrules + nuseless_productions; i++)
|
||||
{
|
||||
rule *rule_i = &rules[i];
|
||||
rule const *rule_i = &rules[i];
|
||||
item_number *rp = NULL;
|
||||
unsigned int rhs_itemno = rule_i->rhs - ritem;
|
||||
unsigned int rhs_count = 0;
|
||||
|
||||
16
src/gram.h
16
src/gram.h
@@ -203,31 +203,31 @@ typedef struct
|
||||
extern rule *rules;
|
||||
|
||||
/* A function that selects a rule. */
|
||||
typedef bool (*rule_filter) (rule *);
|
||||
typedef bool (*rule_filter) (rule const *);
|
||||
|
||||
/* Return true IFF the rule has a `number' smaller than NRULES. That is, it is
|
||||
useful in the grammar. */
|
||||
bool rule_useful_in_grammar_p (rule *r);
|
||||
bool rule_useful_in_grammar_p (rule const *r);
|
||||
|
||||
/* Return true IFF the rule has a `number' higher than NRULES. That is, it is
|
||||
useless in the grammar. */
|
||||
bool rule_useless_in_grammar_p (rule *r);
|
||||
bool rule_useless_in_grammar_p (rule const *r);
|
||||
|
||||
/* Return true IFF the rule is not flagged as useful but is useful in the
|
||||
grammar. In other words, it was discarded because of conflicts. */
|
||||
bool rule_useless_in_parser_p (rule *r);
|
||||
bool rule_useless_in_parser_p (rule const *r);
|
||||
|
||||
/* Print this rule's number and lhs on OUT. If a PREVIOUS_LHS was
|
||||
already displayed (by a previous call for another rule), avoid
|
||||
useless repetitions. */
|
||||
void rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out);
|
||||
void rule_lhs_print_xml (rule *r, FILE *out, int level);
|
||||
void rule_lhs_print (rule const *r, symbol const *previous_lhs, FILE *out);
|
||||
void rule_lhs_print_xml (rule const *r, FILE *out, int level);
|
||||
|
||||
/* Return the length of the RHS. */
|
||||
size_t rule_rhs_length (rule *r);
|
||||
size_t rule_rhs_length (rule const *r);
|
||||
|
||||
/* Print this rule's RHS on OUT. */
|
||||
void rule_rhs_print (rule *r, FILE *out);
|
||||
void rule_rhs_print (rule const *r, FILE *out);
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user