static void output_base(void) { int i, j; start_int_table("sindex", base[0]); j = 10; for (i = 1; i < nstates; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(base[i]); } end_table(); start_int_table("rindex", base[nstates]); j = 10; for (i = nstates + 1; i < 2 * nstates; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(base[i]); } end_table(); start_int_table("gindex", base[2 * nstates]); j = 10; for (i = 2 * nstates + 1; i < nvectors - 1; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(base[i]); } end_table(); FREE(base); }
static void output_check(void) { int i; int j; start_int_table("check", check[0]); j = 10; for (i = 1; i <= high; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(check[i]); } end_table(); FREE(check); }
static void output_table(void) { int i; int j; ++outline; fprintf(code_file, "#define YYTABLESIZE %d\n", high); start_int_table("table", table[0]); j = 10; for (i = 1; i <= high; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(table[i]); } end_table(); FREE(table); }
static void goto_actions(void) { int i, j, k; state_count = NEW2(nstates, Value_t); k = default_goto(start_symbol + 1); start_int_table("dgoto", k); save_column(start_symbol + 1, k); j = 10; for (i = start_symbol + 2; i < nsyms; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; k = default_goto(i); output_int(k); save_column(i, k); } end_table(); FREE(state_count); }
static void start_str_table(const char *name) { fprintf(output_file, "%sconst char *%s%s[] = {", StaticOrR, "yy", name); output_newline(); }
static void start_str_table(const char *name) { fprintf(output_file, "%sconst char *const %s%s[] = {", StaticOrR, symbol_prefix, name); output_newline(); }
static void output_rule_data(void) { int i; int j; output_YYINT_typedef(output_file); start_int_table("lhs", symbol_value[start_symbol]); j = 10; for (i = 3; i < nrules; i++) { if (j >= 10) { output_newline(); j = 1; } else ++j; output_int(symbol_value[rlhs[i]]); } end_table(); start_int_table("len", 2); j = 10; for (i = 3; i < nrules; i++) { if (j >= 10) { output_newline(); j = 1; } else j++; output_int(rrhs[i + 1] - rrhs[i] - 1); } end_table(); }
void do_output(void) { node *p; for (p=head.next; p!=&head; p=p->next) { if (p->type == TT_NEWLINE) { output_newline(); } else if (p->type == TT_PAREN) { output_paren(p->lojban); } else if (p->type == TT_CMAVO) { output(p->lojban, p->trans, p->selmao); } else if (p->type == TT_BRIVLA) { output(p->lojban, p->trans, "BRIVLA"); } else if (p->type == TT_CMENE) { output(p->lojban, p->trans, "CMENE"); } } }
static void output_accessing_symbols(void) { int i, j; int *translate; if (nstates != 0) { translate = TMALLOC(int, nstates); NO_SPACE(translate); for (i = 0; i < nstates; ++i) { int gsymb = accessing_symbol[i]; translate[i] = symbol_pval[gsymb]; } putl_code(output_file, "#if defined(YYDESTRUCT_CALL) || defined(YYSTYPE_TOSTRING)\n"); /* yystos[] may be unused, depending on compile-time defines */ start_int_table("stos", translate[0]); j = 10; for (i = 1; i < nstates; ++i) { if (j < 10) ++j; else { output_newline(); j = 1; } output_int(translate[i]); } end_table(); FREE(translate); putl_code(output_file, "#endif /* YYDESTRUCT_CALL || YYSTYPE_TOSTRING */\n"); }
static void output_yydefred (void) { int i, j; start_int_table ("defred", (defred[0] ? defred[0] - 2 : 0)); j = 10; for (i = 1; i < nstates; i++) { if (j < 10) ++j; else { output_newline (); j = 1; } output_int ((defred[i] ? defred[i] - 2 : 0)); } end_table (); }
static void output_accessing_symbols(void) { int i, j; int *translate; if (nstates != 0) { translate = TMALLOC(int, nstates); NO_SPACE(translate); for (i = 0; i < nstates; ++i) { int gsymb = accessing_symbol[i]; translate[i] = symbol_pval[gsymb]; } /* yystos[] may be unused, depending on compile-time defines */ start_int_table("stos", translate[0]); j = 10; for (i = 1; i < nstates; ++i) { if (j < 10) ++j; else { output_newline(); j = 1; } output_int(translate[i]); } end_table(); FREE(translate); }
static void output_debug(void) { int i, j, k, max; const char **symnam; const char *s; ++outline; fprintf(code_file, "#define YYFINAL %d\n", final_state); putl_code(code_file, "#ifndef YYDEBUG\n"); ++outline; fprintf(code_file, "#define YYDEBUG %d\n", tflag); putl_code(code_file, "#endif\n"); if (rflag) { fprintf(output_file, "#ifndef YYDEBUG\n"); fprintf(output_file, "#define YYDEBUG %d\n", tflag); fprintf(output_file, "#endif\n"); } max = 0; for (i = 2; i < ntokens; ++i) if (symbol_value[i] > max) max = symbol_value[i]; ++outline; fprintf(code_file, "#define YYMAXTOKEN %d\n", max); symnam = TMALLOC(const char *, max + 1); NO_SPACE(symnam); /* Note that it is not necessary to initialize the element */ /* symnam[max]. */ for (i = 0; i < max; ++i) symnam[i] = 0; for (i = ntokens - 1; i >= 2; --i) symnam[symbol_value[i]] = symbol_name[i]; symnam[0] = "end-of-file"; output_line("#if YYDEBUG"); start_str_table("name"); j = 80; for (i = 0; i <= max; ++i) { if ((s = symnam[i]) != 0) { if (s[0] == '"') { k = 7; while (*++s != '"') { ++k; if (*s == '\\') { k += 2; if (*++s == '\\') ++k; } } j += k; if (j > 80) { output_newline(); j = k; } fprintf(output_file, "\"\\\""); s = symnam[i]; while (*++s != '"') { if (*s == '\\') { fprintf(output_file, "\\\\"); if (*++s == '\\') fprintf(output_file, "\\\\"); else putc(*s, output_file); } else putc(*s, output_file); } fprintf(output_file, "\\\"\","); } else if (s[0] == '\'') { if (s[1] == '"') { j += 7; if (j > 80) { output_newline(); j = 7; } fprintf(output_file, "\"'\\\"'\","); } else { k = 5; while (*++s != '\'') { ++k; if (*s == '\\') { k += 2; if (*++s == '\\') ++k; } } j += k; if (j > 80) { output_newline(); j = k; } fprintf(output_file, "\"'"); s = symnam[i]; while (*++s != '\'') { if (*s == '\\') { fprintf(output_file, "\\\\"); if (*++s == '\\') fprintf(output_file, "\\\\"); else putc(*s, output_file); } else putc(*s, output_file); } fprintf(output_file, "'\","); } } else { k = (int)strlen(s) + 3; j += k; if (j > 80) { output_newline(); j = k; } putc('"', output_file); do { putc(*s, output_file); } while (*++s); fprintf(output_file, "\","); } } else { j += 2; if (j > 80) { output_newline(); j = 2; } fprintf(output_file, "0,"); } } end_table(); FREE(symnam); start_str_table("rule"); for (i = 2; i < nrules; ++i) { fprintf(output_file, "\"%s :", symbol_name[rlhs[i]]); for (j = rrhs[i]; ritem[j] > 0; ++j) { s = symbol_name[ritem[j]]; if (s[0] == '"') { fprintf(output_file, " \\\""); while (*++s != '"') { if (*s == '\\') { if (s[1] == '\\') fprintf(output_file, "\\\\\\\\"); else fprintf(output_file, "\\\\%c", s[1]); ++s; } else putc(*s, output_file); } fprintf(output_file, "\\\""); } else if (s[0] == '\'') { if (s[1] == '"') fprintf(output_file, " '\\\"'"); else if (s[1] == '\\') { if (s[2] == '\\') fprintf(output_file, " '\\\\\\\\"); else fprintf(output_file, " '\\\\%c", s[2]); s += 2; while (*++s != '\'') putc(*s, output_file); putc('\'', output_file); } else fprintf(output_file, " '%c'", s[1]); } else fprintf(output_file, " %s", s); } fprintf(output_file, "\","); output_newline(); } end_table(); output_line("#endif"); }
static void end_table(void) { output_newline(); output_line("};"); }
static void output_line(const char *value) { fputs(value, output_file); output_newline(); }