update: normed lots of stuff
This commit is contained in:
parent
978636b6ef
commit
50a2f3d4be
118 changed files with 1145 additions and 1330 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/07/22 13:54:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/11 16:40:31 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:45:08 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -28,65 +28,64 @@
|
|||
#define TREE_SITTER_LANGUAGE_VERSION 14
|
||||
#define TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION 13
|
||||
|
||||
TSTree *ts_tree_copy(const TSTree *self);
|
||||
void ts_tree_delete(TSTree *self);
|
||||
TSNode ts_tree_root_node(const TSTree *self);
|
||||
TSNode ts_tree_root_node_with_offset(const TSTree *self, t_u32 offset_bytes, TSPoint offset_extent);
|
||||
const TSLanguage *ts_tree_language(const TSTree *self);
|
||||
t_tree *ts_tree_copy(const t_tree *self);
|
||||
void ts_tree_delete(t_tree *self);
|
||||
t_node ts_tree_root_node(const t_tree *self);
|
||||
t_node ts_tree_root_node_with_offset(const t_tree *self, t_u32 offset_bytes, t_point offset_extent);
|
||||
const t_language *ts_tree_language(const t_tree *self);
|
||||
|
||||
t_const_str ts_node_type(TSNode self);
|
||||
TSSymbol ts_node_symbol(TSNode self);
|
||||
const TSLanguage *ts_node_language(TSNode self);
|
||||
t_const_str ts_node_grammar_type(TSNode self);
|
||||
TSSymbol ts_node_grammar_symbol(TSNode self);
|
||||
t_u32 ts_node_start_byte(TSNode self);
|
||||
TSPoint ts_node_start_point(TSNode self);
|
||||
t_u32 ts_node_end_byte(TSNode self);
|
||||
TSPoint ts_node_end_point(TSNode self);
|
||||
char *ts_node_string(TSNode self);
|
||||
bool ts_node_is_null(TSNode self);
|
||||
bool ts_node_is_named(TSNode self);
|
||||
bool ts_node_is_missing(TSNode self);
|
||||
bool ts_node_is_extra(TSNode self);
|
||||
bool ts_node_has_changes(TSNode self);
|
||||
bool ts_node_has_error(TSNode self);
|
||||
bool ts_node_is_error(TSNode self);
|
||||
TSStateId ts_node_parse_state(TSNode self);
|
||||
TSStateId ts_node_next_parse_state(TSNode self);
|
||||
TSNode ts_node_parent(TSNode self);
|
||||
TSNode ts_node_child_containing_descendant(TSNode self, TSNode descendant);
|
||||
TSNode ts_node_child(TSNode self, t_u32 child_index);
|
||||
t_const_str ts_node_field_name_for_child(TSNode self, t_u32 child_index);
|
||||
TSFieldId ts_node_field_id_for_child(TSNode self, t_u32 child_index);
|
||||
t_u32 ts_node_child_count(TSNode self);
|
||||
TSNode ts_node_named_child(TSNode self, t_u32 child_index);
|
||||
t_u32 ts_node_named_child_count(TSNode self);
|
||||
TSNode ts_node_child_by_field_name(TSNode self, t_const_str name, t_u32 name_length);
|
||||
TSNode ts_node_child_by_field_id(TSNode self, TSFieldId field_id);
|
||||
TSNode ts_node_next_sibling(TSNode self);
|
||||
TSNode ts_node_prev_sibling(TSNode self);
|
||||
TSNode ts_node_next_named_sibling(TSNode self);
|
||||
TSNode ts_node_prev_named_sibling(TSNode self);
|
||||
TSNode ts_node_first_child_for_byte(TSNode self, t_u32 byte);
|
||||
TSNode ts_node_first_named_child_for_byte(TSNode self, t_u32 byte);
|
||||
t_u32 ts_node_descendant_count(TSNode self);
|
||||
TSNode ts_node_descendant_for_byte_range(TSNode self, t_u32 start, t_u32 end);
|
||||
TSNode ts_node_descendant_for_point_range(TSNode self, TSPoint start, TSPoint end);
|
||||
TSNode ts_node_named_descendant_for_byte_range(TSNode self, t_u32 start, t_u32 end);
|
||||
TSNode ts_node_named_descendant_for_point_range(TSNode self, TSPoint start, TSPoint end);
|
||||
bool ts_node_eq(TSNode self, TSNode other);
|
||||
t_const_str ts_node_type(t_node self);
|
||||
t_symbol ts_node_symbol(t_node self);
|
||||
const t_language *ts_node_language(t_node self);
|
||||
t_symbol ts_node_grammar_symbol(t_node self);
|
||||
t_u32 ts_node_start_byte(t_node self);
|
||||
t_point ts_node_start_point(t_node self);
|
||||
t_u32 ts_node_end_byte(t_node self);
|
||||
t_point ts_node_end_point(t_node self);
|
||||
char *ts_node_string(t_node self);
|
||||
bool ts_node_is_null(t_node self);
|
||||
bool ts_node_is_named(t_node self);
|
||||
bool ts_node_is_missing(t_node self);
|
||||
bool ts_node_is_extra(t_node self);
|
||||
bool ts_node_has_changes(t_node self);
|
||||
bool ts_node_has_error(t_node self);
|
||||
bool ts_node_is_error(t_node self);
|
||||
t_state_id ts_node_parse_state(t_node self);
|
||||
t_state_id ts_node_next_parse_state(t_node self);
|
||||
t_node ts_node_parent(t_node self);
|
||||
t_node ts_node_child_containing_descendant(t_node self, t_node descendant);
|
||||
t_node ts_node_child(t_node self, t_u32 child_index);
|
||||
t_const_str ts_node_field_name_for_child(t_node self, t_u32 child_index);
|
||||
t_field_id ts_node_field_id_for_child(t_node self, t_u32 child_index);
|
||||
t_u32 ts_node_child_count(t_node self);
|
||||
t_node ts_node_named_child(t_node self, t_u32 child_index);
|
||||
t_u32 ts_node_named_child_count(t_node self);
|
||||
t_node ts_node_child_by_field_name(t_node self, t_const_str name, t_u32 name_length);
|
||||
t_node ts_node_child_by_field_id(t_node self, t_field_id field_id);
|
||||
t_node ts_node_next_sibling(t_node self);
|
||||
t_node ts_node_prev_sibling(t_node self);
|
||||
t_node ts_node_next_named_sibling(t_node self);
|
||||
t_node ts_node_prev_named_sibling(t_node self);
|
||||
t_node ts_node_first_child_for_byte(t_node self, t_u32 byte);
|
||||
t_node ts_node_first_named_child_for_byte(t_node self, t_u32 byte);
|
||||
t_u32 ts_node_descendant_count(t_node self);
|
||||
t_node ts_node_descendant_for_byte_range(t_node self, t_u32 start, t_u32 end);
|
||||
t_node ts_node_descendant_for_point_range(t_node self, t_point start, t_point end);
|
||||
t_node ts_node_named_descendant_for_byte_range(t_node self, t_u32 start, t_u32 end);
|
||||
t_node ts_node_named_descendant_for_point_range(t_node self, t_point start, t_point end);
|
||||
bool ts_node_eq(t_node self, t_node other);
|
||||
|
||||
const TSLanguage *ts_language_copy(const TSLanguage *self);
|
||||
void ts_language_delete(const TSLanguage *self);
|
||||
t_u32 ts_language_symbol_count(const TSLanguage *self);
|
||||
t_u32 ts_language_state_count(const TSLanguage *self);
|
||||
t_const_str ts_language_symbol_name(const TSLanguage *self, TSSymbol symbol);
|
||||
TSSymbol ts_language_symbol_for_name(const TSLanguage *self, t_const_str string, t_u32 length, bool is_named);
|
||||
t_u32 ts_language_field_count(const TSLanguage *self);
|
||||
t_const_str ts_language_field_name_for_id(const TSLanguage *self, TSFieldId id);
|
||||
TSFieldId ts_language_field_id_for_name(const TSLanguage *self, t_const_str name, t_u32 name_length);
|
||||
TSSymbolType ts_language_symbol_type(const TSLanguage *self, TSSymbol symbol);
|
||||
t_u32 ts_language_version(const TSLanguage *self);
|
||||
TSStateId ts_language_next_state(const TSLanguage *self, TSStateId state, TSSymbol symbol);
|
||||
const t_language *ts_language_copy(const t_language *self);
|
||||
void ts_language_delete(const t_language *self);
|
||||
t_u32 ts_language_symbol_count(const t_language *self);
|
||||
t_u32 ts_language_state_count(const t_language *self);
|
||||
t_const_str ts_language_symbol_name(const t_language *self, t_symbol symbol);
|
||||
t_symbol ts_language_symbol_for_name(const t_language *self, t_const_str string, t_u32 length, bool is_named);
|
||||
t_u32 ts_language_field_count(const t_language *self);
|
||||
t_const_str ts_language_field_name_for_id(const t_language *self, t_field_id id);
|
||||
t_field_id ts_language_field_id_for_name(const t_language *self, t_const_str name, t_u32 name_length);
|
||||
t_symbol_type ts_language_symbol_type(const t_language *self, t_symbol symbol);
|
||||
t_u32 ts_language_version(const t_language *self);
|
||||
t_state_id ts_language_next_state(const t_language *self, t_state_id state, t_symbol symbol);
|
||||
|
||||
#endif // TREE_SITTER_API_H_
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/24 13:56:34 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/02 18:14:43 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:54:04 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -20,16 +20,17 @@ struct s_external_scanner_state
|
|||
char *long_data;
|
||||
t_u32 length;
|
||||
};
|
||||
|
||||
typedef struct s_external_scanner_state t_external_scanner_state;
|
||||
typedef struct s_subtree_data t_subtree_data;
|
||||
typedef t_subtree_data *t_subtree;
|
||||
|
||||
void ts_external_scanner_state_init(t_external_scanner_state *self, const t_u8 *data, t_u32 length);
|
||||
t_external_scanner_state ts_external_scanner_state_copy(const t_external_scanner_state *self);
|
||||
void ts_external_scanner_state_delete(t_external_scanner_state *self);
|
||||
const t_u8 *ts_external_scanner_state_data(const t_external_scanner_state *self);
|
||||
bool ts_external_scanner_state_eq(const t_external_scanner_state *self, const t_u8 *buffer, t_u32 length);
|
||||
const t_external_scanner_state *ts_subtree_external_scanner_state(t_subtree self);
|
||||
bool ts_subtree_external_scanner_state_eq(t_subtree self, t_subtree other);
|
||||
const t_external_scanner_state *ts_subtree_external_scanner_state(t_subtree self);
|
||||
const t_u8 *ts_external_scanner_state_data(const t_external_scanner_state *self);
|
||||
t_external_scanner_state ts_external_scanner_state_copy(const t_external_scanner_state *self);
|
||||
void ts_external_scanner_state_delete(t_external_scanner_state *self);
|
||||
void ts_external_scanner_state_init(t_external_scanner_state *self, const t_u8 *data, t_u32 length);
|
||||
|
||||
#endif /* EXTERNAL_SCANNER_STATE_H */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/02 20:03:42 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/02 20:16:55 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:35:42 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,7 +17,6 @@
|
|||
#include "parser/inner/point_inner.h"
|
||||
|
||||
typedef struct s_length t_length;
|
||||
typedef t_length Length;
|
||||
|
||||
struct s_length
|
||||
{
|
||||
|
|
@ -25,4 +24,12 @@ struct s_length
|
|||
t_point extent;
|
||||
};
|
||||
|
||||
t_length length_add(t_length len1, t_length len2);
|
||||
t_length length_min(t_length len1, t_length len2);
|
||||
t_length length_saturating_sub(t_length len1, t_length len2);
|
||||
t_length length_sub(t_length len1, t_length len2);
|
||||
t_length length_zero(void);
|
||||
bool length_is_undefined(t_length length);
|
||||
|
||||
|
||||
#endif /* LENGTH_INNER_H */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 17:04:59 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/31 17:12:08 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:45:08 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -20,24 +20,24 @@
|
|||
typedef struct s_node_child_iterator NodeChildIterator;
|
||||
struct s_node_child_iterator
|
||||
{
|
||||
t_subtree parent;
|
||||
const TSTree *tree;
|
||||
Length position;
|
||||
t_subtree parent;
|
||||
const t_tree *tree;
|
||||
t_length position;
|
||||
t_u32 child_index;
|
||||
t_u32 structural_child_index;
|
||||
const TSSymbol *alias_sequence;
|
||||
const t_symbol *alias_sequence;
|
||||
};
|
||||
|
||||
NodeChildIterator ts_node_iterate_children(const TSNode *node);
|
||||
TSFieldId ts_node__field_id_from_language(TSNode self, t_u32 structural_child_index);
|
||||
TSNode ts_node__child(TSNode self, t_u32 child_index, bool include_anonymous);
|
||||
TSNode ts_node__null(void);
|
||||
bool ts_node__is_relevant(TSNode self, bool include_anonymous);
|
||||
NodeChildIterator ts_node_iterate_children(const t_node *node);
|
||||
t_field_id ts_node__field_id_from_language(t_node self, t_u32 structural_child_index);
|
||||
t_node ts_node__child(t_node self, t_u32 child_index, bool include_anonymous);
|
||||
t_node ts_node__null(void);
|
||||
bool ts_node__is_relevant(t_node self, bool include_anonymous);
|
||||
bool ts_node_child_iterator_done(NodeChildIterator *self);
|
||||
bool ts_node_child_iterator_next(NodeChildIterator *self, TSNode *result);
|
||||
t_const_str ts_node__field_name_from_language(TSNode self, t_u32 structural_child_index);
|
||||
t_u32 ts_node__relevant_child_count(TSNode self, bool include_anonymous);
|
||||
t_subtree ts_node__subtree(TSNode self);
|
||||
t_u32 ts_node__alias(const TSNode *self);
|
||||
bool ts_node_child_iterator_next(NodeChildIterator *self, t_node *result);
|
||||
t_const_str ts_node__field_name_from_language(t_node self, t_u32 structural_child_index);
|
||||
t_u32 ts_node__relevant_child_count(t_node self, bool include_anonymous);
|
||||
t_subtree ts_node__subtree(t_node self);
|
||||
t_u32 ts_node__alias(const t_node *self);
|
||||
|
||||
#endif /* NODE_H */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/10 13:56:47 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/11 17:25:29 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:44:59 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
#include "parser/length.h"
|
||||
#include "parser/lexer.h"
|
||||
#include "parser/reduce_action.h"
|
||||
#include "parser/stack.h"
|
||||
#include "parser/inner/stack_inner.h"
|
||||
#include "parser/subtree.h"
|
||||
#include "parser/tree.h"
|
||||
#include <assert.h>
|
||||
|
|
@ -34,16 +34,17 @@
|
|||
#define MAX_SUMMARY_DEPTH 1
|
||||
#define MAX_COST_DIFFERENCE 16 * ERROR_COST_PER_SKIPPED_TREE
|
||||
|
||||
typedef enum e_error_comparison t_error_comparison;
|
||||
typedef struct s_error_status t_error_status;
|
||||
typedef enum e_error_comparison t_error_comparison;
|
||||
typedef struct s_string_input t_string_input;
|
||||
typedef struct s_parser t_parser;
|
||||
|
||||
struct TSParser
|
||||
struct s_parser
|
||||
{
|
||||
t_lexer lexer;
|
||||
t_stack *stack;
|
||||
const TSLanguage *language;
|
||||
ReduceActionSet reduce_actions;
|
||||
const t_language *language;
|
||||
t_vec_reduce_action reduce_actions;
|
||||
t_subtree finished_tree;
|
||||
t_vec_subtree trailing_extras;
|
||||
t_vec_subtree trailing_extras2;
|
||||
|
|
@ -78,36 +79,34 @@ struct s_string_input
|
|||
t_u32 length;
|
||||
};
|
||||
|
||||
TSParser *ts_parser_new(TSLanguage *language);
|
||||
void ts_parser_delete(TSParser *self);
|
||||
t_parser *ts_parser_new(t_language *language);
|
||||
t_tree *ts_parser_parse(t_parser *self, t_input input);
|
||||
t_tree *ts_parser_parse_string(t_parser *self, t_const_str string, t_u32 length);
|
||||
bool _parse_condition(t_parser *self, t_u32 *version_count, t_stack_version *version);
|
||||
bool ts_parser__advance(t_parser *self, t_stack_version version);
|
||||
bool ts_parser__better_version_exists(t_parser *self, t_stack_version version, bool is_in_error, t_u32 cost);
|
||||
bool ts_parser__breakdown_top_of_stack(t_parser *self, t_stack_version version);
|
||||
bool ts_parser__do_all_potential_reductions(t_parser *self, t_stack_version starting_version, t_symbol lookahead_symbol);
|
||||
bool ts_parser__external_scanner_scan(t_parser *self, t_state_id external_lex_state);
|
||||
bool ts_parser__recover_to_state(t_parser *self, t_stack_version version, t_u32 depth, t_state_id goal_state);
|
||||
bool ts_parser__select_children(t_parser *self, t_subtree left, const t_vec_subtree *children);
|
||||
bool ts_parser__select_tree(t_parser *self, t_subtree left, t_subtree right);
|
||||
bool ts_parser_has_outstanding_parse(t_parser *self);
|
||||
const t_u8 *ts_string_input_read(void *_self, t_u32 byte, t_point point, t_u32 *length);
|
||||
t_error_comparison ts_parser__compare_versions(t_parser *self, t_error_status a, t_error_status b);
|
||||
t_error_status ts_parser__version_status(t_parser *self, t_stack_version version);
|
||||
t_stack_version ts_parser__reduce(t_parser *self, t_stack_version version, t_symbol symbol, t_u32 count, int dynamic_precedence, t_u16 production_id, bool is_fragile, bool end_of_non_terminal_extra);
|
||||
t_subtree ts_parser__lex(t_parser *self, t_stack_version version, t_state_id parse_state);
|
||||
t_u32 ts_parser__condense_stack(t_parser *self);
|
||||
t_u32 ts_parser__external_scanner_serialize(t_parser *self);
|
||||
void ts_parser__accept(t_parser *self, t_stack_version version, t_subtree lookahead);
|
||||
void ts_parser__external_scanner_create(t_parser *self);
|
||||
void ts_parser__external_scanner_deserialize(t_parser *self, t_subtree external_token);
|
||||
void ts_parser__external_scanner_destroy(t_parser *self);
|
||||
void ts_parser__handle_error(t_parser *self, t_stack_version version, t_subtree lookahead);
|
||||
void ts_parser__recover(t_parser *self, t_stack_version version, t_subtree lookahead);
|
||||
void ts_parser__shift(t_parser *self, t_stack_version version, t_state_id state, t_subtree lookahead, bool extra);
|
||||
void ts_parser_delete(t_parser *self);
|
||||
void ts_parser_reset(t_parser *self);
|
||||
|
||||
void ts_parser__accept(TSParser *self, t_stack_version version, t_subtree lookahead);
|
||||
bool ts_parser__advance(TSParser *self, t_stack_version version);
|
||||
bool ts_parser__better_version_exists(TSParser *self, t_stack_version version, bool is_in_error, t_u32 cost);
|
||||
bool ts_parser__breakdown_top_of_stack(TSParser *self, t_stack_version version);
|
||||
t_error_comparison ts_parser__compare_versions(TSParser *self, t_error_status a, t_error_status b);
|
||||
t_u32 ts_parser__condense_stack(TSParser *self);
|
||||
bool ts_parser__do_all_potential_reductions(TSParser *self, t_stack_version starting_version, TSSymbol lookahead_symbol);
|
||||
void ts_parser__external_scanner_create(TSParser *self);
|
||||
void ts_parser__external_scanner_deserialize(TSParser *self, t_subtree external_token);
|
||||
void ts_parser__external_scanner_destroy(TSParser *self);
|
||||
bool ts_parser__external_scanner_scan(TSParser *self, TSStateId external_lex_state);
|
||||
t_u32 ts_parser__external_scanner_serialize(TSParser *self);
|
||||
void ts_parser__handle_error(TSParser *self, t_stack_version version, t_subtree lookahead);
|
||||
t_subtree ts_parser__lex(TSParser *self, t_stack_version version, TSStateId parse_state);
|
||||
void ts_parser__recover(TSParser *self, t_stack_version version, t_subtree lookahead);
|
||||
bool ts_parser__recover_to_state(TSParser *self, t_stack_version version, t_u32 depth, TSStateId goal_state);
|
||||
t_stack_version ts_parser__reduce(TSParser *self, t_stack_version version, TSSymbol symbol, t_u32 count, int dynamic_precedence,
|
||||
t_u16 production_id, bool is_fragile, bool end_of_non_terminal_extra);
|
||||
bool ts_parser__select_children(TSParser *self, t_subtree left, const t_vec_subtree *children);
|
||||
bool ts_parser__select_tree(TSParser *self, t_subtree left, t_subtree right);
|
||||
void ts_parser__shift(TSParser *self, t_stack_version version, TSStateId state, t_subtree lookahead, bool extra);
|
||||
t_error_status ts_parser__version_status(TSParser *self, t_stack_version version);
|
||||
bool ts_parser_has_outstanding_parse(TSParser *self);
|
||||
const TSLanguage *ts_parser_language(const TSParser *self);
|
||||
TSTree *ts_parser_parse(TSParser *self, TSInput input);
|
||||
TSTree *ts_parser_parse_string(TSParser *self, t_const_str string, t_u32 length);
|
||||
void ts_parser_reset(TSParser *self);
|
||||
bool ts_parser_set_language(TSParser *self, const TSLanguage *language);
|
||||
const t_u8 *ts_string_input_read(void *_self, t_u32 byte, TSPoint point, t_u32 *length);
|
||||
#endif /* PARSER_INNER_H */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/02 20:05:43 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/02 20:07:26 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:38:38 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -16,7 +16,6 @@
|
|||
#include "me/types.h"
|
||||
|
||||
typedef struct s_point t_point;
|
||||
typedef t_point TSPoint;
|
||||
|
||||
struct s_point
|
||||
{
|
||||
|
|
@ -24,4 +23,16 @@ struct s_point
|
|||
t_u32 column;
|
||||
};
|
||||
|
||||
t_point point__new(t_u32 row, t_u32 column);
|
||||
t_point point_add(t_point a, t_point b);
|
||||
t_point point_max(t_point a, t_point b);
|
||||
t_point point_min(t_point a, t_point b);
|
||||
t_point point_sub(t_point a, t_point b);
|
||||
bool point_eq(t_point a, t_point b);
|
||||
bool point_gt(t_point a, t_point b);
|
||||
bool point_gte(t_point a, t_point b);
|
||||
bool point_lt(t_point a, t_point b);
|
||||
bool point_lte(t_point a, t_point b);
|
||||
|
||||
|
||||
#endif /* POINT_INNER_H */
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/02 20:08:11 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/02 20:20:55 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:45:06 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -17,47 +17,42 @@
|
|||
#include "parser/inner/length_inner.h"
|
||||
#include "parser/inner/point_inner.h"
|
||||
|
||||
typedef t_u16 TSStateId;
|
||||
typedef t_u16 TSSymbol;
|
||||
typedef t_u16 TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
typedef struct TSParser TSParser;
|
||||
typedef struct s_tree TSTree;
|
||||
typedef t_u16 t_state_id;
|
||||
typedef t_u16 t_symbol;
|
||||
typedef t_u16 t_field_id;
|
||||
typedef struct s_language t_language;
|
||||
typedef struct s_parser t_parser;
|
||||
typedef struct s_tree t_tree;
|
||||
|
||||
typedef enum TSSymbolType
|
||||
typedef enum e_symbol_type
|
||||
{
|
||||
TSSymbolTypeRegular,
|
||||
TSSymbolTypeAnonymous,
|
||||
TSSymbolTypeAuxiliary,
|
||||
} TSSymbolType;
|
||||
t_symbol_typeRegular,
|
||||
t_symbol_typeAnonymous,
|
||||
t_symbol_typeAuxiliary,
|
||||
} t_symbol_type;
|
||||
|
||||
typedef struct s_srange
|
||||
{
|
||||
TSPoint start_point;
|
||||
TSPoint end_point;
|
||||
t_point start_point;
|
||||
t_point end_point;
|
||||
t_u32 start_byte;
|
||||
t_u32 end_byte;
|
||||
} TSRange;
|
||||
} t_range;
|
||||
|
||||
typedef struct t_input
|
||||
typedef struct s_input
|
||||
{
|
||||
void *payload;
|
||||
const t_u8 *(*read)(void *payload, t_u32 byte_index, TSPoint position, t_u32 *bytes_read);
|
||||
} TSInput;
|
||||
const t_u8 *(*read)(void *payload, t_u32 byte_index, t_point position, t_u32 *bytes_read);
|
||||
} t_input;
|
||||
|
||||
typedef struct t_parse_node
|
||||
typedef struct s_node
|
||||
{
|
||||
t_u32 start_byte;
|
||||
t_u32 start_row;
|
||||
t_u32 start_col;
|
||||
t_u32 alias;
|
||||
const void *id;
|
||||
const TSTree *tree;
|
||||
} TSNode;
|
||||
const t_tree *tree;
|
||||
} t_node;
|
||||
|
||||
typedef TSNode t_parse_node;
|
||||
typedef TSSymbol t_symbol;
|
||||
typedef TSParser t_first_parser;
|
||||
typedef TSLanguage t_language;
|
||||
typedef TSTree t_first_tree;
|
||||
#endif /* PTYPES_H */
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
struct s_reduce_action
|
||||
{
|
||||
t_u32 count;
|
||||
TSSymbol symbol;
|
||||
t_symbol symbol;
|
||||
int dynamic_precedence;
|
||||
t_u16 production_id;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* stack.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 16:37:50 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/31 18:36:27 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef STACK_H
|
||||
#define STACK_H
|
||||
|
||||
#include "me/types.h"
|
||||
#include "parser/subtree.h"
|
||||
#include "parser/stack.h"
|
||||
|
||||
#define MAX_LINK_COUNT 8
|
||||
#define MAX_NODE_POOL_SIZE 50
|
||||
#define MAX_ITERATOR_COUNT 64
|
||||
|
||||
typedef enum e_stack_status t_stack_status;
|
||||
typedef struct s_stack_head t_stack_head;
|
||||
typedef struct s_stack_iterator t_stack_iterator;
|
||||
typedef struct s_stack_link t_stack_link;
|
||||
typedef struct s_stack_node t_stack_node;
|
||||
typedef struct s_summarize_stack_session t_summarize_stack_session;
|
||||
typedef t_u32 t_stack_action;
|
||||
|
||||
typedef t_stack_action (*t_stack_callback)(void *,
|
||||
const t_stack_iterator *);
|
||||
|
||||
struct s_stack_link
|
||||
{
|
||||
t_stack_node *node;
|
||||
t_subtree subtree;
|
||||
bool is_pending;
|
||||
};
|
||||
|
||||
struct s_stack_node
|
||||
{
|
||||
TSStateId state;
|
||||
Length position;
|
||||
t_stack_link links[MAX_LINK_COUNT];
|
||||
t_u16 link_count;
|
||||
t_u32 ref_count;
|
||||
t_u32 error_cost;
|
||||
t_u32 node_count;
|
||||
int dynamic_precedence;
|
||||
};
|
||||
|
||||
struct s_stack_iterator
|
||||
{
|
||||
t_stack_node *node;
|
||||
t_vec_subtree subtrees;
|
||||
t_u32 subtree_count;
|
||||
bool is_pending;
|
||||
};
|
||||
|
||||
enum e_stack_status
|
||||
{
|
||||
SStatusActive,
|
||||
SStatusPaused,
|
||||
SStatusHalted,
|
||||
};
|
||||
|
||||
struct s_stack_head
|
||||
{
|
||||
t_stack_node *node;
|
||||
t_stack_summary *summary;
|
||||
t_u32 node_count_at_last_error;
|
||||
t_subtree last_external_token;
|
||||
t_subtree lookahead_when_paused;
|
||||
t_stack_status status;
|
||||
};
|
||||
|
||||
struct s_stack
|
||||
{
|
||||
Array(t_stack_head) heads;
|
||||
t_stack_slice_array slices;
|
||||
Array(t_stack_iterator) iterators;
|
||||
t_stack_node *base_node;
|
||||
};
|
||||
|
||||
enum e_stack_action
|
||||
{
|
||||
SActionNone,
|
||||
SActionStop = 1,
|
||||
SActionPop = 2,
|
||||
};
|
||||
|
||||
struct s_summarize_stack_session
|
||||
{
|
||||
t_stack_summary *summary;
|
||||
t_u32 max_depth;
|
||||
};
|
||||
|
||||
bool stack__subtree_is_equivalent(t_subtree left, t_subtree right);
|
||||
t_stack_node *stack_node_new(t_stack_node *previous_node, t_subtree subtree, bool is_pending, TSStateId state);
|
||||
t_stack_slice_array stack__iter(t_stack *self, t_stack_version version, t_stack_callback callback, void *payload, int goal_subtree_count);
|
||||
t_stack_version ts_stack__add_version(t_stack *self, t_stack_version original_version, t_stack_node *node);
|
||||
t_u32 stack__subtree_node_count(t_subtree subtree);
|
||||
void stack_head_delete(t_stack_head *self);
|
||||
void stack_node_add_link(t_stack_node *self, t_stack_link link);
|
||||
void stack_node_release(t_stack_node *self);
|
||||
void stack_node_retain(t_stack_node *self);
|
||||
void ts_stack__add_slice(t_stack *self, t_stack_version original_version, t_stack_node *node, t_vec_subtree *subtrees);
|
||||
|
||||
#endif /* STACK_H */
|
||||
177
parser/include/parser/inner/stack_inner.h
Normal file
177
parser/include/parser/inner/stack_inner.h
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* stack_inner.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 16:37:50 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/19 16:42:26 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef STACK_INNER_H
|
||||
#define STACK_INNER_H
|
||||
|
||||
#include "me/types.h"
|
||||
#include "parser/inner/length_inner.h"
|
||||
#include "parser/subtree.h"
|
||||
|
||||
#define MAX_LINK_COUNT 8
|
||||
#define MAX_NODE_POOL_SIZE 50
|
||||
#define MAX_ITERATOR_COUNT 64
|
||||
#define STACK_VERSION_NONE -1
|
||||
|
||||
typedef struct s_stack t_stack;
|
||||
typedef t_u32 t_stack_version;
|
||||
typedef struct s_stack_slice t_stack_slice;
|
||||
typedef struct s_stack_summary_entry t_stack_summary_entry;
|
||||
typedef Array(t_stack_slice) t_stack_slice_array;
|
||||
typedef Array(t_stack_summary_entry) t_stack_summary;
|
||||
|
||||
typedef enum e_stack_status t_stack_status;
|
||||
typedef struct s_stack_head t_stack_head;
|
||||
typedef struct s_stack_iterator t_stack_iterator;
|
||||
typedef struct s_stack_link t_stack_link;
|
||||
typedef struct s_stack_node t_stack_node;
|
||||
typedef struct s_summarize_stack_session t_summarize_stack_session;
|
||||
typedef t_u32 t_stack_action;
|
||||
|
||||
typedef t_stack_action (*t_stack_callback)(void *,
|
||||
const t_stack_iterator *);
|
||||
|
||||
struct s_stack_link
|
||||
{
|
||||
t_stack_node *node;
|
||||
t_subtree subtree;
|
||||
bool is_pending;
|
||||
};
|
||||
|
||||
struct s_stack_node
|
||||
{
|
||||
t_state_id state;
|
||||
t_length position;
|
||||
t_stack_link links[MAX_LINK_COUNT];
|
||||
t_u16 link_count;
|
||||
t_u32 ref_count;
|
||||
t_u32 error_cost;
|
||||
t_u32 node_count;
|
||||
int dynamic_precedence;
|
||||
};
|
||||
|
||||
struct s_stack_iterator
|
||||
{
|
||||
t_stack_node *node;
|
||||
t_vec_subtree subtrees;
|
||||
t_u32 subtree_count;
|
||||
bool is_pending;
|
||||
};
|
||||
|
||||
enum e_stack_status
|
||||
{
|
||||
SStatusActive,
|
||||
SStatusPaused,
|
||||
SStatusHalted,
|
||||
};
|
||||
|
||||
struct s_stack_head
|
||||
{
|
||||
t_stack_node *node;
|
||||
t_stack_summary *summary;
|
||||
t_u32 node_count_at_last_error;
|
||||
t_subtree last_external_token;
|
||||
t_subtree lookahead_when_paused;
|
||||
t_stack_status status;
|
||||
};
|
||||
|
||||
struct s_stack
|
||||
{
|
||||
Array(t_stack_head) heads;
|
||||
t_stack_slice_array slices;
|
||||
Array(t_stack_iterator) iterators;
|
||||
t_stack_node *base_node;
|
||||
};
|
||||
|
||||
enum e_stack_action
|
||||
{
|
||||
SActionNone,
|
||||
SActionStop = 1,
|
||||
SActionPop = 2,
|
||||
};
|
||||
|
||||
struct s_summarize_stack_session
|
||||
{
|
||||
t_stack_summary *summary;
|
||||
t_u32 max_depth;
|
||||
};
|
||||
|
||||
struct s_stack_slice
|
||||
{
|
||||
t_vec_subtree subtrees;
|
||||
t_stack_version version;
|
||||
};
|
||||
|
||||
struct s_stack_summary_entry
|
||||
{
|
||||
t_length position;
|
||||
t_u32 depth;
|
||||
t_state_id state;
|
||||
};
|
||||
|
||||
struct s_stack_push_arg
|
||||
{
|
||||
t_stack_version version;
|
||||
t_subtree subtree;
|
||||
bool pending;
|
||||
t_state_id state;
|
||||
};
|
||||
|
||||
t_length ts_stack_position(const t_stack *self, t_stack_version version);
|
||||
t_state_id ts_stack_state(const t_stack *self, t_stack_version version);
|
||||
bool stack__subtree_is_equivalent(t_subtree left, t_subtree right);
|
||||
bool ts_stack_can_merge(t_stack *self, t_stack_version version1, t_stack_version version2);
|
||||
bool ts_stack_has_advanced_since_error(const t_stack *self, t_stack_version version);
|
||||
bool ts_stack_is_active(const t_stack *self, t_stack_version version);
|
||||
bool ts_stack_is_halted(const t_stack *self, t_stack_version version);
|
||||
bool ts_stack_is_paused(const t_stack *self, t_stack_version version);
|
||||
bool ts_stack_merge(t_stack *self, t_stack_version version1, t_stack_version version2);
|
||||
int ts_stack_dynamic_precedence(t_stack *self, t_stack_version version);
|
||||
t_stack *ts_stack_new(void);
|
||||
t_stack_action pop_all_callback(void *payload, const t_stack_iterator *iterator);
|
||||
t_stack_action pop_count_callback(void *payload, const t_stack_iterator *iterator);
|
||||
t_stack_action pop_error_callback(void *payload, const t_stack_iterator *iterator);
|
||||
t_stack_action pop_pending_callback(void *payload, const t_stack_iterator *iterator);
|
||||
t_stack_action summarize_stack_callback(void *payload, const t_stack_iterator *iterator);
|
||||
t_stack_node *stack_node_new(t_stack_node *previous_node, t_subtree subtree, bool is_pending, t_state_id state);
|
||||
t_stack_slice_array stack__iter(t_stack *self, t_stack_version version, t_stack_callback callback, void *payload, int goal_subtree_count);
|
||||
t_stack_slice_array ts_stack_pop_all(t_stack *self, t_stack_version version);
|
||||
t_stack_slice_array ts_stack_pop_count(t_stack *self, t_stack_version version, t_u32 count);
|
||||
t_stack_slice_array ts_stack_pop_pending(t_stack *self, t_stack_version version);
|
||||
t_stack_summary *ts_stack_get_summary(t_stack *self, t_stack_version version);
|
||||
t_stack_version ts_stack__add_version(t_stack *self, t_stack_version original_version, t_stack_node *node);
|
||||
t_stack_version ts_stack_copy_version(t_stack *self, t_stack_version version);
|
||||
t_subtree ts_stack_last_external_token(const t_stack *self, t_stack_version version);
|
||||
t_subtree ts_stack_resume(t_stack *self, t_stack_version version);
|
||||
t_u32 stack__subtree_node_count(t_subtree subtree);
|
||||
t_u32 ts_stack_error_cost(const t_stack *self, t_stack_version version);
|
||||
t_u32 ts_stack_node_count_since_error(const t_stack *self, t_stack_version version);
|
||||
t_u32 ts_stack_version_count(const t_stack *self);
|
||||
t_vec_subtree ts_stack_pop_error(t_stack *self, t_stack_version version);
|
||||
void stack_head_delete(t_stack_head *self);
|
||||
void stack_node_add_link(t_stack_node *self, t_stack_link link);
|
||||
void stack_node_release(t_stack_node *self);
|
||||
void stack_node_retain(t_stack_node *self);
|
||||
void ts_stack__add_slice(t_stack *self, t_stack_version original_version, t_stack_node *node, t_vec_subtree *subtrees);
|
||||
void ts_stack_clear(t_stack *self);
|
||||
void ts_stack_delete(t_stack *self);
|
||||
void ts_stack_halt(t_stack *self, t_stack_version version);
|
||||
void ts_stack_pause(t_stack *self, t_stack_version version, t_subtree lookahead);
|
||||
void ts_stack_push(t_stack *self, struct s_stack_push_arg args);
|
||||
void ts_stack_record_summary(t_stack *self, t_stack_version version, t_u32 max_depth);
|
||||
void ts_stack_remove_version(t_stack *self, t_stack_version version);
|
||||
void ts_stack_renumber_version(t_stack *self, t_stack_version v1, t_stack_version v2);
|
||||
void ts_stack_set_last_external_token(t_stack *self, t_stack_version version, t_subtree token);
|
||||
void ts_stack_swap_versions(t_stack *self, t_stack_version v1, t_stack_version v2);
|
||||
|
||||
|
||||
#endif /* STACK_INNER_H */
|
||||
|
|
@ -28,13 +28,13 @@ typedef struct s_subtree_data t_subtree_data;
|
|||
struct s_subtree_data
|
||||
{
|
||||
t_u32 ref_count;
|
||||
Length padding;
|
||||
Length size;
|
||||
t_length padding;
|
||||
t_length size;
|
||||
t_u32 lookahead_bytes;
|
||||
t_u32 error_cost;
|
||||
t_u32 child_count;
|
||||
TSSymbol symbol;
|
||||
TSStateId parse_state;
|
||||
t_symbol symbol;
|
||||
t_state_id parse_state;
|
||||
|
||||
bool visible;
|
||||
bool named;
|
||||
|
|
@ -60,8 +60,8 @@ struct s_subtree_data
|
|||
t_u16 production_id;
|
||||
struct
|
||||
{
|
||||
TSSymbol symbol;
|
||||
TSStateId parse_state;
|
||||
t_symbol symbol;
|
||||
t_state_id parse_state;
|
||||
} first_leaf;
|
||||
};
|
||||
|
||||
|
|
@ -81,31 +81,31 @@ typedef struct s_subtree_new_error_args t_st_newerr_args;
|
|||
|
||||
struct s_subtree_new_leaf_args
|
||||
{
|
||||
TSSymbol symbol;
|
||||
Length padding;
|
||||
Length size;
|
||||
t_symbol symbol;
|
||||
t_length padding;
|
||||
t_length size;
|
||||
t_u32 lookahead_bytes;
|
||||
TSStateId parse_state;
|
||||
t_state_id parse_state;
|
||||
bool has_external_tokens;
|
||||
bool depends_on_column;
|
||||
bool is_keyword;
|
||||
const TSLanguage *language;
|
||||
const t_language *language;
|
||||
};
|
||||
|
||||
struct s_subtree_new_error_args
|
||||
{
|
||||
t_i32 lookahead_char;
|
||||
Length padding;
|
||||
Length size;
|
||||
t_length padding;
|
||||
t_length size;
|
||||
t_u32 bytes_scanned;
|
||||
TSStateId parse_state;
|
||||
const TSLanguage *language;
|
||||
t_state_id parse_state;
|
||||
const t_language *language;
|
||||
};
|
||||
|
||||
struct s_summarize_state
|
||||
{
|
||||
t_u32 structural_index;
|
||||
const TSSymbol *alias_sequence;
|
||||
const t_symbol *alias_sequence;
|
||||
t_u32 lookahead_end_byte;
|
||||
t_subtree *children;
|
||||
t_subtree child;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 12:03:18 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/31 12:03:29 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:54:21 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -21,28 +21,28 @@
|
|||
#define LANGUAGE_VERSION_WITH_PRIMARY_STATES 14
|
||||
#define LANGUAGE_VERSION_USABLE_VIA_WASM 13
|
||||
|
||||
struct TableEntry
|
||||
struct s_table_entry
|
||||
{
|
||||
const TSParseAction *actions;
|
||||
t_u32 action_count;
|
||||
bool is_reusable;
|
||||
};
|
||||
|
||||
typedef struct TableEntry TableEntry;
|
||||
typedef struct s_table_entry TableEntry;
|
||||
|
||||
void ts_language_table_entry(const TSLanguage *, TSStateId, TSSymbol, TableEntry *);
|
||||
TSSymbolMetadata ts_language_symbol_metadata(const TSLanguage *, TSSymbol);
|
||||
TSSymbol ts_language_public_symbol(const TSLanguage *, TSSymbol);
|
||||
TSStateId ts_language_next_state(const TSLanguage *self, TSStateId state, TSSymbol symbol);
|
||||
bool ts_language_is_symbol_external(const TSLanguage *self, TSSymbol symbol);
|
||||
const TSParseAction *ts_language_actions(const TSLanguage *self, TSStateId state, TSSymbol symbol, t_u32 *count);
|
||||
bool ts_language_has_reduce_action(const TSLanguage *self, TSStateId state, TSSymbol symbol);
|
||||
t_u16 ts_language_lookup(const TSLanguage *self, TSStateId state, TSSymbol symbol);
|
||||
bool ts_language_has_actions(const TSLanguage *self, TSStateId state, TSSymbol symbol);
|
||||
const bool *ts_language_enabled_external_tokens(const TSLanguage *self, t_u32 external_scanner_state);
|
||||
const TSSymbol *ts_language_alias_sequence(const TSLanguage *self, t_u32 production_id);
|
||||
TSSymbol ts_language_alias_at(const TSLanguage *self, t_u32 production_id, t_u32 child_index);
|
||||
void ts_language_field_map(const TSLanguage *self, t_u32 production_id, const TSFieldMapEntry **start, const TSFieldMapEntry **end);
|
||||
void ts_language_aliases_for_symbol(const TSLanguage *self, TSSymbol original_symbol, const TSSymbol **start, const TSSymbol **end);
|
||||
void ts_language_table_entry(const t_language *, t_state_id, t_symbol, TableEntry *);
|
||||
t_symbol_metadata ts_language_symbol_metadata(const t_language *, t_symbol);
|
||||
t_symbol ts_language_public_symbol(const t_language *, t_symbol);
|
||||
t_state_id ts_language_next_state(const t_language *self, t_state_id state, t_symbol symbol);
|
||||
bool ts_language_is_symbol_external(const t_language *self, t_symbol symbol);
|
||||
const TSParseAction *ts_language_actions(const t_language *self, t_state_id state, t_symbol symbol, t_u32 *count);
|
||||
bool ts_language_has_reduce_action(const t_language *self, t_state_id state, t_symbol symbol);
|
||||
t_u16 ts_language_lookup(const t_language *self, t_state_id state, t_symbol symbol);
|
||||
bool ts_language_has_actions(const t_language *self, t_state_id state, t_symbol symbol);
|
||||
const bool *ts_language_enabled_external_tokens(const t_language *self, t_u32 external_scanner_state);
|
||||
const t_symbol *ts_language_alias_sequence(const t_language *self, t_u32 production_id);
|
||||
t_symbol ts_language_alias_at(const t_language *self, t_u32 production_id, t_u32 child_index);
|
||||
void ts_language_field_map(const t_language *self, t_u32 production_id, const TSFieldMapEntry **start, const TSFieldMapEntry **end);
|
||||
void ts_language_aliases_for_symbol(const t_language *self, t_symbol original_symbol, const t_symbol **start, const t_symbol **end);
|
||||
|
||||
#endif // LANGUAGE_H
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 12:03:16 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/02 20:05:01 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:36:07 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,15 +15,7 @@
|
|||
|
||||
#include "parser/inner/length_inner.h"
|
||||
|
||||
static const Length LENGTH_UNDEFINED = {0, {0, 1}};
|
||||
static const Length LENGTH_MAX = {UINT32_MAX, {UINT32_MAX, UINT32_MAX}};
|
||||
|
||||
Length length_saturating_sub(Length len1, Length len2);
|
||||
Length length_zero(void);
|
||||
Length length_sub(Length len1, Length len2);
|
||||
Length length_add(Length len1, Length len2);
|
||||
Length length_min(Length len1, Length len2);
|
||||
Length length_max(Length len1, Length len2);
|
||||
bool length_is_undefined(Length length);
|
||||
static const t_length LENGTH_UNDEFINED = {0, {0, 1}};
|
||||
static const t_length LENGTH_MAX = {UINT32_MAX, {UINT32_MAX, UINT32_MAX}};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 12:03:15 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/02 20:21:08 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:52:25 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -18,35 +18,36 @@
|
|||
#include "parser/parser.h"
|
||||
#include "me/types.h"
|
||||
|
||||
typedef struct s_lexer t_lexer;
|
||||
|
||||
struct s_lexer
|
||||
{
|
||||
TSLexer data;
|
||||
Length current_position;
|
||||
Length token_start_position;
|
||||
Length token_end_position;
|
||||
TSRange *included_ranges;
|
||||
const t_u8 *chunk;
|
||||
TSInput input;
|
||||
t_u32 included_range_count;
|
||||
t_u32 current_included_range_index;
|
||||
t_u32 chunk_start;
|
||||
t_u32 chunk_size;
|
||||
t_u32 lookahead_size;
|
||||
bool did_get_column;
|
||||
t_u8 debug_buffer[TREE_SITTER_SERIALIZATION_BUFFER_SIZE];
|
||||
struct s_lexer_functions funcs;
|
||||
t_length current_position;
|
||||
t_length token_start_position;
|
||||
t_length token_end_position;
|
||||
t_range *included_ranges;
|
||||
const t_u8 *chunk;
|
||||
t_input input;
|
||||
t_u32 included_range_count;
|
||||
t_u32 current_included_range_index;
|
||||
t_u32 chunk_start;
|
||||
t_u32 chunk_size;
|
||||
t_u32 lookahead_size;
|
||||
bool did_get_column;
|
||||
t_u8 debug_buffer[TREE_SITTER_SERIALIZATION_BUFFER_SIZE];
|
||||
};
|
||||
|
||||
typedef struct s_lexer t_lexer;
|
||||
|
||||
void ts_lexer_init(t_lexer *self);
|
||||
void ts_lexer_delete(t_lexer *self);
|
||||
void ts_lexer_set_input(t_lexer *self, TSInput input);
|
||||
void ts_lexer_reset(t_lexer *self, Length length);
|
||||
void ts_lexer_set_input(t_lexer *self, t_input input);
|
||||
void ts_lexer_reset(t_lexer *self, t_length length);
|
||||
void ts_lexer_start(t_lexer *self);
|
||||
void ts_lexer_finish(t_lexer *self, t_u32 *lookahead);
|
||||
void ts_lexer_advance_to_end(t_lexer *self);
|
||||
void ts_lexer_mark_end(t_lexer *self);
|
||||
bool ts_lexer_set_included_ranges(t_lexer *self, const TSRange *ranges, t_u32 count);
|
||||
TSRange *ts_lexer_included_ranges(const t_lexer *self, t_u32 *count);
|
||||
bool ts_lexer_set_included_ranges(t_lexer *self, const t_range *ranges, t_u32 count);
|
||||
t_range *ts_lexer_included_ranges(const t_lexer *self, t_u32 *count);
|
||||
|
||||
#endif // LEXER_H
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 12:03:13 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/31 18:45:04 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:57:51 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -15,50 +15,47 @@
|
|||
|
||||
#include "me/types.h"
|
||||
|
||||
#define ts_builtin_sym_error ((TSSymbol)-1)
|
||||
#define ts_builtin_sym_error ((t_symbol)-1)
|
||||
#define ts_builtin_sym_end 0
|
||||
#define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024
|
||||
|
||||
#ifndef TREE_SITTER_API_H_
|
||||
typedef t_u16 TSStateId;
|
||||
typedef t_u16 TSSymbol;
|
||||
typedef t_u16 TSFieldId;
|
||||
typedef struct TSLanguage TSLanguage;
|
||||
#endif
|
||||
typedef t_u16 t_state_id;
|
||||
typedef t_u16 t_symbol;
|
||||
typedef t_u16 t_field_id;
|
||||
typedef struct s_language t_language;
|
||||
typedef struct s_lexer t_lexer;
|
||||
|
||||
typedef struct TSFieldMapEntry
|
||||
typedef struct s_field_map_entry
|
||||
{
|
||||
TSFieldId field_id;
|
||||
t_field_id field_id;
|
||||
t_u8 child_index;
|
||||
bool inherited;
|
||||
} TSFieldMapEntry;
|
||||
|
||||
typedef struct TSFieldMapSlice
|
||||
typedef struct s_field_map_slice
|
||||
{
|
||||
t_u16 index;
|
||||
t_u16 length;
|
||||
} TSFieldMapSlice;
|
||||
|
||||
typedef struct TSSymbolMetadata
|
||||
typedef struct s_symbol_metadata
|
||||
{
|
||||
bool visible;
|
||||
bool named;
|
||||
bool supertype;
|
||||
} TSSymbolMetadata;
|
||||
|
||||
typedef struct s_lexer_functions TSLexer;
|
||||
} t_symbol_metadata;
|
||||
|
||||
struct s_lexer_functions
|
||||
{
|
||||
t_i32 lookahead;
|
||||
TSSymbol result_symbol;
|
||||
void (*advance)(TSLexer *, bool);
|
||||
void (*mark_end)(TSLexer *);
|
||||
t_u32 (*get_column)(TSLexer *);
|
||||
bool (*eof)(const TSLexer *);
|
||||
t_symbol result_symbol;
|
||||
void (*advance)(t_lexer *, bool);
|
||||
void (*mark_end)(t_lexer *);
|
||||
t_u32 (*get_column)(t_lexer *);
|
||||
bool (*eof)(const t_lexer *);
|
||||
};
|
||||
|
||||
typedef enum TSParseActionType
|
||||
typedef enum e_parse_action_type
|
||||
{
|
||||
TSParseActionTypeShift,
|
||||
TSParseActionTypeReduce,
|
||||
|
|
@ -66,47 +63,47 @@ typedef enum TSParseActionType
|
|||
TSParseActionTypeRecover,
|
||||
} TSParseActionType;
|
||||
|
||||
typedef union TSParseAction {
|
||||
struct TSParseActionShift
|
||||
typedef union u_parse_action {
|
||||
struct s_parse_action_shift
|
||||
{
|
||||
t_u8 type;
|
||||
TSStateId state;
|
||||
t_state_id state;
|
||||
bool extra;
|
||||
bool repetition;
|
||||
} shift;
|
||||
struct TSParseActionReduce
|
||||
struct s_parse_action_reduce
|
||||
{
|
||||
t_u8 type;
|
||||
t_u8 child_count;
|
||||
TSSymbol symbol;
|
||||
t_symbol symbol;
|
||||
t_i16 dynamic_precedence;
|
||||
t_u16 production_id;
|
||||
} reduce;
|
||||
t_u8 type;
|
||||
} TSParseAction;
|
||||
|
||||
typedef struct TSLexMode
|
||||
typedef struct s_lex_mode
|
||||
{
|
||||
t_u16 lex_state;
|
||||
t_u16 external_lex_state;
|
||||
} TSLexMode;
|
||||
|
||||
typedef union TSParseActionEntry {
|
||||
typedef union u_parse_action_entry {
|
||||
TSParseAction action;
|
||||
struct TSParseActionEntryInner
|
||||
struct s_parse_action_entry_inner
|
||||
{
|
||||
t_u8 count;
|
||||
bool reusable;
|
||||
} entry;
|
||||
} TSParseActionEntry;
|
||||
|
||||
typedef struct TSCharacterRange
|
||||
typedef struct s_character_range
|
||||
{
|
||||
t_i32 start;
|
||||
t_i32 end;
|
||||
} TSCharacterRange;
|
||||
|
||||
struct TSLanguage
|
||||
struct s_language
|
||||
{
|
||||
t_u32 version;
|
||||
t_u32 symbol_count;
|
||||
|
|
@ -126,25 +123,25 @@ struct TSLanguage
|
|||
t_const_str const *field_names;
|
||||
const TSFieldMapSlice *field_map_slices;
|
||||
const TSFieldMapEntry *field_map_entries;
|
||||
const TSSymbolMetadata *symbol_metadata;
|
||||
const TSSymbol *public_symbol_map;
|
||||
const t_symbol_metadata *symbol_metadata;
|
||||
const t_symbol *public_symbol_map;
|
||||
const t_u16 *alias_map;
|
||||
const TSSymbol *alias_sequences;
|
||||
const t_symbol *alias_sequences;
|
||||
const TSLexMode *lex_modes;
|
||||
bool (*lex_fn)(TSLexer *, TSStateId);
|
||||
bool (*keyword_lex_fn)(TSLexer *, TSStateId);
|
||||
TSSymbol keyword_capture_token;
|
||||
bool (*lex_fn)(t_lexer *, t_state_id);
|
||||
bool (*keyword_lex_fn)(t_lexer *, t_state_id);
|
||||
t_symbol keyword_capture_token;
|
||||
struct ExternalScannerDefinition
|
||||
{
|
||||
const bool *states;
|
||||
const TSSymbol *symbol_map;
|
||||
const t_symbol *symbol_map;
|
||||
void *(*create)(void);
|
||||
void (*destroy)(void *);
|
||||
bool (*scan)(void *, TSLexer *, const bool *symbol_whitelist);
|
||||
bool (*scan)(void *, t_lexer *, const bool *symbol_whitelist);
|
||||
t_u32 (*serialize)(void *, t_u8 *);
|
||||
void (*deserialize)(void *, const t_u8 *, t_u32);
|
||||
} external_scanner;
|
||||
const TSStateId *primary_state_ids;
|
||||
const t_state_id *primary_state_ids;
|
||||
};
|
||||
|
||||
static inline bool set_contains(TSCharacterRange *ranges, t_u32 len, t_i32 lookahead)
|
||||
|
|
@ -184,10 +181,10 @@ static inline bool set_contains(TSCharacterRange *ranges, t_u32 len, t_i32 looka
|
|||
t_i32 lookahead; \
|
||||
goto start; \
|
||||
next_state: \
|
||||
lexer->data.advance((void *)lexer, skip); \
|
||||
lexer->funcs.advance((void *)lexer, skip); \
|
||||
start: \
|
||||
skip = false; \
|
||||
lookahead = lexer->data.lookahead;
|
||||
lookahead = lexer->funcs.lookahead;
|
||||
|
||||
#define ADVANCE(state_value) \
|
||||
{ \
|
||||
|
|
@ -217,8 +214,8 @@ start:
|
|||
|
||||
#define ACCEPT_TOKEN(symbol_value) \
|
||||
result = true; \
|
||||
lexer->data.result_symbol = symbol_value; \
|
||||
lexer->data.mark_end((void *)lexer);
|
||||
lexer->funcs.result_symbol = symbol_value; \
|
||||
lexer->funcs.mark_end((void *)lexer);
|
||||
|
||||
#define END_STATE() return result;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,18 +16,18 @@
|
|||
#include "parser/api.h"
|
||||
#include "me/types.h"
|
||||
|
||||
#define POINT_ZERO ((TSPoint){0, 0})
|
||||
#define POINT_MAX ((TSPoint){UINT32_MAX, UINT32_MAX})
|
||||
#define POINT_ZERO ((t_point){0, 0})
|
||||
#define POINT_MAX ((t_point){UINT32_MAX, UINT32_MAX})
|
||||
|
||||
TSPoint point_max(TSPoint a, TSPoint b);
|
||||
TSPoint point_min(TSPoint a, TSPoint b);
|
||||
TSPoint point__new(t_u32 row, t_u32 column);
|
||||
TSPoint point_add(TSPoint a, TSPoint b);
|
||||
TSPoint point_sub(TSPoint a, TSPoint b);
|
||||
bool point_lte(TSPoint a, TSPoint b);
|
||||
bool point_lt(TSPoint a, TSPoint b);
|
||||
bool point_gte(TSPoint a, TSPoint b);
|
||||
bool point_gt(TSPoint a, TSPoint b);
|
||||
bool point_eq(TSPoint a, TSPoint b);
|
||||
t_point point_max(t_point a, t_point b);
|
||||
t_point point_min(t_point a, t_point b);
|
||||
t_point point__new(t_u32 row, t_u32 column);
|
||||
t_point point_add(t_point a, t_point b);
|
||||
t_point point_sub(t_point a, t_point b);
|
||||
bool point_lte(t_point a, t_point b);
|
||||
bool point_lt(t_point a, t_point b);
|
||||
bool point_gte(t_point a, t_point b);
|
||||
bool point_gt(t_point a, t_point b);
|
||||
bool point_eq(t_point a, t_point b);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@
|
|||
#include "parser/inner/reduce_action_inner.h"
|
||||
#include "me/vec/vec_reduce_action.h"
|
||||
|
||||
typedef t_vec_reduce_action ReduceActionSet;
|
||||
typedef t_vec_reduce_action t_vec_reduce_action;
|
||||
|
||||
void ts_reduce_action_set_add(ReduceActionSet *self, t_reduce_action new_action);
|
||||
void ts_reduce_action_set_add(t_vec_reduce_action *self, t_reduce_action new_action);
|
||||
|
||||
#endif // REDUCE_ACTION_H
|
||||
|
|
|
|||
|
|
@ -1,74 +0,0 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* stack.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 12:03:07 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/08/31 18:34:46 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PARSE_STACK_H
|
||||
#define PARSE_STACK_H
|
||||
|
||||
#include "me/types.h"
|
||||
#include "parser/array.h"
|
||||
#include "parser/subtree.h"
|
||||
|
||||
typedef struct s_stack t_stack;
|
||||
typedef t_u32 t_stack_version;
|
||||
typedef struct s_stack_slice t_stack_slice;
|
||||
typedef struct s_stack_summary_entry t_stack_summary_entry;
|
||||
typedef Array(t_stack_slice) t_stack_slice_array;
|
||||
typedef Array(t_stack_summary_entry) t_stack_summary;
|
||||
|
||||
#define STACK_VERSION_NONE ((t_stack_version) - 1)
|
||||
|
||||
struct s_stack_slice
|
||||
{
|
||||
t_vec_subtree subtrees;
|
||||
t_stack_version version;
|
||||
};
|
||||
|
||||
struct s_stack_summary_entry
|
||||
{
|
||||
Length position;
|
||||
t_u32 depth;
|
||||
TSStateId state;
|
||||
};
|
||||
|
||||
t_stack *ts_stack_new(void);
|
||||
void ts_stack_delete(t_stack *);
|
||||
t_u32 ts_stack_version_count(const t_stack *);
|
||||
TSStateId ts_stack_state(const t_stack *, t_stack_version);
|
||||
t_subtree ts_stack_last_external_token(const t_stack *, t_stack_version);
|
||||
void ts_stack_set_last_external_token(t_stack *, t_stack_version, t_subtree);
|
||||
Length ts_stack_position(const t_stack *, t_stack_version);
|
||||
void ts_stack_push(t_stack *, t_stack_version, t_subtree, bool, TSStateId);
|
||||
t_stack_slice_array ts_stack_pop_count(t_stack *, t_stack_version, t_u32 count);
|
||||
t_vec_subtree ts_stack_pop_error(t_stack *, t_stack_version);
|
||||
t_stack_slice_array ts_stack_pop_pending(t_stack *, t_stack_version);
|
||||
t_stack_slice_array ts_stack_pop_all(t_stack *, t_stack_version);
|
||||
t_u32 ts_stack_node_count_since_error(const t_stack *, t_stack_version);
|
||||
int ts_stack_dynamic_precedence(t_stack *, t_stack_version);
|
||||
bool ts_stack_has_advanced_since_error(const t_stack *, t_stack_version);
|
||||
void ts_stack_record_summary(t_stack *, t_stack_version, t_u32 max_depth);
|
||||
t_stack_summary *ts_stack_get_summary(t_stack *, t_stack_version);
|
||||
t_u32 ts_stack_error_cost(const t_stack *, t_stack_version version);
|
||||
bool ts_stack_merge(t_stack *, t_stack_version, t_stack_version);
|
||||
bool ts_stack_can_merge(t_stack *, t_stack_version, t_stack_version);
|
||||
t_subtree ts_stack_resume(t_stack *, t_stack_version);
|
||||
void ts_stack_pause(t_stack *, t_stack_version, t_subtree);
|
||||
void ts_stack_halt(t_stack *, t_stack_version);
|
||||
bool ts_stack_is_active(const t_stack *, t_stack_version);
|
||||
bool ts_stack_is_paused(const t_stack *, t_stack_version);
|
||||
bool ts_stack_is_halted(const t_stack *, t_stack_version);
|
||||
void ts_stack_renumber_version(t_stack *, t_stack_version, t_stack_version);
|
||||
void ts_stack_swap_versions(t_stack *, t_stack_version, t_stack_version);
|
||||
t_stack_version ts_stack_copy_version(t_stack *, t_stack_version);
|
||||
void ts_stack_remove_version(t_stack *, t_stack_version);
|
||||
void ts_stack_clear(t_stack *);
|
||||
|
||||
#endif // PARSE_STACK_H
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/08/31 12:03:06 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/09/14 14:14:46 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/09/19 16:37:37 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -31,35 +31,37 @@
|
|||
|
||||
typedef t_vec_subtree t_vec_subtree;
|
||||
|
||||
void ts_external_scanner_state_init(t_external_scanner_state *, const t_u8 *, t_u32);
|
||||
const t_u8 *ts_external_scanner_state_data(const t_external_scanner_state *);
|
||||
bool ts_external_scanner_state_eq(const t_external_scanner_state *self, const t_u8 *, t_u32);
|
||||
void ts_external_scanner_state_delete(t_external_scanner_state *self);
|
||||
bool _subtree_compress_inner(t_subtree *tree, t_symbol symbol, t_vec_subtree *stack);
|
||||
int subtree_compare_func(t_subtree left, t_subtree right);
|
||||
int ts_subtree_compare(t_subtree left, t_subtree right);
|
||||
struct s_summarize_state _init_sumnarize_state(t_subtree self, const t_language *language);
|
||||
t_subtree ts_subtree_clone(t_subtree self);
|
||||
t_subtree ts_subtree_ensure_owner(t_subtree self);
|
||||
t_subtree ts_subtree_last_external_token(t_subtree tree);
|
||||
t_subtree ts_subtree_new_error(t_st_newerr_args args);
|
||||
t_subtree ts_subtree_new_error_node(t_vec_subtree *children, bool extra, const t_language *language);
|
||||
t_subtree ts_subtree_new_leaf(t_st_newleaf_args args);
|
||||
t_subtree ts_subtree_new_missing_leaf(t_symbol symbol, t_length padding, t_u32 lookahead_bytes, const t_language *language);
|
||||
t_subtree ts_subtree_new_node(t_symbol symbol, t_vec_subtree *children, t_u32 production_id, const t_language *language);
|
||||
void _subtree_balance_inner(const t_language *language, t_vec_subtree *tree_stack);
|
||||
void _subtree_balance_repush(t_vec_subtree *tree_stack, t_subtree tree);
|
||||
void _subtree_release_inner(t_vec_subtree *to_free);
|
||||
void _sumarize_end(t_subtree self, t_subtree *children);
|
||||
void _summarize_loop_inner1(t_subtree self, const t_language *language, struct s_summarize_state *s);
|
||||
void _summarize_loop_inner2(t_subtree self, const t_language *language, struct s_summarize_state *s);
|
||||
void _summarize_loop_inner3(t_subtree self, const t_language *language, struct s_summarize_state *s);
|
||||
void _summarize_loop_inner4(t_subtree self, const t_language *language, struct s_summarize_state *s);
|
||||
void ts_subtree__compress(t_subtree self, t_u32 count, const t_language *language, t_vec_subtree *stack);
|
||||
void ts_subtree_array_clear(t_vec_subtree *self);
|
||||
void ts_subtree_array_copy(t_vec_subtree self, t_vec_subtree *dest);
|
||||
void ts_subtree_array_delete(t_vec_subtree *self);
|
||||
void ts_subtree_array_remove_trailing_extras(t_vec_subtree *self, t_vec_subtree *destination);
|
||||
void ts_subtree_balance(t_subtree self, const t_language *language);
|
||||
void ts_subtree_release(t_subtree self);
|
||||
void ts_subtree_set_symbol(t_subtree *self, t_symbol symbol, const t_language *language);
|
||||
void ts_subtree_summarize_children(t_subtree self, const t_language *language);
|
||||
|
||||
void ts_subtree_array_copy(t_vec_subtree, t_vec_subtree *);
|
||||
void ts_subtree_array_clear(t_vec_subtree *);
|
||||
void ts_subtree_array_delete(t_vec_subtree *);
|
||||
void ts_subtree_array_remove_trailing_extras(t_vec_subtree *, t_vec_subtree *);
|
||||
void ts_subtree_array_reverse(t_vec_subtree *);
|
||||
|
||||
t_subtree ts_subtree_new_leaf(t_st_newleaf_args args);
|
||||
t_subtree ts_subtree_new_error(t_st_newerr_args args);
|
||||
t_subtree ts_subtree_new_node(TSSymbol, t_vec_subtree *, t_u32, const TSLanguage *);
|
||||
t_subtree ts_subtree_new_error_node(t_vec_subtree *, bool, const TSLanguage *);
|
||||
t_subtree ts_subtree_new_missing_leaf(TSSymbol, Length, t_u32, const TSLanguage *);
|
||||
t_subtree ts_subtree_ensure_owner(t_subtree);
|
||||
void ts_subtree_release(t_subtree);
|
||||
int ts_subtree_compare(t_subtree, t_subtree);
|
||||
void ts_subtree_set_symbol(t_subtree *, TSSymbol, const TSLanguage *);
|
||||
void ts_subtree_summarize(t_subtree, const t_subtree *, t_u32, const TSLanguage *);
|
||||
void ts_subtree_summarize_children(t_subtree, const TSLanguage *);
|
||||
void ts_subtree_balance(t_subtree, const TSLanguage *);
|
||||
char *ts_subtree_string(t_subtree, TSSymbol, bool, const TSLanguage *, bool include_all);
|
||||
t_subtree ts_subtree_last_external_token(t_subtree);
|
||||
const t_external_scanner_state *ts_subtree_external_scanner_state(t_subtree self);
|
||||
bool ts_subtree_external_scanner_state_eq(t_subtree, t_subtree);
|
||||
|
||||
static inline TSSymbol ts_subtree_symbol(t_subtree self)
|
||||
static inline t_symbol ts_subtree_symbol(t_subtree self)
|
||||
{
|
||||
return ((self)->symbol);
|
||||
}
|
||||
|
|
@ -87,7 +89,7 @@ static inline bool ts_subtree_is_keyword(t_subtree self)
|
|||
{
|
||||
return ((self)->is_keyword);
|
||||
}
|
||||
static inline TSStateId ts_subtree_parse_state(t_subtree self)
|
||||
static inline t_state_id ts_subtree_parse_state(t_subtree self)
|
||||
{
|
||||
return ((self)->parse_state);
|
||||
}
|
||||
|
|
@ -115,31 +117,31 @@ static inline void ts_subtree_set_extra(t_subtree *self, bool is_extra)
|
|||
(*self)->extra = is_extra;
|
||||
}
|
||||
|
||||
static inline TSSymbol ts_subtree_leaf_symbol(t_subtree self)
|
||||
static inline t_symbol ts_subtree_leaf_symbol(t_subtree self)
|
||||
{
|
||||
if (self->child_count == 0)
|
||||
return self->symbol;
|
||||
return self->first_leaf.symbol;
|
||||
}
|
||||
|
||||
static inline TSStateId ts_subtree_leaf_parse_state(t_subtree self)
|
||||
static inline t_state_id ts_subtree_leaf_parse_state(t_subtree self)
|
||||
{
|
||||
if (self->child_count == 0)
|
||||
return self->parse_state;
|
||||
return self->first_leaf.parse_state;
|
||||
}
|
||||
|
||||
static inline Length ts_subtree_padding(t_subtree self)
|
||||
static inline t_length ts_subtree_padding(t_subtree self)
|
||||
{
|
||||
return self->padding;
|
||||
}
|
||||
|
||||
static inline Length ts_subtree_size(t_subtree self)
|
||||
static inline t_length ts_subtree_size(t_subtree self)
|
||||
{
|
||||
return self->size;
|
||||
}
|
||||
|
||||
static inline Length ts_subtree_total_size(t_subtree self)
|
||||
static inline t_length ts_subtree_total_size(t_subtree self)
|
||||
{
|
||||
return (length_add(ts_subtree_padding(self), ts_subtree_size(self)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@
|
|||
struct s_tree
|
||||
{
|
||||
t_subtree root;
|
||||
const TSLanguage *language;
|
||||
const t_language *language;
|
||||
};
|
||||
|
||||
TSTree *ts_tree_new(t_subtree root, const TSLanguage *language);
|
||||
TSNode ts_node_new(const TSTree *, const t_subtree *, Length, TSSymbol);
|
||||
t_tree *ts_tree_new(t_subtree root, const t_language *language);
|
||||
t_node ts_node_new(const t_tree *, const t_subtree *, t_length, t_symbol);
|
||||
|
||||
#endif // TREE_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue