Remove halt_on_error API
This commit is contained in:
parent
d06407aca2
commit
7de36a33eb
5 changed files with 8 additions and 77 deletions
|
|
@ -313,13 +313,6 @@ extern "C" {
|
|||
#[doc = " SVG output. You can turn off this logging by passing a negative number."]
|
||||
pub fn ts_parser_print_dot_graphs(self_: *mut TSParser, file: ::std::os::raw::c_int);
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Set whether or not the parser should halt immediately upon detecting an"]
|
||||
#[doc = " error. This will generally result in a syntax tree with an error at the"]
|
||||
#[doc = " root, and one or more partial syntax trees within the error. This behavior"]
|
||||
#[doc = " may not be supported long-term."]
|
||||
pub fn ts_parser_halt_on_error(self_: *mut TSParser, halt: bool);
|
||||
}
|
||||
extern "C" {
|
||||
#[doc = " Create a shallow copy of the syntax tree. This is very fast."]
|
||||
#[doc = ""]
|
||||
|
|
|
|||
|
|
@ -336,14 +336,6 @@ TSLogger ts_parser_logger(const TSParser *self);
|
|||
*/
|
||||
void ts_parser_print_dot_graphs(TSParser *self, int file);
|
||||
|
||||
/**
|
||||
* Set whether or not the parser should halt immediately upon detecting an
|
||||
* error. This will generally result in a syntax tree with an error at the
|
||||
* root, and one or more partial syntax trees within the error. This behavior
|
||||
* may not be supported long-term.
|
||||
*/
|
||||
void ts_parser_halt_on_error(TSParser *self, bool halt);
|
||||
|
||||
/******************/
|
||||
/* Section - Tree */
|
||||
/******************/
|
||||
|
|
|
|||
|
|
@ -71,7 +71,6 @@ struct TSParser {
|
|||
unsigned accept_count;
|
||||
unsigned operation_count;
|
||||
const volatile size_t *cancellation_flag;
|
||||
bool halt_on_error;
|
||||
Subtree old_tree;
|
||||
TSRangeArray included_range_differences;
|
||||
unsigned included_range_difference_index;
|
||||
|
|
@ -1067,46 +1066,6 @@ static void ts_parser__handle_error(
|
|||
LOG_STACK();
|
||||
}
|
||||
|
||||
static void ts_parser__halt_parse(TSParser *self) {
|
||||
LOG("halting_parse");
|
||||
LOG_STACK();
|
||||
|
||||
ts_lexer_advance_to_end(&self->lexer);
|
||||
Length remaining_length = length_sub(
|
||||
self->lexer.current_position,
|
||||
ts_stack_position(self->stack, 0)
|
||||
);
|
||||
|
||||
Subtree filler_node = ts_subtree_new_error(
|
||||
&self->tree_pool,
|
||||
0,
|
||||
length_zero(),
|
||||
remaining_length,
|
||||
remaining_length.bytes,
|
||||
0,
|
||||
self->language
|
||||
);
|
||||
ts_subtree_to_mut_unsafe(filler_node).ptr->visible = false;
|
||||
ts_stack_push(self->stack, 0, filler_node, false, 0);
|
||||
|
||||
SubtreeArray children = array_new();
|
||||
Subtree root_error = ts_subtree_new_error_node(&self->tree_pool, &children, false, self->language);
|
||||
ts_stack_push(self->stack, 0, root_error, false, 0);
|
||||
|
||||
Subtree eof = ts_subtree_new_leaf(
|
||||
&self->tree_pool,
|
||||
ts_builtin_sym_end,
|
||||
length_zero(),
|
||||
length_zero(),
|
||||
0,
|
||||
0,
|
||||
false,
|
||||
false,
|
||||
self->language
|
||||
);
|
||||
ts_parser__accept(self, 0, eof);
|
||||
}
|
||||
|
||||
static bool ts_parser__recover_to_state(
|
||||
TSParser *self,
|
||||
StackVersion version,
|
||||
|
|
@ -1661,7 +1620,6 @@ TSParser *ts_parser_new(void) {
|
|||
self->finished_tree = NULL_SUBTREE;
|
||||
self->reusable_node = reusable_node_new();
|
||||
self->dot_graph_file = NULL;
|
||||
self->halt_on_error = false;
|
||||
self->cancellation_flag = NULL;
|
||||
self->timeout_duration = 0;
|
||||
self->end_clock = clock_null();
|
||||
|
|
@ -1741,10 +1699,6 @@ void ts_parser_print_dot_graphs(TSParser *self, int fd) {
|
|||
}
|
||||
}
|
||||
|
||||
void ts_parser_halt_on_error(TSParser *self, bool should_halt_on_error) {
|
||||
self->halt_on_error = should_halt_on_error;
|
||||
}
|
||||
|
||||
const size_t *ts_parser_cancellation_flag(const TSParser *self) {
|
||||
return (const size_t *)self->cancellation_flag;
|
||||
}
|
||||
|
|
@ -1862,9 +1816,6 @@ TSTree *ts_parser_parse(
|
|||
unsigned min_error_cost = ts_parser__condense_stack(self);
|
||||
if (self->finished_tree.ptr && ts_subtree_error_cost(self->finished_tree) < min_error_cost) {
|
||||
break;
|
||||
} else if (self->halt_on_error && min_error_cost > 0) {
|
||||
ts_parser__halt_parse(self);
|
||||
break;
|
||||
}
|
||||
|
||||
while (self->included_range_difference_index < self->included_range_differences.size) {
|
||||
|
|
|
|||
|
|
@ -59,17 +59,14 @@ for lang in ${languages[@]}; do
|
|||
ts_lang_query_filename=""
|
||||
fi
|
||||
|
||||
modes=(true halt false recover)
|
||||
for i in 0 2; do
|
||||
# FIXME: We should extract the grammar name from grammar.js. Use the name of
|
||||
# the directory instead. Also, the grammar name needs to be a valid C
|
||||
# identifier so replace any '-' characters
|
||||
ts_lang="tree_sitter_$(echo $lang | tr -- - _)"
|
||||
$CXX $CXXFLAGS -std=c++11 -I lib/include -D TS_HALT_ON_ERROR="${modes[i]}" -D TS_LANG="$ts_lang" -D TS_LANG_QUERY_FILENAME="\"${ts_lang_query_filename}\"" \
|
||||
"test/fuzz/fuzzer.cc" "${objects[@]}" \
|
||||
libtree-sitter.a "$LIB_FUZZER_PATH" \
|
||||
-o "out/${lang}_fuzzer_${modes[i+1]}"
|
||||
done
|
||||
# FIXME: We should extract the grammar name from grammar.js. Use the name of
|
||||
# the directory instead. Also, the grammar name needs to be a valid C
|
||||
# identifier so replace any '-' characters
|
||||
ts_lang="tree_sitter_$(echo $lang | tr -- - _)"
|
||||
$CXX $CXXFLAGS -std=c++11 -I lib/include -D TS_LANG="$ts_lang" -D TS_LANG_QUERY_FILENAME="\"${ts_lang_query_filename}\"" \
|
||||
"test/fuzz/fuzzer.cc" "${objects[@]}" \
|
||||
libtree-sitter.a "$LIB_FUZZER_PATH" \
|
||||
-o "out/${lang}_fuzzer"
|
||||
|
||||
python test/fuzz/gen-dict.py "${lang_dir}/src/grammar.json" > "out/$lang.dict"
|
||||
done
|
||||
|
|
|
|||
|
|
@ -44,8 +44,6 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||
bool language_ok = ts_parser_set_language(parser, TS_LANG());
|
||||
assert(language_ok);
|
||||
|
||||
ts_parser_halt_on_error(parser, TS_HALT_ON_ERROR);
|
||||
|
||||
TSTree *tree = ts_parser_parse_string(parser, NULL, str, size);
|
||||
TSNode root_node = ts_tree_root_node(tree);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue