diff options
author | Guido van Rossum <guido@python.org> | 1990-12-20 15:06:42 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1990-12-20 15:06:42 (GMT) |
commit | 3f5da24ea304e674a9abbdcffc4d671e32aa70f1 (patch) | |
tree | e932e31cb9381f40b7c87c377638216c043b5cfc /Parser/printgrammar.c | |
parent | 226d79eb4a776dd54c9e4544b17deaf928bcef3a (diff) | |
download | cpython-3f5da24ea304e674a9abbdcffc4d671e32aa70f1.zip cpython-3f5da24ea304e674a9abbdcffc4d671e32aa70f1.tar.gz cpython-3f5da24ea304e674a9abbdcffc4d671e32aa70f1.tar.bz2 |
"Compiling" version
Diffstat (limited to 'Parser/printgrammar.c')
-rw-r--r-- | Parser/printgrammar.c | 70 |
1 files changed, 37 insertions, 33 deletions
diff --git a/Parser/printgrammar.c b/Parser/printgrammar.c index f6aa2cc..00a8d47 100644 --- a/Parser/printgrammar.c +++ b/Parser/printgrammar.c @@ -1,10 +1,44 @@ /* Print a bunch of C initializers that represent a grammar */ -#include <stdio.h> - -#include "PROTO.h" +#include "pgenheaders.h" #include "grammar.h" +/* Forward */ +static void printarcs PROTO((int, dfa *, FILE *)); +static void printstates PROTO((grammar *, FILE *)); +static void printdfas PROTO((grammar *, FILE *)); +static void printlabels PROTO((grammar *, FILE *)); + +void +printgrammar(g, fp) + grammar *g; + FILE *fp; +{ + fprintf(fp, "#include \"pgenheaders.h\"\n"); + fprintf(fp, "#include \"grammar.h\"\n"); + printdfas(g, fp); + printlabels(g, fp); + fprintf(fp, "grammar gram = {\n"); + fprintf(fp, "\t%d,\n", g->g_ndfas); + fprintf(fp, "\tdfas,\n"); + fprintf(fp, "\t{%d, labels},\n", g->g_ll.ll_nlabels); + fprintf(fp, "\t%d\n", g->g_start); + fprintf(fp, "};\n"); +} + +void +printnonterminals(g, fp) + grammar *g; + FILE *fp; +{ + dfa *d; + int i; + + d = g->g_dfa; + for (i = g->g_ndfas; --i >= 0; d++) + fprintf(fp, "#define %s %d\n", d->d_name, d->d_type); +} + static void printarcs(i, d, fp) int i; @@ -89,33 +123,3 @@ printlabels(g, fp) } fprintf(fp, "};\n"); } - -void -printgrammar(g, fp) - grammar *g; - FILE *fp; -{ - fprintf(fp, "#include \"PROTO.h\"\n"); - fprintf(fp, "#include \"grammar.h\"\n"); - printdfas(g, fp); - printlabels(g, fp); - fprintf(fp, "grammar gram = {\n"); - fprintf(fp, "\t%d,\n", g->g_ndfas); - fprintf(fp, "\tdfas,\n"); - fprintf(fp, "\t{%d, labels},\n", g->g_ll.ll_nlabels); - fprintf(fp, "\t%d\n", g->g_start); - fprintf(fp, "};\n"); -} - -void -printnonterminals(g, fp) - grammar *g; - FILE *fp; -{ - dfa *d; - int i; - - d = g->g_dfa; - for (i = g->g_ndfas; --i >= 0; d++) - fprintf(fp, "#define %s %d\n", d->d_name, d->d_type); -} |