23 if (self->lexer.logger.log || self->dot_graph_file) { \
24 snprintf(self->lexer.debug_buffer, TREE_SITTER_SERIALIZATION_BUFFER_SIZE, __VA_ARGS__); \
25 ts_parser__log(self); \
28 #define LOG_LOOKAHEAD(symbol_name, size) \
29 if (self->lexer.logger.log || self->dot_graph_file) { \
30 char *buf = self->lexer.debug_buffer; \
31 const char *symbol = symbol_name; \
32 int off = sprintf(buf, "lexed_lookahead sym:"); \
36 && off < TREE_SITTER_SERIALIZATION_BUFFER_SIZE; \
39 switch (symbol[i]) { \
40 case '\t': buf[off++] = '\\'; buf[off++] = 't'; break; \
41 case '\n': buf[off++] = '\\'; buf[off++] = 'n'; break; \
42 case '\v': buf[off++] = '\\'; buf[off++] = 'v'; break; \
43 case '\f': buf[off++] = '\\'; buf[off++] = 'f'; break; \
44 case '\r': buf[off++] = '\\'; buf[off++] = 'r'; break; \
45 case '\\': buf[off++] = '\\'; buf[off++] = '\\'; break; \
46 default: buf[off++] = symbol[i]; break; \
51 TREE_SITTER_SERIALIZATION_BUFFER_SIZE - off, \
55 ts_parser__log(self); \
59 if (self->dot_graph_file) { \
60 ts_stack_print_dot_graph(self->stack, self->language, self->dot_graph_file); \
61 fputs("\n\n", self->dot_graph_file); \
64 #define LOG_TREE(tree) \
65 if (self->dot_graph_file) { \
66 ts_subtree_print_dot_graph(tree, self->language, self->dot_graph_file); \
67 fputs("\n", self->dot_graph_file); \
70 #define SYM_NAME(symbol) ts_language_symbol_name(self->language, symbol)
72 #define TREE_NAME(tree) SYM_NAME(ts_subtree_symbol(tree))
140 if (
byte >= self->length) {
144 *
length =
self->length - byte;
145 return self->string + byte;
152 if (self->lexer.logger.log) {
153 self->lexer.logger.log(
154 self->lexer.logger.payload,
156 self->lexer.debug_buffer
160 if (self->dot_graph_file) {
161 fprintf(self->dot_graph_file,
"graph {\nlabel=\"");
162 for (
char *
c = &self->lexer.debug_buffer[0]; *
c != 0;
c++) {
163 if (*
c ==
'"') fputc(
'\\', self->dot_graph_file);
164 fputc(*
c, self->dot_graph_file);
166 fprintf(self->dot_graph_file,
"\"\n}\n\n");
174 bool did_break_down =
false;
175 bool pending =
false;
179 if (!pop.size)
break;
181 did_break_down =
true;
210 LOG(
"breakdown_top_of_stack tree:%s",
TREE_NAME(parent));
215 return did_break_down;
224 bool did_descend =
false;
246 if (!
a.is_in_error &&
b.is_in_error) {
247 if (
a.cost <
b.cost) {
254 if (
a.is_in_error && !
b.is_in_error) {
255 if (
b.cost <
a.cost) {
262 if (
a.cost <
b.cost) {
270 if (
b.cost <
a.cost) {
311 .is_in_error = is_in_error,
339 if (external_token.
ptr) {
340 self->language->external_scanner.deserialize(
341 self->external_scanner_payload,
346 self->language->external_scanner.deserialize(self->external_scanner_payload,
NULL, 0);
359 TSLexMode leaf_lex_mode =
self->language->lex_modes[leaf_state];
370 memcmp(&leaf_lex_mode, ¤t_lex_mode,
sizeof(
TSLexMode)) == 0 &&
372 leaf_symbol != self->language->keyword_capture_token ||
390 TSLexMode lex_mode =
self->language->lex_modes[parse_state];
392 LOG(
"no_lookahead_after_non_terminal_extra");
403 bool found_external_token =
false;
405 bool skipped_error =
false;
406 bool called_get_column =
false;
407 int32_t first_error_character = 0;
414 Length current_position =
self->lexer.current_position;
416 if (valid_external_tokens) {
418 "lex_external state:%d, row:%u, column:%u",
425 bool found_token =
self->language->external_scanner.scan(
426 self->external_scanner_payload,
428 valid_external_tokens
445 self->lexer.token_end_position.bytes > current_position.
bytes ||
448 found_external_token =
true;
449 called_get_column =
self->lexer.did_get_column;
457 "lex_internal state:%d, row:%u, column:%u",
463 bool found_token =
self->language->lex_fn(&self->lexer.data, lex_mode.
lex_state);
465 if (found_token)
break;
478 if (!skipped_error) {
479 LOG(
"skip_unrecognized_character");
480 skipped_error =
true;
481 error_start_position =
self->lexer.token_start_position;
482 error_end_position =
self->lexer.token_start_position;
483 first_error_character =
self->lexer.data.lookahead;
486 if (self->lexer.current_position.bytes == error_end_position.
bytes) {
487 if (self->lexer.data.eof(&self->lexer.data)) {
491 self->lexer.data.advance(&self->lexer.data,
false);
494 error_end_position =
self->lexer.current_position;
501 uint32_t lookahead_bytes = lookahead_end_byte - error_end_position.
bytes;
504 first_error_character,
517 if (self->lexer.token_end_position.bytes < self->lexer.token_start_position.bytes) {
518 self->lexer.token_start_position =
self->lexer.token_end_position;
521 bool is_keyword =
false;
522 TSSymbol symbol =
self->lexer.data.result_symbol;
523 Length padding =
length_sub(self->lexer.token_start_position, start_position);
525 uint32_t lookahead_bytes = lookahead_end_byte -
self->lexer.token_end_position.bytes;
527 if (found_external_token) {
528 symbol =
self->language->external_scanner.symbol_map[symbol];
529 }
else if (symbol == self->language->keyword_capture_token && symbol != 0) {
530 uint32_t end_byte =
self->lexer.token_end_position.bytes;
534 self->language->keyword_lex_fn(&self->lexer.data, 0) &&
535 self->lexer.token_end_position.bytes == end_byte &&
539 symbol =
self->lexer.data.result_symbol;
550 found_external_token,
556 if (found_external_token) {
557 unsigned length =
self->language->external_scanner.serialize(
558 self->external_scanner_payload,
559 self->lexer.debug_buffer
563 self->lexer.debug_buffer,
609 cache->
token = token;
620 &self->included_range_differences,
621 self->included_range_difference_index,
644 if (byte_offset > position) {
645 LOG(
"before_reusable_node symbol:%s",
TREE_NAME(result));
649 if (byte_offset < position) {
658 LOG(
"reusable_node_has_different_external_scanner_state symbol:%s",
TREE_NAME(result));
663 const char *reason =
NULL;
665 reason =
"has_changes";
669 reason =
"is_missing";
671 reason =
"is_fragile";
673 reason =
"contains_different_included_range";
677 LOG(
"cant_reuse_node_%s tree:%s", reason,
TREE_NAME(result));
690 "cant_reuse_node symbol:%s, first_leaf_symbol:%s",
711 if (!left.
ptr)
return true;
712 if (!right.
ptr)
return false;
725 LOG(
"select_higher_precedence symbol:%s, prec:%u, over_symbol:%s, other_prec:%u",
732 LOG(
"select_higher_precedence symbol:%s, prec:%u, over_symbol:%s, other_prec:%u",
741 switch (comparison) {
760 const SubtreeArray *children
770 &self->scratch_trees,
790 Subtree subtree_to_push = lookahead;
810 int dynamic_precedence,
813 bool end_of_non_terminal_extra
835 removed_version_count++;
836 while (
i + 1 < pop.size) {
848 SubtreeArray children = slice.
subtrees;
852 symbol, &children, production_id, self->language
859 while (
i + 1 < pop.size) {
864 SubtreeArray children = next_slice.
subtrees;
874 array_swap(&self->trailing_extras, &self->trailing_extras2);
876 symbol, &children, production_id, self->language
886 if (end_of_non_terminal_extra && next_state ==
state) {
889 if (is_fragile || pop.size > 1 || initial_version_count > 1) {
901 for (
uint32_t j = 0; j <
self->trailing_extras.size; j++) {
902 ts_stack_push(self->stack, slice_version, self->trailing_extras.contents[j],
false, next_state);
908 removed_version_count++;
916 ? initial_version_count
930 SubtreeArray trees = pop.contents[
i].subtrees;
933 for (
uint32_t j = trees.size - 1; j + 1 > 0; j--) {
934 Subtree tree = trees.contents[j];
955 self->accept_count++;
957 if (self->finished_tree.ptr) {
960 self->finished_tree =
root;
965 self->finished_tree =
root;
980 bool can_shift_lookahead_symbol =
false;
982 for (
unsigned i = 0;
true;
i++) {
984 if (
version >= version_count)
break;
993 if (merged)
continue;
996 bool has_shift_action =
false;
1000 if (lookahead_symbol != 0) {
1001 first_symbol = lookahead_symbol;
1002 end_symbol = lookahead_symbol + 1;
1005 end_symbol =
self->language->token_count;
1008 for (
TSSymbol symbol = first_symbol; symbol < end_symbol; symbol++) {
1016 if (!
action.shift.extra && !
action.shift.repetition) has_shift_action =
true;
1019 if (
action.reduce.child_count > 0)
1021 .symbol = action.reduce.symbol,
1022 .count = action.reduce.child_count,
1023 .dynamic_precedence = action.reduce.dynamic_precedence,
1024 .production_id = action.reduce.production_id,
1034 for (
uint32_t i = 0;
i <
self->reduce_actions.size;
i++) {
1044 if (has_shift_action) {
1045 can_shift_lookahead_symbol =
true;
1049 }
else if (lookahead_symbol != 0) {
1053 if (
version == starting_version) {
1060 return can_shift_lookahead_symbol;
1072 for (
unsigned i = 0;
i < pop.size;
i++) {
1075 if (slice.
version == previous_version) {
1089 if (error_trees.size > 0) {
1090 assert(error_trees.size == 1);
1091 Subtree error_tree = error_trees.contents[0];
1093 if (error_child_count > 0) {
1095 for (
unsigned j = 0; j < error_child_count; j++) {
1111 for (
unsigned j = 0; j <
self->trailing_extras.size; j++) {
1112 Subtree tree =
self->trailing_extras.contents[j];
1116 previous_version = slice.
version;
1127 bool did_recover =
false;
1147 for (
unsigned i = 0;
i <
summary->size;
i++) {
1151 if (
entry.position.bytes == position.
bytes)
continue;
1152 unsigned depth =
entry.depth;
1153 if (node_count_since_error > 0) depth++;
1156 bool would_merge =
false;
1157 for (
unsigned j = 0; j < previous_version_count; j++) {
1166 if (would_merge)
continue;
1170 current_error_cost +
1181 LOG(
"recover_to_previous state:%u, depth:%u",
entry.state, depth);
1255 if (node_count_since_error > 0) {
1263 for (
unsigned i = 1;
i < pop.size;
i++) {
1275 &pop.contents[0].subtrees,
1306 bool did_insert_missing_token =
false;
1308 if (!did_insert_missing_token) {
1312 missing_symbol <
self->language->token_count;
1316 self->language,
state, missing_symbol
1318 if (state_after_missing_symbol == 0 || state_after_missing_symbol ==
state) {
1324 state_after_missing_symbol,
1337 &self->tree_pool, missing_symbol,
1338 padding, lookahead_bytes,
1342 self->stack, version_with_missing_tree,
1343 missing_tree,
false,
1344 state_after_missing_symbol
1348 self, version_with_missing_tree,
1352 "recover_with_missing symbol:%s, state:%u",
1356 did_insert_missing_token =
true;
1364 v = (
v ==
version) ? previous_version_count :
v + 1;
1367 for (
unsigned i = previous_version_count;
i < version_count;
i++) {
1390 bool allow_node_reuse
1396 bool did_reuse =
true;
1401 if (allow_node_reuse) {
1403 self,
version, &
state, position, last_external_token, &table_entry
1409 if (!lookahead.
ptr) {
1412 self,
state, position, last_external_token, &table_entry
1416 bool needs_lex = !lookahead.
ptr;
1423 if (lookahead.
ptr) {
1439 self->operation_count = 0;
1442 self->operation_count == 0 &&
1443 ((self->cancellation_flag &&
atomic_load(self->cancellation_flag)) ||
1461 if (
action.shift.repetition)
break;
1463 if (
action.shift.extra) {
1467 next_state =
action.shift.state;
1468 LOG(
"shift state:%u", next_state);
1483 bool end_of_non_terminal_extra = lookahead.
ptr ==
NULL;
1487 action.reduce.dynamic_precedence,
action.reduce.production_id,
1488 is_fragile, end_of_non_terminal_extra
1491 last_reduction_version = reduction_version;
1527 if (!lookahead.
ptr) {
1552 "switch from_keyword:%s, to_word_token:%s",
1554 SYM_NAME(self->language->keyword_capture_token)
1589 LOG(
"detect_error");
1596 bool made_changes =
false;
1597 unsigned min_error_cost =
UINT_MAX;
1610 min_error_cost = status_i.
cost;
1621 made_changes =
true;
1630 made_changes =
true;
1637 made_changes =
true;
1647 made_changes =
true;
1660 made_changes =
true;
1667 bool has_unpaused_version =
false;
1671 LOG(
"resume version:%u",
i);
1675 has_unpaused_version =
true;
1682 has_unpaused_version =
true;
1692 return min_error_cost;
1713 self->dot_graph_file =
NULL;
1714 self->cancellation_flag =
NULL;
1715 self->timeout_duration = 0;
1717 self->operation_count = 0;
1719 self->included_range_differences = (TSRangeArray)
array_new();
1720 self->included_range_difference_index = 0;
1730 if (self->reduce_actions.contents) {
1733 if (self->included_range_differences.contents) {
1736 if (self->old_tree.ptr) {
1751 return self->language;
1760 if (self->external_scanner_payload && self->language->external_scanner.destroy) {
1761 self->language->external_scanner.destroy(self->external_scanner_payload);
1767 self->external_scanner_payload =
NULL;
1770 self->language = language;
1776 return self->lexer.logger;
1780 self->lexer.logger = logger;
1784 if (self->dot_graph_file) {
1785 fclose(self->dot_graph_file);
1789 self->dot_graph_file = fdopen(
fd,
"a");
1791 self->dot_graph_file =
NULL;
1796 return (
const size_t *)
self->cancellation_flag;
1800 self->cancellation_flag = (
const volatile size_t *)flag;
1824 if (self->language && self->language->external_scanner.deserialize) {
1825 self->language->external_scanner.deserialize(self->external_scanner_payload,
NULL, 0);
1828 if (self->old_tree.ptr) {
1837 if (self->finished_tree.ptr) {
1841 self->accept_count = 0;
1849 if (!self->language || !
input.read)
return NULL;
1854 self->included_range_difference_index = 0;
1857 LOG(
"resume_parsing");
1858 }
else if (old_tree) {
1860 self->old_tree = old_tree->
root;
1863 self->lexer.included_ranges, self->lexer.included_range_count,
1864 &self->included_range_differences
1867 LOG(
"parse_after_edit");
1869 for (
unsigned i = 0;
i <
self->included_range_differences.size;
i++) {
1870 TSRange *
range = &
self->included_range_differences.contents[
i];
1871 LOG(
"different_included_range %u - %u",
range->start_byte,
range->end_byte);
1878 self->operation_count = 0;
1879 if (self->timeout_duration) {
1885 uint32_t position = 0, last_position = 0, version_count = 0;
1893 bool allow_node_reuse = version_count == 1;
1896 "process version:%d, version_count:%u, state:%d, row:%u, col:%u",
1908 if (position > last_position || (
version > 0 && position == last_position)) {
1909 last_position = position;
1920 while (self->included_range_difference_index < self->included_range_differences.size) {
1921 TSRange *
range = &
self->included_range_differences.contents[
self->included_range_difference_index];
1922 if (
range->end_byte <= position) {
1923 self->included_range_difference_index++;
1928 }
while (version_count != 0);
1935 self->finished_tree,
1937 self->lexer.included_ranges,
1938 self->lexer.included_range_count
#define TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION
#define TREE_SITTER_LANGUAGE_VERSION
static RZ_NULLABLE RzILOpBitVector * shift(RzILOpBitVector *val, RZ_NULLABLE RzILOpBool **carry_out, arm_shifter type, RZ_OWN RzILOpBitVector *dist)
#define array_front(self)
#define array_erase(self, index)
#define array_assign(self, other)
#define array_push(self, element)
#define array_reserve(self, new_capacity)
#define array_swap(self, other)
#define array_delete(self)
#define array_clear(self)
#define array_splice(self, index, old_count, new_count, new_contents)
static TSClock clock_null(void)
static TSDuration duration_from_micros(uint64_t micros)
static uint64_t duration_to_micros(TSDuration self)
static bool clock_is_gt(TSClock self, TSClock other)
static TSClock clock_after(TSClock base, TSDuration duration)
static TSClock clock_now(void)
static bool clock_is_null(TSClock self)
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void static offset struct stat static buf void long static basep static whence static length const void static len static semflg const void static shmflg const struct timespec struct timespec static rem const char static group const void length
#define ERROR_COST_PER_SKIPPED_TREE
#define ERROR_COST_PER_SKIPPED_LINE
#define ERROR_COST_PER_SKIPPED_CHAR
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_language_table_entry(const TSLanguage *self, TSStateId state, TSSymbol symbol, TableEntry *result)
static const TSParseAction * ts_language_actions(const TSLanguage *self, TSStateId state, TSSymbol symbol, uint32_t *count)
static bool ts_language_has_reduce_action(const TSLanguage *self, TSStateId state, TSSymbol symbol)
static TSStateId ts_language_next_state(const TSLanguage *self, TSStateId state, TSSymbol symbol)
static bool ts_language_has_actions(const TSLanguage *self, TSStateId state, TSSymbol symbol)
#define ts_builtin_sym_error_repeat
static const bool * ts_language_enabled_external_tokens(const TSLanguage *self, unsigned external_scanner_state)
static Length length_zero(void)
static Length length_sub(Length len1, Length len2)
void ts_lexer_reset(Lexer *self, Length position)
void ts_lexer_finish(Lexer *self, uint32_t *lookahead_end_byte)
void ts_lexer_mark_end(Lexer *self)
void ts_lexer_set_input(Lexer *self, TSInput input)
void ts_lexer_delete(Lexer *self)
void ts_lexer_start(Lexer *self)
void ts_lexer_init(Lexer *self)
TSRange * ts_lexer_included_ranges(const Lexer *self, uint32_t *count)
bool ts_lexer_set_included_ranges(Lexer *self, const TSRange *ranges, uint32_t count)
static const char struct stat static buf struct stat static buf static vhangup int status
assert(limit<=UINT32_MAX/2)
static void ts_reduce_action_set_add(ReduceActionSet *self, ReduceAction new_action)
static void reusable_node_advance(ReusableNode *self)
static uint32_t reusable_node_byte_offset(ReusableNode *self)
static bool reusable_node_descend(ReusableNode *self)
static Subtree reusable_node_tree(ReusableNode *self)
static void reusable_node_advance_past_leaf(ReusableNode *self)
static void reusable_node_delete(ReusableNode *self)
static void reusable_node_reset(ReusableNode *self, Subtree tree)
static void reusable_node_clear(ReusableNode *self)
static ReusableNode reusable_node_new(void)
#define ts_builtin_sym_end
@ TSParseActionTypeAccept
@ TSParseActionTypeRecover
@ TSParseActionTypeReduce
#define ts_builtin_sym_error
#define STACK_VERSION_NONE
int32_t dynamic_precedence
ExternalScannerState external_scanner_state
struct TSLanguage::@436 external_scanner
uint16_t external_lex_state
unsigned included_range_difference_index
const TSLanguage * language
SubtreeArray trailing_extras
const volatile size_t * cancellation_flag
void * external_scanner_payload
SubtreeArray scratch_trees
TSDuration timeout_duration
TSRangeArray included_range_differences
ReusableNode reusable_node
SubtreeArray trailing_extras2
ReduceActionSet reduce_actions
TSRange * included_ranges
unsigned included_range_count
const TSParseAction * actions
Subtree last_external_token
bool ts_stack_can_merge(Stack *self, StackVersion version1, StackVersion version2)
void ts_stack_renumber_version(Stack *self, StackVersion v1, StackVersion v2)
int ts_stack_dynamic_precedence(Stack *self, StackVersion version)
void ts_stack_swap_versions(Stack *self, StackVersion v1, StackVersion v2)
void ts_stack_record_summary(Stack *self, StackVersion version, unsigned max_depth)
StackSummary * ts_stack_get_summary(Stack *self, StackVersion version)
void ts_stack_halt(Stack *self, StackVersion version)
void ts_stack_clear(Stack *self)
bool ts_stack_has_advanced_since_error(const Stack *self, StackVersion version)
void ts_stack_pause(Stack *self, StackVersion version, Subtree lookahead)
Subtree ts_stack_resume(Stack *self, StackVersion version)
uint32_t ts_stack_version_count(const Stack *self)
TSStateId ts_stack_state(const Stack *self, StackVersion version)
bool ts_stack_is_active(const Stack *self, StackVersion version)
Length ts_stack_position(const Stack *self, StackVersion version)
StackSliceArray ts_stack_pop_count(Stack *self, StackVersion version, uint32_t count)
void ts_stack_push(Stack *self, StackVersion version, Subtree subtree, bool pending, TSStateId state)
void ts_stack_remove_version(Stack *self, StackVersion version)
unsigned ts_stack_node_count_since_error(const Stack *self, StackVersion version)
bool ts_stack_merge(Stack *self, StackVersion version1, StackVersion version2)
StackVersion ts_stack_copy_version(Stack *self, StackVersion version)
StackSliceArray ts_stack_pop_pending(Stack *self, StackVersion version)
StackSliceArray ts_stack_pop_all(Stack *self, StackVersion version)
Stack * ts_stack_new(SubtreePool *subtree_pool)
void ts_stack_delete(Stack *self)
bool ts_stack_is_halted(const Stack *self, StackVersion version)
unsigned ts_stack_error_cost(const Stack *self, StackVersion version)
SubtreeArray ts_stack_pop_error(Stack *self, StackVersion version)
Subtree ts_stack_last_external_token(const Stack *self, StackVersion version)
void ts_stack_set_last_external_token(Stack *self, StackVersion version, Subtree token)
bool ts_stack_is_paused(const Stack *self, StackVersion version)
TSTree * ts_tree_new(Subtree root, const TSLanguage *language, const TSRange *included_ranges, unsigned included_range_count)
bool ts_subtree_external_scanner_state_eq(Subtree self, Subtree other)
MutableSubtree ts_subtree_new_node(TSSymbol symbol, SubtreeArray *children, unsigned production_id, const TSLanguage *language)
void ts_subtree_release(SubtreePool *pool, Subtree self)
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_error_node(SubtreeArray *children, bool extra, const TSLanguage *language)
MutableSubtree ts_subtree_make_mut(SubtreePool *pool, Subtree self)
void ts_subtree_retain(Subtree self)
void ts_subtree_array_delete(SubtreePool *pool, SubtreeArray *self)
void ts_subtree_array_remove_trailing_extras(SubtreeArray *self, SubtreeArray *destination)
const char * ts_external_scanner_state_data(const ExternalScannerState *self)
void ts_subtree_set_symbol(MutableSubtree *self, TSSymbol symbol, const TSLanguage *language)
void ts_subtree_balance(Subtree self, SubtreePool *pool, const TSLanguage *language)
Subtree ts_subtree_last_external_token(Subtree tree)
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)
SubtreePool ts_subtree_pool_new(uint32_t capacity)
void ts_external_scanner_state_init(ExternalScannerState *self, const char *data, unsigned length)
int ts_subtree_compare(Subtree left, Subtree right)
Subtree ts_subtree_new_missing_leaf(SubtreePool *pool, TSSymbol symbol, Length padding, uint32_t lookahead_bytes, const TSLanguage *language)
void ts_subtree_array_clear(SubtreePool *pool, SubtreeArray *self)
void ts_subtree_pool_delete(SubtreePool *self)
#define ts_subtree_children(self)
static Subtree ts_subtree_from_mut(MutableSubtree self)
static bool ts_subtree_has_external_tokens(Subtree self)
static Length ts_subtree_total_size(Subtree self)
static uint32_t ts_subtree_total_bytes(Subtree self)
static uint32_t ts_subtree_error_cost(Subtree self)
#define TS_TREE_STATE_NONE
static int32_t ts_subtree_dynamic_precedence(Subtree self)
static bool ts_subtree_extra(Subtree self)
static bool ts_subtree_is_keyword(Subtree self)
static bool ts_subtree_is_error(Subtree self)
static bool ts_subtree_has_changes(Subtree self)
static bool ts_subtree_missing(Subtree self)
static Length ts_subtree_size(Subtree self)
static TSSymbol ts_subtree_leaf_symbol(Subtree self)
static bool ts_subtree_is_fragile(Subtree self)
static TSStateId ts_subtree_parse_state(Subtree self)
static uint32_t ts_subtree_lookahead_bytes(Subtree self)
static uint32_t ts_subtree_child_count(Subtree self)
static void ts_subtree_set_extra(MutableSubtree *self, bool is_extra)
static bool ts_subtree_is_eof(Subtree self)
static TSStateId ts_subtree_leaf_parse_state(Subtree self)
static TSSymbol ts_subtree_symbol(Subtree self)
static size_t atomic_load(const volatile size_t *p)
static const unsigned MAX_VERSION_COUNT_OVERFLOW
TSLogger ts_parser_logger(const TSParser *self)
static const unsigned MAX_COST_DIFFERENCE
static const unsigned MAX_SUMMARY_DEPTH
TSTree * ts_parser_parse(TSParser *self, const TSTree *old_tree, TSInput input)
static Subtree ts_parser__lex(TSParser *self, StackVersion version, TSStateId parse_state)
static Subtree ts_parser__get_cached_token(TSParser *self, TSStateId state, size_t position, Subtree last_external_token, TableEntry *table_entry)
static void ts_parser__accept(TSParser *self, StackVersion version, Subtree lookahead)
@ ErrorComparisonPreferRight
@ ErrorComparisonTakeRight
@ ErrorComparisonTakeLeft
@ ErrorComparisonPreferLeft
static const unsigned OP_COUNT_PER_TIMEOUT_CHECK
static unsigned ts_parser__condense_stack(TSParser *self)
const TSRange * ts_parser_included_ranges(const TSParser *self, uint32_t *count)
void ts_parser_reset(TSParser *self)
static bool ts_parser__breakdown_top_of_stack(TSParser *self, StackVersion version)
static const unsigned MAX_VERSION_COUNT
static void ts_parser__handle_error(TSParser *self, StackVersion version, Subtree lookahead)
static bool ts_parser__can_reuse_first_leaf(TSParser *self, TSStateId state, Subtree tree, TableEntry *table_entry)
static void ts_parser__recover(TSParser *self, StackVersion version, Subtree lookahead)
uint64_t ts_parser_timeout_micros(const TSParser *self)
static bool ts_parser__select_tree(TSParser *self, Subtree left, Subtree right)
static bool ts_parser__advance(TSParser *self, StackVersion version, bool allow_node_reuse)
const size_t * ts_parser_cancellation_flag(const TSParser *self)
void ts_parser_set_timeout_micros(TSParser *self, uint64_t timeout_micros)
static bool ts_parser__recover_to_state(TSParser *self, StackVersion version, unsigned depth, TSStateId goal_state)
static bool ts_parser__do_all_potential_reductions(TSParser *self, StackVersion starting_version, TSSymbol lookahead_symbol)
static void ts_parser__shift(TSParser *self, StackVersion version, TSStateId state, Subtree lookahead, bool extra)
static bool ts_parser__has_included_range_difference(const TSParser *self, uint32_t start_position, uint32_t end_position)
static ErrorComparison ts_parser__compare_versions(TSParser *self, ErrorStatus a, ErrorStatus b)
static void ts_parser__breakdown_lookahead(TSParser *self, Subtree *lookahead, TSStateId state, ReusableNode *reusable_node)
static Subtree ts_parser__reuse_node(TSParser *self, StackVersion version, TSStateId *state, uint32_t position, Subtree last_external_token, TableEntry *table_entry)
static void ts_parser__set_cached_token(TSParser *self, size_t byte_index, Subtree last_external_token, Subtree token)
void ts_parser_set_logger(TSParser *self, TSLogger logger)
#define LOG_LOOKAHEAD(symbol_name, size)
static const char * ts_string_input_read(void *_self, uint32_t byte, TSPoint pt, uint32_t *length)
bool ts_parser_set_language(TSParser *self, const TSLanguage *language)
TSTree * ts_parser_parse_string_encoding(TSParser *self, const TSTree *old_tree, const char *string, uint32_t length, TSInputEncoding encoding)
void ts_parser_set_cancellation_flag(TSParser *self, const size_t *flag)
static ErrorStatus ts_parser__version_status(TSParser *self, StackVersion version)
bool ts_parser_set_included_ranges(TSParser *self, const TSRange *ranges, uint32_t count)
TSParser * ts_parser_new(void)
static void ts_parser__log(TSParser *self)
TSTree * ts_parser_parse_string(TSParser *self, const TSTree *old_tree, const char *string, uint32_t length)
static bool ts_parser__better_version_exists(TSParser *self, StackVersion version, bool is_in_error, unsigned cost)
static void ts_parser__restore_external_scanner(TSParser *self, Subtree external_token)
static bool ts_parser__select_children(TSParser *self, Subtree left, const SubtreeArray *children)
const TSLanguage * ts_parser_language(const TSParser *self)
void ts_parser_print_dot_graphs(TSParser *self, int fd)
void ts_parser_delete(TSParser *self)
static bool ts_parser_has_outstanding_parse(TSParser *self)
static 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)
const SubtreeHeapData * ptr
void error(const char *msg)
static const z80_opcode fd[]
static bool input(void *ud, zip_uint8_t *data, zip_uint64_t length)