aboutsummaryrefslogtreecommitdiff
path: root/util-tables.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-tables.c')
-rw-r--r--util-tables.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/util-tables.c b/util-tables.c
index 83a015c..09df914 100644
--- a/util-tables.c
+++ b/util-tables.c
@@ -27,20 +27,20 @@ void util_tables_fill()
follow[i] = xcalloc(total_symbols, sizeof(*follow[i]));
first[i] = xcalloc(total_symbols, sizeof(*follow[i]));
}
-
+
for(size_t sym = 0; sym < total_symbols; sym++) {
first[sym][sym] = 1;
}
-
+
for(size_t i = 0; i < total_productions; i++) {
struct production *p = &grammar[i];
-
+
first[p->LHS][p->RHS[0]] = 1;
-
+
for(size_t j = 1; j < p->nRHS; j++)
follow[p->RHS[j-1]][p->RHS[j]] = 1;
}
-
+
#define set(e) if((e) != 1) changed = (e) = 1
int changed;
@@ -66,7 +66,7 @@ void util_tables_free()
free(follow[i]);
free(first[i]);
}
-
+
free(follow);
free(first);
}
@@ -75,7 +75,7 @@ void util_tables_print()
{
char *s1 = "-- FIRST --";
printf(" %*s%s\n", (int)((total_symbols*3) - strlen(s1))/2, "", s1);
-
+
printf(" ");
for(size_t i = 0; i < total_symbols; i++) printf("%2zu ", i);
printf("\n");
@@ -88,7 +88,7 @@ void util_tables_print()
}
printf("\n");
-
+
char *s2 = "-- FOLLOW --";
printf(" %*s%s\n", (int)((total_symbols*3) - strlen(s2))/2, "", s2);
@@ -119,7 +119,7 @@ enum symbol {
SYMBOLS_END,
};
-const size_t total_symbols = SYMBOLS_END;
+size_t total_symbols = SYMBOLS_END;
int symbol_is_terminal(symbol s) { return s < E; }
int symbol_is_nonterminal(symbol s) { return s >= E; }