From 5145bba53dfa8530e7e525e28b60f753ff43e1c2 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Sat, 12 Apr 2014 20:16:16 -0700 Subject: [PATCH] Silence missing-initializer warnings for gcc --- examples/parsers/arithmetic.c | 19 ++++++++++++------- examples/parsers/golang.c | 5 +++++ examples/parsers/javascript.c | 5 +++++ examples/parsers/json.c | 5 +++++ include/tree_sitter/parser.h | 7 ------- src/compiler/generate_code/c_code.cc | 7 ++++++- 6 files changed, 33 insertions(+), 15 deletions(-) diff --git a/examples/parsers/arithmetic.c b/examples/parsers/arithmetic.c index 604fca4b..1e389e6b 100644 --- a/examples/parsers/arithmetic.c +++ b/examples/parsers/arithmetic.c @@ -530,6 +530,9 @@ LEX_STATES = { [133] = 26, }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" + PARSE_TABLE = { [0] = { [ts_sym__operand1] = SHIFT(1), @@ -549,7 +552,7 @@ PARSE_TABLE = { [1] = { [ts_aux_sym_token3] = SHIFT(2), [ts_aux_sym_token4] = SHIFT(100), - [ts_builtin_sym_end] = REDUCE(ts_sym_difference, 1), + [ts_builtin_sym_end] = REDUCE(ts_sym_sum, 1), }, [2] = { [ts_sym__operand1] = SHIFT(3), @@ -569,7 +572,7 @@ PARSE_TABLE = { [4] = { [ts_aux_sym_token5] = SHIFT(5), [ts_aux_sym_token6] = SHIFT(85), - [ts_builtin_sym_end] = REDUCE(ts_sym_product, 1), + [ts_builtin_sym_end] = REDUCE(ts_sym_quotient, 1), }, [5] = { [ts_sym__operand2] = SHIFT(6), @@ -617,7 +620,7 @@ PARSE_TABLE = { [ts_builtin_sym_error] = SHIFT(78), }, [12] = { - [ts_aux_sym_token2] = REDUCE(ts_sym_difference, 1), + [ts_aux_sym_token2] = REDUCE(ts_sym_sum, 1), [ts_aux_sym_token3] = SHIFT(13), [ts_aux_sym_token4] = SHIFT(76), }, @@ -687,9 +690,9 @@ PARSE_TABLE = { [ts_builtin_sym_error] = SHIFT(54), }, [23] = { - [ts_aux_sym_token2] = REDUCE(ts_sym_quotient, 1), + [ts_aux_sym_token2] = REDUCE(ts_sym_product, 1), [ts_aux_sym_token3] = REDUCE(ts_sym_quotient, 1), - [ts_aux_sym_token4] = REDUCE(ts_sym_product, 1), + [ts_aux_sym_token4] = REDUCE(ts_sym_quotient, 1), [ts_aux_sym_token5] = SHIFT(24), [ts_aux_sym_token6] = SHIFT(52), }, @@ -1208,11 +1211,11 @@ PARSE_TABLE = { [ts_builtin_sym_end] = REDUCE(ts_sym_difference, 3), }, [102] = { - [ts_aux_sym_token3] = REDUCE(ts_sym_quotient, 1), + [ts_aux_sym_token3] = REDUCE(ts_sym_product, 1), [ts_aux_sym_token4] = REDUCE(ts_sym_quotient, 1), [ts_aux_sym_token5] = SHIFT(103), [ts_aux_sym_token6] = SHIFT(117), - [ts_builtin_sym_end] = REDUCE(ts_sym_quotient, 1), + [ts_builtin_sym_end] = REDUCE(ts_sym_product, 1), }, [103] = { [ts_sym__operand2] = SHIFT(104), @@ -1435,4 +1438,6 @@ PARSE_TABLE = { }, }; +#pragma GCC diagnostic pop + EXPORT_PARSER(ts_parser_arithmetic); diff --git a/examples/parsers/golang.c b/examples/parsers/golang.c index 45f9c5e6..03ef0f33 100644 --- a/examples/parsers/golang.c +++ b/examples/parsers/golang.c @@ -1304,6 +1304,9 @@ LEX_STATES = { [195] = 75, }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" + PARSE_TABLE = { [0] = { [ts_sym__package] = SHIFT(1), @@ -2429,4 +2432,6 @@ PARSE_TABLE = { }, }; +#pragma GCC diagnostic pop + EXPORT_PARSER(ts_parser_golang); diff --git a/examples/parsers/javascript.c b/examples/parsers/javascript.c index 729fadd3..88fdea19 100644 --- a/examples/parsers/javascript.c +++ b/examples/parsers/javascript.c @@ -2686,6 +2686,9 @@ LEX_STATES = { [603] = 140, }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" + PARSE_TABLE = { [0] = { [ts_sym__break] = SHIFT(1), @@ -8843,4 +8846,6 @@ PARSE_TABLE = { }, }; +#pragma GCC diagnostic pop + EXPORT_PARSER(ts_parser_javascript); diff --git a/examples/parsers/json.c b/examples/parsers/json.c index abd63746..61ee7adf 100644 --- a/examples/parsers/json.c +++ b/examples/parsers/json.c @@ -424,6 +424,9 @@ LEX_STATES = { [59] = 0, }; +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wmissing-field-initializers" + PARSE_TABLE = { [0] = { [ts_sym_array] = SHIFT(1), @@ -738,4 +741,6 @@ PARSE_TABLE = { }, }; +#pragma GCC diagnostic pop + EXPORT_PARSER(ts_parser_json); diff --git a/include/tree_sitter/parser.h b/include/tree_sitter/parser.h index a37696fc..6f6e1ad3 100644 --- a/include/tree_sitter/parser.h +++ b/include/tree_sitter/parser.h @@ -9,13 +9,6 @@ extern "C" { #include #include "tree_sitter/runtime.h" -/* - * Parsing DSL Macros - * - * Generated parser use these macros. They prevent the code generator - * from having too much knowledge of the runtime types and functions. - */ - //#define TS_DEBUG_PARSE //#define TS_DEBUG_LEX diff --git a/src/compiler/generate_code/c_code.cc b/src/compiler/generate_code/c_code.cc index 5e290600..dc337f32 100644 --- a/src/compiler/generate_code/c_code.cc +++ b/src/compiler/generate_code/c_code.cc @@ -239,6 +239,9 @@ namespace tree_sitter { string parse_table_array() { size_t state_id = 0; return join({ + "#pragma GCC diagnostic push", + "#pragma GCC diagnostic ignored \"-Wmissing-field-initializers\"", + "", "PARSE_TABLE = {", indent(join(map_to_string(parse_table.states, [&](ParseState state) { string result = "[" + to_string(state_id++) + "] = {\n"; @@ -246,7 +249,9 @@ namespace tree_sitter { result += indent("[" + symbol_id(pair.first) + "] = " + code_for_parse_action(pair.second) + ",") + "\n"; return result + "},"; }), "\n")), - "};" + "};", + "", + "#pragma GCC diagnostic pop" }); }