Don't use preprocesser for special tree state values
This commit is contained in:
parent
da1bc038e5
commit
7f1c5f7568
3 changed files with 12 additions and 8 deletions
|
|
@ -136,7 +136,7 @@ static bool ts_parser__can_reuse(TSParser *self, int head, TSTree *subtree) {
|
|||
|
||||
TSStateId state = ts_stack_top_state(self->stack, head);
|
||||
|
||||
if (subtree->lex_state != TSTREE_STATE_INDEPENDENT) {
|
||||
if (subtree->lex_state != TS_TREE_STATE_INDEPENDENT) {
|
||||
TSStateId lex_state = self->language->lex_states[state];
|
||||
if (subtree->lex_state != lex_state)
|
||||
return false;
|
||||
|
|
@ -338,7 +338,7 @@ static bool ts_parser__reduce(TSParser *self, int head, TSSymbol symbol,
|
|||
TSStateId state;
|
||||
TSStateId top_state = ts_stack_top_state(self->stack, new_head);
|
||||
|
||||
if (parent->parse_state != TSTREE_STATE_ERROR)
|
||||
if (parent->parse_state != TS_TREE_STATE_ERROR)
|
||||
parent->parse_state = top_state;
|
||||
|
||||
if (extra) {
|
||||
|
|
@ -384,7 +384,7 @@ static bool ts_parser__reduce(TSParser *self, int head, TSSymbol symbol,
|
|||
TSTree **parent = vector_get(&self->reduce_parents, i);
|
||||
(*parent)->fragile_left = true;
|
||||
(*parent)->fragile_right = true;
|
||||
(*parent)->parse_state = TSTREE_STATE_ERROR;
|
||||
(*parent)->parse_state = TS_TREE_STATE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
#include <assert.h>
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -6,6 +7,9 @@
|
|||
#include "runtime/tree.h"
|
||||
#include "runtime/length.h"
|
||||
|
||||
TSStateId TS_TREE_STATE_INDEPENDENT = USHRT_MAX;
|
||||
TSStateId TS_TREE_STATE_ERROR = USHRT_MAX - 1;
|
||||
|
||||
TSTree *ts_tree_make_leaf(TSSymbol sym, TSLength padding, TSLength size,
|
||||
TSSymbolMetadata metadata) {
|
||||
TSTree *result = malloc(sizeof(TSTree));
|
||||
|
|
@ -20,8 +24,8 @@ TSTree *ts_tree_make_leaf(TSSymbol sym, TSLength padding, TSLength size,
|
|||
.padding = padding,
|
||||
.visible = metadata.visible,
|
||||
.named = metadata.named,
|
||||
.lex_state = TSTREE_STATE_INDEPENDENT,
|
||||
.parse_state = TSTREE_STATE_INDEPENDENT,
|
||||
.lex_state = TS_TREE_STATE_INDEPENDENT,
|
||||
.parse_state = TS_TREE_STATE_INDEPENDENT,
|
||||
};
|
||||
|
||||
if (sym == ts_builtin_sym_error) {
|
||||
|
|
@ -88,7 +92,7 @@ void ts_tree_set_children(TSTree *self, size_t child_count, TSTree **children) {
|
|||
|
||||
if (child->symbol == ts_builtin_sym_error) {
|
||||
self->fragile_left = self->fragile_right = true;
|
||||
self->parse_state = TSTREE_STATE_ERROR;
|
||||
self->parse_state = TS_TREE_STATE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ extern "C" {
|
|||
#include "tree_sitter/parser.h"
|
||||
#include "runtime/length.h"
|
||||
|
||||
#define TSTREE_STATE_INDEPENDENT (unsigned short)(-1)
|
||||
#define TSTREE_STATE_ERROR (TSTREE_STATE_INDEPENDENT - 1)
|
||||
extern TSStateId TS_TREE_STATE_INDEPENDENT;
|
||||
extern TSStateId TS_TREE_STATE_ERROR;
|
||||
|
||||
struct TSTree {
|
||||
struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue