use `const` in graminit.c (GH-12713)

This commit is contained in:
tyomitch 2019-04-23 12:29:57 +03:00 committed by Inada Naoki
parent fb8c7d5332
commit 84b4784f12
3 changed files with 418 additions and 418 deletions

View File

@ -13,7 +13,7 @@ extern "C" {
typedef struct {
int lb_type;
char *lb_str;
const char *lb_str;
} label;
#define EMPTY 0 /* Label number 0 is by definition the empty label */
@ -22,7 +22,7 @@ typedef struct {
typedef struct {
int ll_nlabels;
label *ll_label;
const label *ll_label;
} labellist;
/* An arc from one state to another */
@ -36,7 +36,7 @@ typedef struct {
typedef struct {
int s_narcs;
arc *s_arc; /* Array of arcs */
const arc *s_arc; /* Array of arcs */
/* Optional accelerators */
int s_lower; /* Lowest label index */
@ -59,8 +59,8 @@ typedef struct {
typedef struct {
int g_ndfas;
dfa *g_dfa; /* Array of DFAs */
labellist g_ll;
const dfa *g_dfa; /* Array of DFAs */
const labellist g_ll;
int g_start; /* Start symbol of the grammar */
int g_accel; /* Set if accelerators present */
} grammar;

View File

@ -76,7 +76,7 @@ class Grammar:
def print_labels(self, writer):
writer(
"static label labels[{n_labels}] = {{\n".format(n_labels=len(self.labels))
"static const label labels[{n_labels}] = {{\n".format(n_labels=len(self.labels))
)
for label, name in self.labels:
label_name = '"{}"'.format(name) if name is not None else 0
@ -89,7 +89,7 @@ class Grammar:
def print_dfas(self, writer):
self.print_states(writer)
writer("static dfa dfas[{}] = {{\n".format(len(self.dfas)))
writer("static const dfa dfas[{}] = {{\n".format(len(self.dfas)))
for dfaindex, dfa_elem in enumerate(self.dfas.items()):
symbol, (dfa, first_sets) = dfa_elem
writer(
@ -131,7 +131,7 @@ class Grammar:
for stateindex, state in enumerate(states):
narcs = len(state)
write(
"static arc arcs_{dfa_index}_{state_index}[{n_arcs}] = {{\n".format(
"static const arc arcs_{dfa_index}_{state_index}[{n_arcs}] = {{\n".format(
dfa_index=dfaindex, state_index=stateindex, n_arcs=narcs
)
)

File diff suppressed because it is too large Load Diff