Fixed some issue (relink) and removed more unused stuff from parser lib
This commit is contained in:
parent
c1209452cd
commit
5b7eb9784b
6 changed files with 27 additions and 70 deletions
|
|
@ -3,8 +3,9 @@
|
|||
|
||||
t_u32 ts_decode_ascii(const t_u8 *string, t_u32 length, t_i32 *code_point)
|
||||
{
|
||||
(void)(length);
|
||||
if (string == NULL || length == 0 || code_point == 0)
|
||||
return (0);
|
||||
*code_point = 0;
|
||||
*(t_u8 *)code_point = *string;
|
||||
return (1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "parser/language.h"
|
||||
#include "me/types.h"
|
||||
#include "parser/api.h"
|
||||
#include "parser/parser.h"
|
||||
#include "me/types.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
@ -216,31 +216,8 @@ bool ts_language_has_reduce_action(const TSLanguage *self, TSStateId state, TSSy
|
|||
// the given symbol.
|
||||
t_u16 ts_language_lookup(const TSLanguage *self, TSStateId state, TSSymbol symbol)
|
||||
{
|
||||
t_u32 index;
|
||||
const t_u16 *data;
|
||||
t_u16 group_count;
|
||||
t_u16 section_value;
|
||||
t_u16 symbol_count;
|
||||
t_u32 i;
|
||||
t_u32 j;
|
||||
|
||||
if (state >= self->large_state_count)
|
||||
{
|
||||
index = self->small_parse_table_map[state - self->large_state_count];
|
||||
data = &self->small_parse_table[index];
|
||||
group_count = *(data++);
|
||||
i = 0;
|
||||
while (i++ < group_count)
|
||||
{
|
||||
section_value = *(data++);
|
||||
symbol_count = *(data++);
|
||||
j = 0;
|
||||
while (j++ < symbol_count)
|
||||
if (*(data++) == symbol)
|
||||
return (section_value);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
return (me_abort("we got a small parse table, which isn't supported"), -1);
|
||||
else
|
||||
return (self->parse_table[state * self->symbol_count + symbol]);
|
||||
}
|
||||
|
|
@ -308,4 +285,4 @@ void ts_language_aliases_for_symbol(const TSLanguage *self, TSSymbol original_sy
|
|||
}
|
||||
idx += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,25 +27,16 @@ static const t_u32 MAX_VERSION_COUNT_OVERFLOW = 4;
|
|||
static const t_u32 MAX_SUMMARY_DEPTH = 1;
|
||||
static const t_u32 MAX_COST_DIFFERENCE = 16 * ERROR_COST_PER_SKIPPED_TREE;
|
||||
|
||||
typedef struct TokenCache
|
||||
{
|
||||
Subtree token;
|
||||
Subtree last_external_token;
|
||||
t_u32 byte_index;
|
||||
} TokenCache;
|
||||
|
||||
struct TSParser
|
||||
{
|
||||
Lexer lexer;
|
||||
Stack *stack;
|
||||
/* SubtreePool tree_pool; */
|
||||
Lexer lexer;
|
||||
Stack *stack;
|
||||
const TSLanguage *language;
|
||||
ReduceActionSet reduce_actions;
|
||||
Subtree finished_tree;
|
||||
SubtreeArray trailing_extras;
|
||||
SubtreeArray trailing_extras2;
|
||||
SubtreeArray scratch_trees;
|
||||
TokenCache token_cache;
|
||||
void *external_scanner_payload;
|
||||
t_u32 accept_count;
|
||||
t_u32 operation_count;
|
||||
|
|
@ -1506,7 +1497,6 @@ TSParser *ts_parser_new(void)
|
|||
self->has_scanner_error = false;
|
||||
self->external_scanner_payload = NULL;
|
||||
self->operation_count = 0;
|
||||
self->old_tree = NULL_SUBTREE;
|
||||
self->included_range_difference_index = 0;
|
||||
return self;
|
||||
}
|
||||
|
|
@ -1522,11 +1512,6 @@ void ts_parser_delete(TSParser *self)
|
|||
{
|
||||
array_delete(&self->reduce_actions);
|
||||
}
|
||||
if (self->old_tree.ptr)
|
||||
{
|
||||
ts_subtree_release(/*&self->tree_pool,*/ self->old_tree);
|
||||
self->old_tree = NULL_SUBTREE;
|
||||
}
|
||||
ts_lexer_delete(&self->lexer);
|
||||
/* ts_subtree_pool_delete(&self->tree_pool); */
|
||||
array_delete(&self->trailing_extras);
|
||||
|
|
@ -1559,12 +1544,6 @@ bool ts_parser_set_language(TSParser *self, const TSLanguage *language)
|
|||
void ts_parser_reset(TSParser *self)
|
||||
{
|
||||
ts_parser__external_scanner_destroy(self);
|
||||
if (self->old_tree.ptr)
|
||||
{
|
||||
ts_subtree_release(/*&self->tree_pool,*/ self->old_tree);
|
||||
self->old_tree = NULL_SUBTREE;
|
||||
}
|
||||
|
||||
ts_lexer_reset(&self->lexer, length_zero());
|
||||
ts_stack_clear(self->stack);
|
||||
if (self->finished_tree.ptr)
|
||||
|
|
@ -1576,9 +1555,8 @@ void ts_parser_reset(TSParser *self)
|
|||
self->has_scanner_error = false;
|
||||
}
|
||||
|
||||
TSTree *ts_parser_parse(TSParser *self, const TSTree *old_tree, TSInput input)
|
||||
TSTree *ts_parser_parse(TSParser *self, TSInput input)
|
||||
{
|
||||
(void)(old_tree);
|
||||
TSTree *result = NULL;
|
||||
if (!self->language || !input.read)
|
||||
return NULL;
|
||||
|
|
@ -1660,20 +1638,19 @@ exit:
|
|||
return result;
|
||||
}
|
||||
|
||||
TSTree *ts_parser_parse_string(TSParser *self, const TSTree *old_tree, t_const_str string, t_u32 length)
|
||||
TSTree *ts_parser_parse_string(TSParser *self, t_const_str string, t_u32 length)
|
||||
{
|
||||
return ts_parser_parse_string_encoding(self, old_tree, string, length, TSInputEncodingUTF8);
|
||||
return ts_parser_parse_string_encoding(self, string, length, TSInputEncodingUTF8);
|
||||
}
|
||||
|
||||
TSTree *ts_parser_parse_string_encoding(TSParser *self, const TSTree *old_tree, t_const_str string, t_u32 length, TSInputEncoding encoding)
|
||||
TSTree *ts_parser_parse_string_encoding(TSParser *self, t_const_str string, t_u32 length, TSInputEncoding encoding)
|
||||
{
|
||||
TSStringInput input = {(const t_u8 *)string, length};
|
||||
return ts_parser_parse(self, old_tree,
|
||||
(TSInput){
|
||||
&input,
|
||||
ts_string_input_read,
|
||||
encoding,
|
||||
});
|
||||
return ts_parser_parse(self, (TSInput){
|
||||
&input,
|
||||
ts_string_input_read,
|
||||
encoding,
|
||||
});
|
||||
}
|
||||
|
||||
#undef LOG
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue