diff --git a/cli/src/generate/build_tables/build_parse_table.rs b/cli/src/generate/build_tables/build_parse_table.rs index 0554c06e..729e3f3a 100644 --- a/cli/src/generate/build_tables/build_parse_table.rs +++ b/cli/src/generate/build_tables/build_parse_table.rs @@ -684,8 +684,8 @@ impl<'a> ParseTableBuilder<'a> { child_info.alias_sequence.pop(); } - if item.production.steps.len() > self.parse_table.max_production_length_with_child_info { - self.parse_table.max_production_length_with_child_info = item.production.steps.len() + if item.production.steps.len() > self.parse_table.max_aliased_production_length { + self.parse_table.max_aliased_production_length = item.production.steps.len() } if let Some(index) = self @@ -791,7 +791,7 @@ pub(crate) fn build_parse_table( states: Vec::new(), symbols: Vec::new(), child_infos: Vec::new(), - max_production_length_with_child_info: 0, + max_aliased_production_length: 0, }, field_names_by_hidden_symbol: field_names_by_hidden_symbol(syntax_grammar), } diff --git a/cli/src/generate/render.rs b/cli/src/generate/render.rs index af167a5d..22bf655c 100644 --- a/cli/src/generate/render.rs +++ b/cli/src/generate/render.rs @@ -222,8 +222,8 @@ impl Generator { add_line!(self, "#define FIELD_COUNT {}", self.field_names.len()); add_line!( self, - "#define MAX_CHILD_INFO_PRODUCTION_LENGTH {}", - self.parse_table.max_production_length_with_child_info + "#define MAX_ALIAS_SEQUENCE_LENGTH {}", + self.parse_table.max_aliased_production_length ); add_line!(self, ""); } @@ -357,7 +357,7 @@ impl Generator { fn add_alias_sequences(&mut self) { add_line!( self, - "static TSSymbol ts_alias_sequences[{}][MAX_CHILD_INFO_PRODUCTION_LENGTH] = {{", + "static TSSymbol ts_alias_sequences[{}][MAX_ALIAS_SEQUENCE_LENGTH] = {{", self.parse_table.child_infos.len() ); indent!(self); @@ -912,7 +912,7 @@ impl Generator { add_line!( self, - ".max_child_info_production_length = MAX_CHILD_INFO_PRODUCTION_LENGTH," + ".max_alias_sequence_length = MAX_ALIAS_SEQUENCE_LENGTH," ); add_line!(self, ".lex_fn = ts_lex,"); diff --git a/cli/src/generate/tables.rs b/cli/src/generate/tables.rs index 99adde69..a39ae099 100644 --- a/cli/src/generate/tables.rs +++ b/cli/src/generate/tables.rs @@ -57,7 +57,7 @@ pub(crate) struct ParseTable { pub states: Vec, pub symbols: Vec, pub child_infos: Vec, - pub max_production_length_with_child_info: usize, + pub max_aliased_production_length: usize, } #[derive(Clone, Debug, PartialEq, Eq)] diff --git a/lib/include/tree_sitter/parser.h b/lib/include/tree_sitter/parser.h index 9d25a40f..90ab6200 100644 --- a/lib/include/tree_sitter/parser.h +++ b/lib/include/tree_sitter/parser.h @@ -97,7 +97,7 @@ struct TSLanguage { const TSParseActionEntry *parse_actions; const TSLexMode *lex_modes; const TSSymbol *alias_sequences; - uint16_t max_child_info_production_length; + uint16_t max_alias_sequence_length; bool (*lex_fn)(TSLexer *, TSStateId); bool (*keyword_lex_fn)(TSLexer *, TSStateId); TSSymbol keyword_capture_token; diff --git a/lib/src/language.h b/lib/src/language.h index 908c0646..59c0fadc 100644 --- a/lib/src/language.h +++ b/lib/src/language.h @@ -83,7 +83,7 @@ ts_language_enabled_external_tokens(const TSLanguage *self, static inline const TSSymbol * ts_language_alias_sequence(const TSLanguage *self, uint32_t child_info_id) { return child_info_id > 0 ? - self->alias_sequences + child_info_id * self->max_child_info_production_length : + self->alias_sequences + child_info_id * self->max_alias_sequence_length : NULL; } diff --git a/lib/src/subtree.c b/lib/src/subtree.c index 4c93d6d0..3d588890 100644 --- a/lib/src/subtree.c +++ b/lib/src/subtree.c @@ -914,7 +914,7 @@ void ts_subtree__print_dot_graph(const Subtree *self, uint32_t start_offset, uint32_t child_start_offset = start_offset; uint32_t child_info_offset = - language->max_child_info_production_length * + language->max_alias_sequence_length * ts_subtree_child_info_id(*self); for (uint32_t i = 0, n = ts_subtree_child_count(*self); i < n; i++) { const Subtree *child = &self->ptr->children[i];