WIP restart of lib

This commit is contained in:
Maix0 2024-06-24 00:20:08 +02:00
parent e239bfa0ea
commit 9f6b90d596
36 changed files with 15951 additions and 2 deletions

364
parser/gen/funcs.h Normal file
View file

@ -0,0 +1,364 @@
CaptureListPool capture_list_pool_new(void);
CaptureList *capture_list_pool_get_mut(CaptureListPool *self, uint16_t id);
CaptureQuantifiers capture_quantifiers_new(void);
Iterator iterator_new(TreeCursor *cursor, const Subtree *tree, const TSLanguage *language);
IteratorComparison iterator_compare(const Iterator *old_iter, const Iterator *new_iter);
Length iterator_end_position(Iterator *self);
Length iterator_start_position(Iterator *self);
QueryStep query_step__new(TSSymbol symbol, uint16_t depth, bool is_immediate);
StackNode *stack_node_new(StackNode *previous_node, Subtree subtree, bool is_pending, TSStateId state, StackNodeArray *pool);
StackSliceArray stack__iter(Stack *self, StackVersion version, StackCallback callback, void *payload, int goal_subtree_count);
Stream stream_new(const char *string, uint32_t length);
SymbolTable symbol_table_new(void);
TSQuantifier capture_quantifier_for_id(const CaptureQuantifiers *self, uint16_t id);
TSQuantifier quantifier_add(TSQuantifier left, TSQuantifier right);
TSQuantifier quantifier_join(TSQuantifier left, TSQuantifier right);
TSQuantifier quantifier_mul(TSQuantifier left, TSQuantifier right);
bool capture_list_pool_is_empty(const CaptureListPool *self);
bool iterator_descend(Iterator *self, uint32_t goal_position);
bool iterator_done(Iterator *self);
bool iterator_tree_is_visible(const Iterator *self);
bool stack__subtree_is_equivalent(Subtree left, Subtree right);
bool stream_advance(Stream *self);
bool stream_is_ident_start(Stream *self);
const CaptureList *capture_list_pool_get(const CaptureListPool *self, uint16_t id);
const Length LENGTH_MAX;
const Length LENGTH_UNDEFINED;
const TSQueryError PARENT_DONE;
const TSRange DEFAULT_RANGE;
const TSSymbol WILDCARD_SYMBOL;
const char *symbol_table_name_for_id(const SymbolTable *self, uint16_t id, uint32_t *length);
const char *const ROOT_FIELD;
const int32_t BYTE_ORDER_MARK;
const int32_t TS_DECODE_ERROR;
const uint16_t NONE;
const uint16_t PATTERN_DONE_MARKER;
const unsigned MAX_COST_DIFFERENCE;
const unsigned MAX_SUMMARY_DEPTH;
const unsigned MAX_VERSION_COUNT;
const unsigned MAX_VERSION_COUNT_OVERFLOW;
const unsigned OP_COUNT_PER_TIMEOUT_CHECK;
int symbol_table_id_for_name(const SymbolTable *self, const char *name, uint32_t length);
uint16_t capture_list_pool_acquire(CaptureListPool *self);
uint16_t symbol_table_insert_name(SymbolTable *self, const char *name, uint32_t length);
uint32_t stack__subtree_node_count(Subtree subtree);
uint32_t stream_offset(Stream *self);
unsigned analysis_state__recursion_depth(const AnalysisState *self);
void capture_list_pool_delete(CaptureListPool *self);
void capture_list_pool_release(CaptureListPool *self, uint16_t id);
void capture_list_pool_reset(CaptureListPool *self);
void capture_quantifiers_add_all(CaptureQuantifiers *self, CaptureQuantifiers *quantifiers);
void capture_quantifiers_add_for_id(CaptureQuantifiers *self, uint16_t id, TSQuantifier quantifier);
void capture_quantifiers_clear(CaptureQuantifiers *self);
void capture_quantifiers_delete(CaptureQuantifiers *self);
void capture_quantifiers_join_all(CaptureQuantifiers *self, CaptureQuantifiers *quantifiers);
void capture_quantifiers_mul(CaptureQuantifiers *self, TSQuantifier quantifier);
void capture_quantifiers_replace(CaptureQuantifiers *self, CaptureQuantifiers *quantifiers);
void iterator_advance(Iterator *self);
void iterator_ascend(Iterator *self);
void iterator_get_visible_state(const Iterator *self, Subtree *tree, TSSymbol *alias_symbol, uint32_t *start_byte);
void query_step__add_capture(QueryStep *self, uint16_t capture_id);
void query_step__remove_capture(QueryStep *self, uint16_t capture_id);
void stack_head_delete(StackHead *self, StackNodeArray *pool, SubtreePool *subtree_pool);
void stack_node_add_link(StackNode *self, StackLink link, SubtreePool *subtree_pool);
void stack_node_release(StackNode *self, StackNodeArray *pool, SubtreePool *subtree_pool);
void stack_node_retain(StackNode *self);
void stream_reset(Stream *self, const char *input);
void stream_scan_identifier(Stream *stream);
void stream_skip_whitespace(Stream *self);
void symbol_table_delete(SymbolTable *self);
void *ts_calloc_default(size_t count, size_t size);
uint32_t ts_decode_ascii(const uint8_t *string, uint32_t length, int32_t *code_point);
int _ts_dup(int file_descriptor);
ExternalScannerState ts_external_scanner_state_copy(const ExternalScannerState *self);
const char *ts_external_scanner_state_data(const ExternalScannerState *self);
void ts_external_scanner_state_delete(ExternalScannerState *self);
bool ts_external_scanner_state_eq(const ExternalScannerState *self, const char *buffer, unsigned length);
void ts_external_scanner_state_init(ExternalScannerState *self, const char *data, unsigned length);
const TSLanguage *ts_language_copy(const TSLanguage *self);
void ts_language_delete(const TSLanguage *self);
uint32_t ts_language_field_count(const TSLanguage *self);
TSFieldId ts_language_field_id_for_name(const TSLanguage *self, const char *name, uint32_t name_length);
const char *ts_language_field_name_for_id(const TSLanguage *self, TSFieldId id);
TSStateId ts_language_next_state(const TSLanguage *self, TSStateId state, TSSymbol symbol);
TSSymbol ts_language_public_symbol(const TSLanguage *self, TSSymbol symbol);
uint32_t ts_language_state_count(const TSLanguage *self);
uint32_t ts_language_symbol_count(const TSLanguage *self);
TSSymbol ts_language_symbol_for_name(const TSLanguage *self, const char *string, uint32_t length, bool is_named);
TSSymbolMetadata ts_language_symbol_metadata(const TSLanguage *self, TSSymbol symbol);
const char *ts_language_symbol_name(const TSLanguage *self, TSSymbol symbol);
TSSymbolType ts_language_symbol_type(const TSLanguage *self, TSSymbol symbol);
void ts_language_table_entry(const TSLanguage *self, TSStateId state, TSSymbol symbol, TableEntry *result);
uint32_t ts_language_version(const TSLanguage *self);
void ts_lexer__advance(TSLexer *_self, bool skip);
void ts_lexer__clear_chunk(Lexer *self);
void ts_lexer__do_advance(Lexer *self, bool skip);
bool ts_lexer__eof(const TSLexer *_self);
void ts_lexer__get_chunk(Lexer *self);
uint32_t ts_lexer__get_column(TSLexer *_self);
void ts_lexer__get_lookahead(Lexer *self);
bool ts_lexer__is_at_included_range_start(const TSLexer *_self);
void ts_lexer__mark_end(TSLexer *_self);
void ts_lexer_advance_to_end(Lexer *self);
void ts_lexer_delete(Lexer *self);
void ts_lexer_finish(Lexer *self, uint32_t *lookahead_end_byte);
void ts_lexer_goto(Lexer *self, Length position);
TSRange *ts_lexer_included_ranges(const Lexer *self, uint32_t *count);
void ts_lexer_init(Lexer *self);
void ts_lexer_mark_end(Lexer *self);
void ts_lexer_reset(Lexer *self, Length position);
bool ts_lexer_set_included_ranges(Lexer *self, const TSRange *ranges, uint32_t count);
void ts_lexer_set_input(Lexer *self, TSInput input);
void ts_lexer_start(Lexer *self);
TSSymbol ts_lookahead_iterator_current_symbol(const TSLookaheadIterator *self);
const char *ts_lookahead_iterator_current_symbol_name(const TSLookaheadIterator *self);
void ts_lookahead_iterator_delete(TSLookaheadIterator *self);
const TSLanguage *ts_lookahead_iterator_language(const TSLookaheadIterator *self);
TSLookaheadIterator *ts_lookahead_iterator_new(const TSLanguage *self, TSStateId state);
bool ts_lookahead_iterator_next(TSLookaheadIterator *self);
bool ts_lookahead_iterator_reset(TSLookaheadIterator *self, const TSLanguage *language, TSStateId state);
bool ts_lookahead_iterator_reset_state(TSLookaheadIterator *self, TSStateId state);
void *ts_malloc_default(size_t size);
TSNode ts_node_child(TSNode self, uint32_t child_index);
TSNode ts_node_child_by_field_id(TSNode self, TSFieldId field_id);
TSNode ts_node_child_by_field_name(TSNode self, const char *name, uint32_t name_length);
TSNode ts_node_child_containing_descendant(TSNode self, TSNode subnode);
uint32_t ts_node_child_count(TSNode self);
uint32_t ts_node_descendant_count(TSNode self);
TSNode ts_node_descendant_for_byte_range(TSNode self, uint32_t start, uint32_t end);
TSNode ts_node_descendant_for_point_range(TSNode self, TSPoint start, TSPoint end);
void ts_node_edit(TSNode *self, const TSInputEdit *edit);
uint32_t ts_node_end_byte(TSNode self);
TSPoint ts_node_end_point(TSNode self);
bool ts_node_eq(TSNode self, TSNode other);
const char *ts_node_field_name_for_child(TSNode self, uint32_t child_index);
TSNode ts_node_first_child_for_byte(TSNode self, uint32_t byte);
TSNode ts_node_first_named_child_for_byte(TSNode self, uint32_t byte);
TSSymbol ts_node_grammar_symbol(TSNode self);
const char *ts_node_grammar_type(TSNode self);
bool ts_node_has_changes(TSNode self);
bool ts_node_has_error(TSNode self);
bool ts_node_is_error(TSNode self);
bool ts_node_is_extra(TSNode self);
bool ts_node_is_missing(TSNode self);
bool ts_node_is_named(TSNode self);
bool ts_node_is_null(TSNode self);
const TSLanguage *ts_node_language(TSNode self);
TSNode ts_node_named_child(TSNode self, uint32_t child_index);
uint32_t ts_node_named_child_count(TSNode self);
TSNode ts_node_named_descendant_for_byte_range(TSNode self, uint32_t start, uint32_t end);
TSNode ts_node_named_descendant_for_point_range(TSNode self, TSPoint start, TSPoint end);
TSNode ts_node_new(const TSTree *tree, const Subtree *subtree, Length position, TSSymbol alias);
TSNode ts_node_next_named_sibling(TSNode self);
TSStateId ts_node_next_parse_state(TSNode self);
TSNode ts_node_next_sibling(TSNode self);
TSNode ts_node_parent(TSNode self);
TSStateId ts_node_parse_state(TSNode self);
TSNode ts_node_prev_named_sibling(TSNode self);
TSNode ts_node_prev_sibling(TSNode self);
uint32_t ts_node_start_byte(TSNode self);
TSPoint ts_node_start_point(TSNode self);
char *ts_node_string(TSNode self);
TSSymbol ts_node_symbol(TSNode self);
const char *ts_node_type(TSNode self);
void ts_parser__accept(TSParser *self, StackVersion version, Subtree lookahead);
bool ts_parser__advance(TSParser *self, StackVersion version, bool allow_node_reuse);
bool ts_parser__better_version_exists(TSParser *self, StackVersion version, bool is_in_error, unsigned cost);
void ts_parser__breakdown_lookahead(TSParser *self, Subtree *lookahead, TSStateId state, ReusableNode *reusable_node);
bool ts_parser__breakdown_top_of_stack(TSParser *self, StackVersion version);
bool ts_parser__call_keyword_lex_fn(TSParser *self, TSLexMode lex_mode);
bool ts_parser__call_main_lex_fn(TSParser *self, TSLexMode lex_mode);
bool ts_parser__can_reuse_first_leaf(TSParser *self, TSStateId state, Subtree tree, TableEntry *table_entry);
ErrorComparison ts_parser__compare_versions(TSParser *self, ErrorStatus a, ErrorStatus b);
unsigned ts_parser__condense_stack(TSParser *self);
bool ts_parser__do_all_potential_reductions(TSParser *self, StackVersion starting_version, TSSymbol lookahead_symbol);
void ts_parser__external_scanner_create(TSParser *self);
void ts_parser__external_scanner_deserialize(TSParser *self, Subtree external_token);
void ts_parser__external_scanner_destroy(TSParser *self);
bool ts_parser__external_scanner_scan(TSParser *self, TSStateId external_lex_state);
unsigned ts_parser__external_scanner_serialize(TSParser *self);
Subtree ts_parser__get_cached_token(TSParser *self, TSStateId state, size_t position, Subtree last_external_token, TableEntry *table_entry);
void ts_parser__handle_error(TSParser *self, StackVersion version, Subtree lookahead);
bool ts_parser__has_included_range_difference(const TSParser *self, uint32_t start_position, uint32_t end_position);
Subtree ts_parser__lex(TSParser *self, StackVersion version, TSStateId parse_state);
void ts_parser__log(TSParser *self);
void ts_parser__recover(TSParser *self, StackVersion version, Subtree lookahead);
bool ts_parser__recover_to_state(TSParser *self, StackVersion version, unsigned depth, TSStateId goal_state);
StackVersion ts_parser__reduce(TSParser *self, StackVersion version, TSSymbol symbol, uint32_t count, int dynamic_precedence, uint16_t production_id, bool is_fragile, bool end_of_non_terminal_extra);
Subtree ts_parser__reuse_node(TSParser *self, StackVersion version, TSStateId *state, uint32_t position, Subtree last_external_token, TableEntry *table_entry);
bool ts_parser__select_children(TSParser *self, Subtree left, const SubtreeArray *children);
bool ts_parser__select_tree(TSParser *self, Subtree left, Subtree right);
void ts_parser__set_cached_token(TSParser *self, uint32_t byte_index, Subtree last_external_token, Subtree token);
void ts_parser__shift(TSParser *self, StackVersion version, TSStateId state, Subtree lookahead, bool extra);
ErrorStatus ts_parser__version_status(TSParser *self, StackVersion version);
const size_t *ts_parser_cancellation_flag(const TSParser *self);
void ts_parser_delete(TSParser *self);
bool ts_parser_has_outstanding_parse(TSParser *self);
const TSRange *ts_parser_included_ranges(const TSParser *self, uint32_t *count);
const TSLanguage *ts_parser_language(const TSParser *self);
TSLogger ts_parser_logger(const TSParser *self);
TSParser *ts_parser_new(void);
TSTree *ts_parser_parse(TSParser *self, const TSTree *old_tree, TSInput input);
TSTree *ts_parser_parse_string(TSParser *self, const TSTree *old_tree, const char *string, uint32_t length);
TSTree *ts_parser_parse_string_encoding(TSParser *self, const TSTree *old_tree, const char *string, uint32_t length, TSInputEncoding encoding);
void ts_parser_print_dot_graphs(TSParser *self, int fd);
void ts_parser_reset(TSParser *self);
void ts_parser_set_cancellation_flag(TSParser *self, const size_t *flag);
bool ts_parser_set_included_ranges(TSParser *self, const TSRange *ranges, uint32_t count);
bool ts_parser_set_language(TSParser *self, const TSLanguage *language);
void ts_parser_set_logger(TSParser *self, TSLogger logger);
void ts_parser_set_timeout_micros(TSParser *self, uint64_t timeout_micros);
void ts_parser_set_wasm_store(TSParser *self, TSWasmStore *store);
TSWasmStore *ts_parser_take_wasm_store(TSParser *self);
uint64_t ts_parser_timeout_micros(const TSParser *self);
void ts_query__add_negated_fields(TSQuery *self, uint16_t step_index, TSFieldId *field_ids, uint16_t field_count);
bool ts_query__analyze_patterns(TSQuery *self, unsigned *error_offset);
TSQueryError ts_query__parse_pattern(TSQuery *self, Stream *stream, uint32_t depth, bool is_immediate, CaptureQuantifiers *capture_quantifiers);
TSQueryError ts_query__parse_predicate(TSQuery *self, Stream *stream);
TSQueryError ts_query__parse_string_literal(TSQuery *self, Stream *stream);
void ts_query__perform_analysis(TSQuery *self, const AnalysisSubgraphArray *subgraphs, QueryAnalysis *analysis);
bool ts_query__step_is_fallible(const TSQuery *self, uint16_t step_index);
uint32_t ts_query_capture_count(const TSQuery *self);
const char *ts_query_capture_name_for_id(const TSQuery *self, uint32_t index, uint32_t *length);
TSQuantifier ts_query_capture_quantifier_for_id(const TSQuery *self, uint32_t pattern_index, uint32_t capture_index);
void ts_query_cursor__add_state(TSQueryCursor *self, const PatternEntry *pattern);
void ts_query_cursor__capture(TSQueryCursor *self, QueryState *state, QueryStep *step, TSNode node);
void ts_query_cursor__compare_captures(TSQueryCursor *self, QueryState *left_state, QueryState *right_state, bool *left_contains_right, bool *right_contains_left);
int ts_query_cursor__compare_nodes(TSNode left, TSNode right);
QueryState *ts_query_cursor__copy_state(TSQueryCursor *self, QueryState **state_ref);
bool ts_query_cursor__first_in_progress_capture(TSQueryCursor *self, uint32_t *state_index, uint32_t *byte_offset, uint32_t *pattern_index, bool *root_pattern_guaranteed);
CaptureList *ts_query_cursor__prepare_to_capture(TSQueryCursor *self, QueryState *state, unsigned state_index_to_preserve);
void ts_query_cursor_delete(TSQueryCursor *self);
bool ts_query_cursor_did_exceed_match_limit(const TSQueryCursor *self);
void ts_query_cursor_exec(TSQueryCursor *self, const TSQuery *query, TSNode node);
uint32_t ts_query_cursor_match_limit(const TSQueryCursor *self);
TSQueryCursor *ts_query_cursor_new(void);
bool ts_query_cursor_next_capture(TSQueryCursor *self, TSQueryMatch *match, uint32_t *capture_index);
bool ts_query_cursor_next_match(TSQueryCursor *self, TSQueryMatch *match);
void ts_query_cursor_remove_match(TSQueryCursor *self, uint32_t match_id);
void ts_query_cursor_set_byte_range(TSQueryCursor *self, uint32_t start_byte, uint32_t end_byte);
void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit);
void ts_query_cursor_set_max_start_depth(TSQueryCursor *self, uint32_t max_start_depth);
void ts_query_cursor_set_point_range(TSQueryCursor *self, TSPoint start_point, TSPoint end_point);
void ts_query_delete(TSQuery *self);
void ts_query_disable_capture(TSQuery *self, const char *name, uint32_t length);
void ts_query_disable_pattern(TSQuery *self, uint32_t pattern_index);
bool ts_query_is_pattern_guaranteed_at_step(const TSQuery *self, uint32_t byte_offset);
bool ts_query_is_pattern_non_local(const TSQuery *self, uint32_t pattern_index);
bool ts_query_is_pattern_rooted(const TSQuery *self, uint32_t pattern_index);
TSQuery *ts_query_new(const TSLanguage *language, const char *source, uint32_t source_len, uint32_t *error_offset, TSQueryError *error_type);
uint32_t ts_query_pattern_count(const TSQuery *self);
const TSQueryPredicateStep *ts_query_predicates_for_pattern(const TSQuery *self, uint32_t pattern_index, uint32_t *step_count);
uint32_t ts_query_start_byte_for_pattern(const TSQuery *self, uint32_t pattern_index);
uint32_t ts_query_string_count(const TSQuery *self);
const char *ts_query_string_value_for_id(const TSQuery *self, uint32_t index, uint32_t *length);
void ts_range_array_add(TSRangeArray *self, Length start, Length end);
void ts_range_array_get_changed_ranges(const TSRange *old_ranges, unsigned old_range_count, const TSRange *new_ranges, unsigned new_range_count, TSRangeArray *differences);
bool ts_range_array_intersects(const TSRangeArray *self, unsigned start_index, uint32_t start_byte, uint32_t end_byte);
void *ts_realloc_default(void *buffer, size_t size);
void ts_set_allocator(void *(*new_malloc)(void), void *(*new_calloc)(void), void *(*new_realloc)(void), void (*new_free)(void));
void ts_stack__add_slice(Stack *self, StackVersion original_version, StackNode *node, SubtreeArray *subtrees);
StackVersion ts_stack__add_version(Stack *self, StackVersion original_version, StackNode *node);
bool ts_stack_can_merge(Stack *self, StackVersion version1, StackVersion version2);
void ts_stack_clear(Stack *self);
StackVersion ts_stack_copy_version(Stack *self, StackVersion version);
void ts_stack_delete(Stack *self);
int ts_stack_dynamic_precedence(Stack *self, StackVersion version);
unsigned ts_stack_error_cost(const Stack *self, StackVersion version);
StackSummary *ts_stack_get_summary(Stack *self, StackVersion version);
void ts_stack_halt(Stack *self, StackVersion version);
bool ts_stack_has_advanced_since_error(const Stack *self, StackVersion version);
bool ts_stack_is_active(const Stack *self, StackVersion version);
bool ts_stack_is_halted(const Stack *self, StackVersion version);
bool ts_stack_is_paused(const Stack *self, StackVersion version);
Subtree ts_stack_last_external_token(const Stack *self, StackVersion version);
bool ts_stack_merge(Stack *self, StackVersion version1, StackVersion version2);
Stack *ts_stack_new(SubtreePool *subtree_pool);
unsigned ts_stack_node_count_since_error(const Stack *self, StackVersion version);
void ts_stack_pause(Stack *self, StackVersion version, Subtree lookahead);
StackSliceArray ts_stack_pop_all(Stack *self, StackVersion version);
StackSliceArray ts_stack_pop_count(Stack *self, StackVersion version, uint32_t count);
SubtreeArray ts_stack_pop_error(Stack *self, StackVersion version);
StackSliceArray ts_stack_pop_pending(Stack *self, StackVersion version);
Length ts_stack_position(const Stack *self, StackVersion version);
bool ts_stack_print_dot_graph(Stack *self, const TSLanguage *language, FILE *f);
void ts_stack_push(Stack *self, StackVersion version, Subtree subtree, bool pending, TSStateId state);
void ts_stack_record_summary(Stack *self, StackVersion version, unsigned max_depth);
void ts_stack_remove_version(Stack *self, StackVersion version);
void ts_stack_renumber_version(Stack *self, StackVersion v1, StackVersion v2);
Subtree ts_stack_resume(Stack *self, StackVersion version);
void ts_stack_set_last_external_token(Stack *self, StackVersion version, Subtree token);
TSStateId ts_stack_state(const Stack *self, StackVersion version);
void ts_stack_swap_versions(Stack *self, StackVersion v1, StackVersion v2);
uint32_t ts_stack_version_count(const Stack *self);
const char *ts_string_input_read(void *_self, uint32_t byte, TSPoint point, uint32_t *length);
void ts_subtree__compress(MutableSubtree self, unsigned count, const TSLanguage *language, MutableSubtreeArray *stack);
void ts_subtree__print_dot_graph(const Subtree *self, uint32_t start_offset, const TSLanguage *language, TSSymbol alias_symbol, FILE *f);
size_t ts_subtree__write_char_to_string(char *str, size_t n, int32_t chr);
size_t ts_subtree__write_to_string(Subtree self, char *string, size_t limit, const TSLanguage *language, bool include_all, TSSymbol alias_symbol, bool alias_is_named, const char *field_name);
void ts_subtree_array_clear(SubtreePool *pool, SubtreeArray *self);
void ts_subtree_array_copy(SubtreeArray self, SubtreeArray *dest);
void ts_subtree_array_delete(SubtreePool *pool, SubtreeArray *self);
void ts_subtree_array_remove_trailing_extras(SubtreeArray *self, SubtreeArray *destination);
void ts_subtree_array_reverse(SubtreeArray *self);
void ts_subtree_balance(Subtree self, SubtreePool *pool, const TSLanguage *language);
MutableSubtree ts_subtree_clone(Subtree self);
int ts_subtree_compare(Subtree left, Subtree right, SubtreePool *pool);
Subtree ts_subtree_edit(Subtree self, const TSInputEdit *input_edit, SubtreePool *pool);
const ExternalScannerState *ts_subtree_external_scanner_state(Subtree self);
bool ts_subtree_external_scanner_state_eq(Subtree self, Subtree other);
unsigned ts_subtree_get_changed_ranges(const Subtree *old_tree, const Subtree *new_tree, TreeCursor *cursor1, TreeCursor *cursor2, const TSLanguage *language, const TSRangeArray *included_range_differences, TSRange **ranges);
bool ts_subtree_has_trailing_empty_descendant(Subtree self, Subtree other);
Subtree ts_subtree_last_external_token(Subtree tree);
MutableSubtree ts_subtree_make_mut(SubtreePool *pool, Subtree self);
Subtree ts_subtree_new_error(SubtreePool *pool, int32_t lookahead_char, Length padding, Length size, uint32_t bytes_scanned, TSStateId parse_state, const TSLanguage *language);
Subtree ts_subtree_new_error_node(SubtreeArray *children, bool extra, const TSLanguage *language);
Subtree ts_subtree_new_leaf(SubtreePool *pool, TSSymbol symbol, Length padding, Length size, uint32_t lookahead_bytes, TSStateId parse_state, bool has_external_tokens, bool depends_on_column, bool is_keyword, const TSLanguage *language);
Subtree ts_subtree_new_missing_leaf(SubtreePool *pool, TSSymbol symbol, Length padding, uint32_t lookahead_bytes, const TSLanguage *language);
MutableSubtree ts_subtree_new_node(TSSymbol symbol, SubtreeArray *children, unsigned production_id, const TSLanguage *language);
SubtreeHeapData *ts_subtree_pool_allocate(SubtreePool *self);
void ts_subtree_pool_delete(SubtreePool *self);
void ts_subtree_pool_free(SubtreePool *self, SubtreeHeapData *tree);
SubtreePool ts_subtree_pool_new(uint32_t capacity);
void ts_subtree_print_dot_graph(Subtree self, const TSLanguage *language, FILE *f);
void ts_subtree_release(SubtreePool *pool, Subtree self);
void ts_subtree_retain(Subtree self);
void ts_subtree_set_symbol(MutableSubtree *self, TSSymbol symbol, const TSLanguage *language);
char *ts_subtree_string(Subtree self, TSSymbol alias_symbol, bool alias_is_named, const TSLanguage *language, bool include_all);
void ts_subtree_summarize_children(MutableSubtree self, const TSLanguage *language);
TSTree *ts_tree_copy(const TSTree *self);
TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *_cursor);
uint32_t ts_tree_cursor_current_depth(const TSTreeCursor *_self);
uint32_t ts_tree_cursor_current_descendant_index(const TSTreeCursor *_self);
TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *_self);
const char *ts_tree_cursor_current_field_name(const TSTreeCursor *_self);
TSNode ts_tree_cursor_current_node(const TSTreeCursor *_self);
void ts_tree_cursor_current_status(const TSTreeCursor *_self, TSFieldId *field_id, bool *has_later_siblings, bool *has_later_named_siblings, bool *can_have_later_siblings_with_this_field, TSSymbol *supertypes, unsigned *supertype_count);
void ts_tree_cursor_delete(TSTreeCursor *_self);
void ts_tree_cursor_goto_descendant(TSTreeCursor *_self, uint32_t goal_descendant_index);
bool ts_tree_cursor_goto_first_child(TSTreeCursor *self);
int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *self, uint32_t goal_byte);
int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self, TSPoint goal_point);
TreeCursorStep ts_tree_cursor_goto_first_child_internal(TSTreeCursor *_self);
bool ts_tree_cursor_goto_last_child(TSTreeCursor *self);
TreeCursorStep ts_tree_cursor_goto_last_child_internal(TSTreeCursor *_self);
bool ts_tree_cursor_goto_next_sibling(TSTreeCursor *self);
TreeCursorStep ts_tree_cursor_goto_next_sibling_internal(TSTreeCursor *_self);
bool ts_tree_cursor_goto_parent(TSTreeCursor *_self);
bool ts_tree_cursor_goto_previous_sibling(TSTreeCursor *self);
TreeCursorStep ts_tree_cursor_goto_previous_sibling_internal(TSTreeCursor *_self);
TreeCursorStep ts_tree_cursor_goto_sibling_internal(TSTreeCursor *_self, bool (*advance)(CursorChildIterator *, TreeCursorEntry *, bool *));
void ts_tree_cursor_init(TreeCursor *self, TSNode node);
TSTreeCursor ts_tree_cursor_new(TSNode node);
TSNode ts_tree_cursor_parent_node(const TSTreeCursor *_self);
void ts_tree_cursor_reset(TSTreeCursor *_self, TSNode node);
void ts_tree_cursor_reset_to(TSTreeCursor *_dst, const TSTreeCursor *_src);
void ts_tree_delete(TSTree *self);
void ts_tree_edit(TSTree *self, const TSInputEdit *edit);
TSRange *ts_tree_get_changed_ranges(const TSTree *old_tree, const TSTree *new_tree, uint32_t *length);
TSRange *ts_tree_included_ranges(const TSTree *self, uint32_t *length);
const TSLanguage *ts_tree_language(const TSTree *self);
TSTree *ts_tree_new(Subtree root, const TSLanguage *language, const TSRange *included_ranges, unsigned included_range_count);
void ts_tree_print_dot_graph(const TSTree *self, int file_descriptor);
TSNode ts_tree_root_node(const TSTree *self);
TSNode ts_tree_root_node_with_offset(const TSTree *self, uint32_t offset_bytes, TSPoint offset_extent);

935
parser/gen/types.h Normal file
View file

@ -0,0 +1,935 @@
#include <stdint.h>
#include <stdio.h>
typedef uint16_t TSStateId;
typedef uint16_t TSSymbol;
typedef uint16_t TSFieldId;
typedef struct TSLanguage TSLanguage;
typedef struct TSParser TSParser;
typedef struct TSTree TSTree;
typedef struct TSQuery TSQuery;
typedef struct TSQueryCursor TSQueryCursor;
typedef struct TSLookaheadIterator TSLookaheadIterator;
typedef enum TSInputEncoding
{
TSInputEncodingUTF8,
TSInputEncodingUTF16,
} TSInputEncoding;
typedef enum TSSymbolType
{
TSSymbolTypeRegular,
TSSymbolTypeAnonymous,
TSSymbolTypeAuxiliary,
} TSSymbolType;
typedef struct TSPoint
{
uint32_t row;
uint32_t column;
} TSPoint;
typedef struct TSRange
{
TSPoint start_point;
TSPoint end_point;
uint32_t start_byte;
uint32_t end_byte;
} TSRange;
typedef struct TSInput
{
void *payload;
const char *(*read)(void *payload, uint32_t byte_index, TSPoint position, uint32_t *bytes_read);
TSInputEncoding encoding;
} TSInput;
typedef enum TSLogType
{
TSLogTypeParse,
TSLogTypeLex,
} TSLogType;
typedef struct TSLogger
{
void *payload;
void (*log)(void *payload, TSLogType log_type, const char *buffer);
} TSLogger;
typedef struct TSInputEdit
{
uint32_t start_byte;
uint32_t old_end_byte;
uint32_t new_end_byte;
TSPoint start_point;
TSPoint old_end_point;
TSPoint new_end_point;
} TSInputEdit;
typedef struct TSNode
{
uint32_t context[4];
const void *id;
const TSTree *tree;
} TSNode;
typedef struct TSTreeCursor
{
const void *tree;
const void *id;
uint32_t context[3];
} TSTreeCursor;
typedef struct TSQueryCapture
{
TSNode node;
uint32_t index;
} TSQueryCapture;
typedef enum TSQuantifier
{
TSQuantifierZero = 0,
TSQuantifierZeroOrOne,
TSQuantifierZeroOrMore,
TSQuantifierOne,
TSQuantifierOneOrMore,
} TSQuantifier;
typedef struct TSQueryMatch
{
uint32_t id;
uint16_t pattern_index;
uint16_t capture_count;
const TSQueryCapture *captures;
} TSQueryMatch;
typedef enum TSQueryPredicateStepType
{
TSQueryPredicateStepTypeDone,
TSQueryPredicateStepTypeCapture,
TSQueryPredicateStepTypeString,
} TSQueryPredicateStepType;
typedef struct TSQueryPredicateStep
{
TSQueryPredicateStepType type;
uint32_t value_id;
} TSQueryPredicateStep;
typedef enum TSQueryError
{
TSQueryErrorNone = 0,
TSQueryErrorSyntax,
TSQueryErrorNodeType,
TSQueryErrorField,
TSQueryErrorCapture,
TSQueryErrorStructure,
TSQueryErrorLanguage,
} TSQueryError;
typedef struct wasm_engine_t TSWasmEngine;
typedef struct TSWasmStore TSWasmStore;
typedef enum
{
TSWasmErrorKindNone = 0,
TSWasmErrorKindParse,
TSWasmErrorKindCompile,
TSWasmErrorKindInstantiate,
TSWasmErrorKindAllocate,
} TSWasmErrorKind;
typedef struct
{
TSWasmErrorKind kind;
char *message;
} TSWasmError;
typedef struct
{
void *contents;
uint32_t size;
uint32_t capacity;
} Array;
typedef struct
{
uint32_t bytes;
TSPoint extent;
} Length;
typedef struct
{
TSFieldId field_id;
uint8_t child_index;
_Bool inherited;
} TSFieldMapEntry;
typedef struct
{
uint16_t index;
uint16_t length;
} TSFieldMapSlice;
typedef struct
{
_Bool visible;
_Bool named;
_Bool supertype;
} TSSymbolMetadata;
typedef struct TSLexer TSLexer;
struct TSLexer
{
int32_t lookahead;
TSSymbol result_symbol;
void (*advance)(TSLexer *, _Bool);
void (*mark_end)(TSLexer *);
uint32_t (*get_column)(TSLexer *);
_Bool (*is_at_included_range_start)(const TSLexer *);
_Bool (*eof)(const TSLexer *);
};
typedef enum
{
TSParseActionTypeShift,
TSParseActionTypeReduce,
TSParseActionTypeAccept,
TSParseActionTypeRecover,
} TSParseActionType;
typedef union {
struct
{
uint8_t type;
TSStateId state;
_Bool extra;
_Bool repetition;
} shift;
struct
{
uint8_t type;
uint8_t child_count;
TSSymbol symbol;
int16_t dynamic_precedence;
uint16_t production_id;
} reduce;
uint8_t type;
} TSParseAction;
typedef struct
{
uint16_t lex_state;
uint16_t external_lex_state;
} TSLexMode;
typedef union {
TSParseAction action;
struct
{
uint8_t count;
_Bool reusable;
} entry;
} TSParseActionEntry;
typedef struct
{
int32_t start;
int32_t end;
} TSCharacterRange;
struct TSLanguage
{
uint32_t version;
uint32_t symbol_count;
uint32_t alias_count;
uint32_t token_count;
uint32_t external_token_count;
uint32_t state_count;
uint32_t large_state_count;
uint32_t production_id_count;
uint32_t field_count;
uint16_t max_alias_sequence_length;
const uint16_t *parse_table;
const uint16_t *small_parse_table;
const uint32_t *small_parse_table_map;
const TSParseActionEntry *parse_actions;
const char *const *symbol_names;
const char *const *field_names;
const TSFieldMapSlice *field_map_slices;
const TSFieldMapEntry *field_map_entries;
const TSSymbolMetadata *symbol_metadata;
const TSSymbol *public_symbol_map;
const uint16_t *alias_map;
const TSSymbol *alias_sequences;
const TSLexMode *lex_modes;
_Bool (*lex_fn)(TSLexer *, TSStateId);
_Bool (*keyword_lex_fn)(TSLexer *, TSStateId);
TSSymbol keyword_capture_token;
struct
{
const _Bool *states;
const TSSymbol *symbol_map;
void *(*create)(void);
void (*destroy)(void *);
_Bool (*scan)(void *, TSLexer *, const _Bool *symbol_whitelist);
unsigned (*serialize)(void *, char *);
void (*deserialize)(void *, const char *, unsigned);
} external_scanner;
const TSStateId *primary_state_ids;
};
typedef struct
{
union {
char *long_data;
char short_data[24];
};
uint32_t length;
} ExternalScannerState;
typedef struct SubtreeInlineData SubtreeInlineData;
struct SubtreeInlineData
{
_Bool is_inline : 1;
_Bool visible : 1;
_Bool named : 1;
_Bool extra : 1;
_Bool has_changes : 1;
_Bool is_missing : 1;
_Bool is_keyword : 1;
uint8_t symbol;
uint16_t parse_state;
uint8_t padding_columns;
uint8_t padding_rows : 4;
uint8_t lookahead_bytes : 4;
uint8_t padding_bytes;
uint8_t size_bytes;
};
typedef struct
{
volatile uint32_t ref_count;
Length padding;
Length size;
uint32_t lookahead_bytes;
uint32_t error_cost;
uint32_t child_count;
TSSymbol symbol;
TSStateId parse_state;
_Bool visible : 1;
_Bool named : 1;
_Bool extra : 1;
_Bool fragile_left : 1;
_Bool fragile_right : 1;
_Bool has_changes : 1;
_Bool has_external_tokens : 1;
_Bool has_external_scanner_state_change : 1;
_Bool depends_on_column : 1;
_Bool is_missing : 1;
_Bool is_keyword : 1;
union {
struct
{
uint32_t visible_child_count;
uint32_t named_child_count;
uint32_t visible_descendant_count;
int32_t dynamic_precedence;
uint16_t repeat_depth;
uint16_t production_id;
struct
{
TSSymbol symbol;
TSStateId parse_state;
} first_leaf;
};
ExternalScannerState external_scanner_state;
int32_t lookahead_char;
};
} SubtreeHeapData;
typedef union {
SubtreeInlineData data;
const SubtreeHeapData *ptr;
} Subtree;
typedef union {
SubtreeInlineData data;
SubtreeHeapData *ptr;
} MutableSubtree;
typedef struct
{
Subtree *contents;
uint32_t size;
uint32_t capacity;
} SubtreeArray;
typedef struct
{
MutableSubtree *contents;
uint32_t size;
uint32_t capacity;
} MutableSubtreeArray;
typedef struct
{
MutableSubtreeArray free_trees;
MutableSubtreeArray tree_stack;
} SubtreePool;
typedef struct
{
const Subtree *subtree;
Length position;
uint32_t child_index;
uint32_t structural_child_index;
uint32_t descendant_index;
} TreeCursorEntry;
typedef struct
{
const TSTree *tree;
struct
{
TreeCursorEntry *contents;
uint32_t size;
uint32_t capacity;
} stack;
TSSymbol root_alias_symbol;
} TreeCursor;
typedef enum
{
TreeCursorStepNone,
TreeCursorStepHidden,
TreeCursorStepVisible,
} TreeCursorStep;
typedef struct
{
TSRange *contents;
uint32_t size;
uint32_t capacity;
} TSRangeArray;
typedef struct
{
const TSParseAction *actions;
uint32_t action_count;
_Bool is_reusable;
} TableEntry;
typedef struct
{
const TSLanguage *language;
const uint16_t *data;
const uint16_t *group_end;
TSStateId state;
uint16_t table_value;
uint16_t section_index;
uint16_t group_count;
_Bool is_small_state;
const TSParseAction *actions;
TSSymbol symbol;
TSStateId next_state;
uint16_t action_count;
} LookaheadIterator;
typedef struct
{
TreeCursor cursor;
const TSLanguage *language;
unsigned visible_depth;
_Bool in_padding;
} Iterator;
typedef enum
{
IteratorDiffers,
IteratorMayDiffer,
IteratorMatches,
} IteratorComparison;
typedef struct
{
TSLexer data;
Length current_position;
Length token_start_position;
Length token_end_position;
TSRange *included_ranges;
const char *chunk;
TSInput input;
TSLogger logger;
uint32_t included_range_count;
uint32_t current_included_range_index;
uint32_t chunk_start;
uint32_t chunk_size;
uint32_t lookahead_size;
_Bool did_get_column;
char debug_buffer[1024];
} Lexer;
typedef struct
{
const Subtree *child;
const Subtree *parent;
Length position;
TSSymbol alias_symbol;
} ParentCacheEntry;
struct TSTree
{
Subtree root;
const TSLanguage *language;
TSRange *included_ranges;
unsigned included_range_count;
};
typedef struct
{
Subtree parent;
const TSTree *tree;
Length position;
uint32_t child_index;
uint32_t structural_child_index;
const TSSymbol *alias_sequence;
} NodeChildIterator;
typedef uint64_t TSDuration;
typedef uint64_t TSClock;
typedef struct
{
uint32_t count;
TSSymbol symbol;
int dynamic_precedence;
unsigned short production_id;
} ReduceAction;
typedef struct
{
ReduceAction *contents;
uint32_t size;
uint32_t capacity;
} ReduceActionSet;
typedef struct
{
Subtree tree;
uint32_t child_index;
uint32_t byte_offset;
} StackEntry;
typedef struct
{
struct
{
StackEntry *contents;
uint32_t size;
uint32_t capacity;
} stack;
Subtree last_external_token;
} ReusableNode;
typedef struct Stack Stack;
typedef unsigned StackVersion;
typedef struct
{
SubtreeArray subtrees;
StackVersion version;
} StackSlice;
typedef struct
{
StackSlice *contents;
uint32_t size;
uint32_t capacity;
} StackSliceArray;
typedef struct
{
Length position;
unsigned depth;
TSStateId state;
} StackSummaryEntry;
typedef struct
{
StackSummaryEntry *contents;
uint32_t size;
uint32_t capacity;
} StackSummary;
typedef void (*StackIterateCallback)(void *, TSStateId, uint32_t);
typedef int __gwchar_t;
typedef struct
{
long int quot;
long int rem;
} imaxdiv_t;
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
long int tm_gmtoff;
const char *tm_zone;
};
typedef struct
{
Subtree token;
Subtree last_external_token;
uint32_t byte_index;
} TokenCache;
struct TSParser
{
Lexer lexer;
Stack *stack;
SubtreePool tree_pool;
const TSLanguage *language;
ReduceActionSet reduce_actions;
Subtree finished_tree;
SubtreeArray trailing_extras;
SubtreeArray trailing_extras2;
SubtreeArray scratch_trees;
TokenCache token_cache;
ReusableNode reusable_node;
void *external_scanner_payload;
FILE *dot_graph_file;
TSClock end_clock;
TSDuration timeout_duration;
unsigned accept_count;
unsigned operation_count;
const volatile size_t *cancellation_flag;
Subtree old_tree;
TSRangeArray included_range_differences;
unsigned included_range_difference_index;
_Bool has_scanner_error;
};
typedef struct
{
unsigned cost;
unsigned node_count;
int dynamic_precedence;
_Bool is_in_error;
} ErrorStatus;
typedef enum
{
ErrorComparisonTakeLeft,
ErrorComparisonPreferLeft,
ErrorComparisonNone,
ErrorComparisonPreferRight,
ErrorComparisonTakeRight,
} ErrorComparison;
typedef struct
{
const char *string;
uint32_t length;
} TSStringInput;
typedef struct
{
const char *input;
const char *start;
const char *end;
int32_t next;
uint8_t next_size;
} Stream;
typedef struct
{
TSSymbol symbol;
TSSymbol supertype_symbol;
TSFieldId field;
uint16_t capture_ids[3];
uint16_t depth;
uint16_t alternative_index;
uint16_t negated_field_list_id;
_Bool is_named : 1;
_Bool is_immediate : 1;
_Bool is_last_child : 1;
_Bool is_pass_through : 1;
_Bool is_dead_end : 1;
_Bool alternative_is_immediate : 1;
_Bool contains_captures : 1;
_Bool root_pattern_guaranteed : 1;
_Bool parent_pattern_guaranteed : 1;
} QueryStep;
typedef struct
{
uint32_t offset;
uint32_t length;
} Slice;
typedef struct
{
struct
{
char *contents;
uint32_t size;
uint32_t capacity;
} characters;
struct
{
Slice *contents;
uint32_t size;
uint32_t capacity;
} slices;
} SymbolTable;
typedef struct
{
uint8_t *contents;
uint32_t size;
uint32_t capacity;
} CaptureQuantifiers;
typedef struct
{
uint16_t step_index;
uint16_t pattern_index;
_Bool is_rooted;
} PatternEntry;
typedef struct
{
Slice steps;
Slice predicate_steps;
uint32_t start_byte;
_Bool is_non_local;
} QueryPattern;
typedef struct
{
uint32_t byte_offset;
uint16_t step_index;
} StepOffset;
typedef struct
{
uint32_t id;
uint32_t capture_list_id;
uint16_t start_depth;
uint16_t step_index;
uint16_t pattern_index;
uint16_t consumed_capture_count : 12;
_Bool seeking_immediate_match : 1;
_Bool has_in_progress_alternatives : 1;
_Bool dead : 1;
_Bool needs_parent : 1;
} QueryState;
typedef struct
{
TSQueryCapture *contents;
uint32_t size;
uint32_t capacity;
} CaptureList;
typedef struct
{
struct
{
CaptureList *contents;
uint32_t size;
uint32_t capacity;
} list;
CaptureList empty_list;
uint32_t max_capture_list_count;
uint32_t free_capture_list_count;
} CaptureListPool;
typedef struct
{
TSStateId parse_state;
TSSymbol parent_symbol;
uint16_t child_index;
TSFieldId field_id : 15;
_Bool done : 1;
} AnalysisStateEntry;
typedef struct
{
AnalysisStateEntry stack[8];
uint16_t depth;
uint16_t step_index;
TSSymbol root_symbol;
} AnalysisState;
typedef struct
{
AnalysisState **contents;
uint32_t size;
uint32_t capacity;
} AnalysisStateSet;
typedef struct
{
AnalysisStateSet states;
AnalysisStateSet next_states;
AnalysisStateSet deeper_states;
AnalysisStateSet state_pool;
struct
{
uint16_t *contents;
uint32_t size;
uint32_t capacity;
} final_step_indices;
struct
{
TSSymbol *contents;
uint32_t size;
uint32_t capacity;
} finished_parent_symbols;
_Bool did_abort;
} QueryAnalysis;
typedef struct
{
TSStateId state;
uint16_t production_id;
uint8_t child_index : 7;
_Bool done : 1;
} AnalysisSubgraphNode;
typedef struct
{
TSSymbol symbol;
struct
{
TSStateId *contents;
uint32_t size;
uint32_t capacity;
} start_states;
struct
{
AnalysisSubgraphNode *contents;
uint32_t size;
uint32_t capacity;
} nodes;
} AnalysisSubgraph;
typedef struct
{
AnalysisSubgraph *contents;
uint32_t size;
uint32_t capacity;
} AnalysisSubgraphArray;
typedef struct
{
TSStateId *contents;
} StatePredecessorMap;
struct TSQuery
{
SymbolTable captures;
SymbolTable predicate_values;
struct
{
CaptureQuantifiers *contents;
uint32_t size;
uint32_t capacity;
} capture_quantifiers;
struct
{
QueryStep *contents;
uint32_t size;
uint32_t capacity;
} steps;
struct
{
PatternEntry *contents;
uint32_t size;
uint32_t capacity;
} pattern_map;
struct
{
TSQueryPredicateStep *contents;
uint32_t size;
uint32_t capacity;
} predicate_steps;
struct
{
QueryPattern *contents;
uint32_t size;
uint32_t capacity;
} patterns;
struct
{
StepOffset *contents;
uint32_t size;
uint32_t capacity;
} step_offsets;
struct
{
TSFieldId *contents;
uint32_t size;
uint32_t capacity;
} negated_fields;
struct
{
char *contents;
uint32_t size;
uint32_t capacity;
} string_buffer;
struct
{
TSSymbol *contents;
uint32_t size;
uint32_t capacity;
} repeat_symbols_with_rootless_patterns;
const TSLanguage *language;
uint16_t wildcard_root_pattern_count;
};
struct TSQueryCursor
{
const TSQuery *query;
TSTreeCursor cursor;
struct
{
QueryState *contents;
uint32_t size;
uint32_t capacity;
} states;
struct
{
QueryState *contents;
uint32_t size;
uint32_t capacity;
} finished_states;
CaptureListPool capture_list_pool;
uint32_t depth;
uint32_t max_start_depth;
uint32_t start_byte;
uint32_t end_byte;
TSPoint start_point;
TSPoint end_point;
uint32_t next_state_id;
_Bool on_visible_node;
_Bool ascending;
_Bool halted;
_Bool did_exceed_match_limit;
};
typedef struct StackNode StackNode;
typedef struct
{
StackNode *node;
Subtree subtree;
_Bool is_pending;
} StackLink;
struct StackNode
{
TSStateId state;
Length position;
StackLink links[8];
short unsigned int link_count;
uint32_t ref_count;
unsigned error_cost;
unsigned node_count;
int dynamic_precedence;
};
typedef struct
{
StackNode *node;
SubtreeArray subtrees;
uint32_t subtree_count;
_Bool is_pending;
} StackIterator;
typedef struct
{
StackNode **contents;
uint32_t size;
uint32_t capacity;
} StackNodeArray;
typedef enum
{
StackStatusActive,
StackStatusPaused,
StackStatusHalted,
} StackStatus;
typedef struct
{
StackNode *node;
StackSummary *summary;
unsigned node_count_at_last_error;
Subtree last_external_token;
Subtree lookahead_when_paused;
StackStatus status;
} StackHead;
struct Stack
{
struct
{
StackHead *contents;
uint32_t size;
uint32_t capacity;
} heads;
StackSliceArray slices;
struct
{
StackIterator *contents;
uint32_t size;
uint32_t capacity;
} iterators;
StackNodeArray node_pool;
StackNode *base_node;
SubtreePool *subtree_pool;
};
typedef unsigned StackAction;
enum
{
StackActionNone,
StackActionStop = 1,
StackActionPop = 2,
};
typedef StackAction (*StackCallback)(void *, const StackIterator *);
typedef struct
{
StackSummary *summary;
unsigned max_depth;
} SummarizeStackSession;
typedef struct
{
Length start;
Length old_end;
Length new_end;
} Edit;
typedef struct
{
Subtree parent;
const TSTree *tree;
Length position;
uint32_t child_index;
uint32_t structural_child_index;
uint32_t descendant_index;
const TSSymbol *alias_sequence;
} CursorChildIterator;