Skip to content

Commit 9232f76

Browse files
clear deadwood tables, clear clang warning Wunused-const-variable...
... tables generated for raw parsing are no longer generated for --x-utf8, which is a substantial savings (the raw tables are always 256 columns wide, yet go unused when parsing as UTF-8 as it categorizes input endpoints before the main parsing.) Along with a few other unused static consts, this also clears -Wunused-const-variable on clang; build for clang is now also clean.
1 parent ec87ea1 commit 9232f76

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/emit_c.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4430,7 +4430,6 @@ void emit_c_file(struct indented_printer *ip, struct carburetta_context *cc, str
44304430
}
44314431
free(table);
44324432
ip_printf(ip, "};\n");
4433-
ip_printf(ip, "static const size_t %snum_scan_table_rows_ = %zu;\n", cc_prefix(cc), num_rows);
44344433
ip_printf(ip, "static const size_t %snum_scan_table_grouped_columns_ = %zu;\n", cc_prefix(cc), num_columns);
44354434

44364435
/* Raw encoding map */
@@ -4456,13 +4455,6 @@ void emit_c_file(struct indented_printer *ip, struct carburetta_context *cc, str
44564455
} while (sg != rex->dfa_.symbol_groups_);
44574456
}
44584457

4459-
uint32_t n;
4460-
ip_printf(ip, "static const int %sscan_table_grouped_raw_encoding_[] = {\n", cc_prefix(cc));
4461-
for (n = 0; n < 256; ++n) {
4462-
ip_printf(ip, "%s%d", n ? ", " : "", srmap[n]);
4463-
}
4464-
ip_printf(ip, "\n};\n");
4465-
44664458
/* UTF-8 encoding map */
44674459
struct rex_scanner utf8_scanner;
44684460
rex_init(&utf8_scanner);
@@ -4673,7 +4665,7 @@ void emit_c_file(struct indented_printer *ip, struct carburetta_context *cc, str
46734665
}
46744666
}
46754667

4676-
if (prdg->num_patterns_) {
4668+
if (prdg->num_patterns_ && !cc->utf8_experimental_) {
46774669
ip_printf(ip, "static const size_t %sscan_table_rex[] = {\n", cc_prefix(cc));
46784670
size_t col;
46794671
char column_widths[256 + 4] = {0};
@@ -4894,9 +4886,12 @@ void emit_c_file(struct indented_printer *ip, struct carburetta_context *cc, str
48944886
}
48954887

48964888
ip_printf(ip, "};\n");
4889+
}
48974890

4891+
if (prdg->num_patterns_) {
48984892
ip_printf(ip, "static const size_t %sscan_actions_rex[] = { ", cc_prefix(cc));
48994893
ip_printf(ip, "0"); /* dummy state 0 action */
4894+
struct rex_dfa_node *dn = rex->dfa_.nodes_;
49004895
if (dn) {
49014896
do {
49024897
dn = dn->chain_;
@@ -4913,8 +4908,6 @@ void emit_c_file(struct indented_printer *ip, struct carburetta_context *cc, str
49134908
num_columns = (size_t)(1 + lalr->max_sym_ - lalr->min_sym_);
49144909
ip_printf(ip, "static const int %sminimum_sym = %d;\n", cc_prefix(cc), lalr->min_sym_);
49154910
ip_printf(ip, "static const size_t %snum_columns = %zu;\n", cc_prefix(cc), num_columns);
4916-
ip_printf(ip, "static const size_t %snum_rows = %zu;\n", cc_prefix(cc), (size_t)lalr->nr_states_);
4917-
ip_printf(ip, "static const size_t %snum_productions = %zu;\n", cc_prefix(cc), lalr->nr_productions_);
49184911
ip_printf(ip, "static const int %sparse_table[] = {\n", cc_prefix(cc));
49194912
size_t row, col;
49204913
char *column_widths;

0 commit comments

Comments
 (0)