diff --git a/Minishell.mk b/Minishell.mk index 23cb8a38..4baef4b2 100644 --- a/Minishell.mk +++ b/Minishell.mk @@ -6,7 +6,7 @@ # By: maiboyer +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/04/28 17:28:30 by maiboyer #+# #+# # -# Updated: 2024/04/29 14:02:41 by maiboyer ### ########.fr # +# Updated: 2024/04/29 14:08:10 by maiboyer ### ########.fr # # # # **************************************************************************** # diff --git a/gen.list b/gen.list new file mode 100644 index 00000000..9d07c83a --- /dev/null +++ b/gen.list @@ -0,0 +1,3 @@ +src/vec/vec_parser_range.c +src/vec/vec_parser_range_functions2.c +src/vec/vec_parser_range_functions3.c diff --git a/input.toml b/input.toml new file mode 100644 index 00000000..86e0ac3f --- /dev/null +++ b/input.toml @@ -0,0 +1,46 @@ +[definition.vec] +headers = ["stdme/generic_sources/header/vec_C__PREFIX__.h__TEMPLATE__"] +sources = [ + "stdme/generic_sources/src/vec_C__PREFIX__.c__TEMPLATE__", + "stdme/generic_sources/src/vec_C__PREFIX___functions2.c__TEMPLATE__", + "stdme/generic_sources/src/vec_C__PREFIX___functions3.c__TEMPLATE__", +] +replace.C__TYPENAME__ = "type" +replace.C__TYPEHEADER__ = "header_include" +replace.C__PREFIX__ = "prefix" +replace.C__PREFIXUP__ = "prefix" + + +[definition.hashmap] +headers = ["stdme/generic_sources/header/hashmap_C__PREFIX__.h__TEMPLATE__"] +sources = [ + "stdme/generic_sources/src/hashmap_C__PREFIX__.c__TEMPLATE__", + "stdme/generic_sources/src/hashmap_C__PREFIX___utils.c__TEMPLATE__", +] +replace.C__VALTYPE__ = "type" +replace.C__KEYTYPE__ = "type" +replace.C__TYPEHEADER__ = "header_include" +replace.C__PREFIX__ = "prefix" +replace.C__PREFIXUP__ = "prefix" + +[definition.str_to_num] +headers = [] +sources = [ + "stdme/generic_sources/src/str_to_C__PREFIX__.c__TEMPLATE__", + "stdme/generic_sources/src/str_to_C__PREFIX___utils.c__TEMPLATE__", +] +replace.C__TYPE__ = "type" +replace.C__UNSIGNED_TYPE__ = "type" +replace.C__PREFIX__ = "prefix" +replace.C__MAX__ = "value" +replace.C__MIN__ = "value" +replace.C__ZERO__ = "value" +replace.C__SIGNED_TYPE__ = "bool" + +[[create.vec]] +sources_output = "src/vec/" +headers_output = "include/me/vec/" +replace.C__TYPENAME__ = "t_parser_range" +replace.C__TYPEHEADER__ = '#include "parser/types/types_parser_range.h"' +replace.C__PREFIX__ = "parser_range" +replace.C__PREFIXUP__ = "PARSER_RANGE" diff --git a/output/include/me/vec/vec_parser_range.h b/output/include/me/vec/vec_parser_range.h new file mode 100644 index 00000000..1eac9f77 --- /dev/null +++ b/output/include/me/vec/vec_parser_range.h @@ -0,0 +1,57 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* vec_parser_range.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/04 18:46:53 by maiboyer #+# #+# */ +/* Updated: 2023/12/09 17:53:00 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef VEC_PARSER_RANGE_H +#define VEC_PARSER_RANGE_H + +#include "parser/types/types_parser_range.h" +#include "me/types.h" + +typedef bool (*t_vec_parser_range_sort_fn)(t_parser_range *, t_parser_range *); +typedef void (*t_free_parser_range_item)(t_parser_range); + +typedef struct s_vec_parser_range +{ + t_free_parser_range_item free_func; + t_usize len; + t_usize capacity; + t_parser_range *buffer; +} t_vec_parser_range; + +t_vec_parser_range vec_parser_range_new(t_usize capacity, + t_free_parser_range_item free_function); +t_error vec_parser_range_push(t_vec_parser_range *vec, t_parser_range element); +t_error vec_parser_range_push_front(t_vec_parser_range *vec, + t_parser_range element); +t_error vec_parser_range_pop(t_vec_parser_range *vec, t_parser_range *value); +t_error vec_parser_range_pop_front(t_vec_parser_range *vec, t_parser_range *value); +void vec_parser_range_free(t_vec_parser_range vec); +t_error vec_parser_range_reserve(t_vec_parser_range *vec, + t_usize wanted_capacity); +t_error vec_parser_range_find(t_vec_parser_range *vec, + bool (*fn)(const t_parser_range *), t_usize *index); +t_error vec_parser_range_find_starting(t_vec_parser_range *vec, + bool (*fn)(const t_parser_range *), + t_usize starting_index, t_usize *index); +t_error vec_parser_range_all(t_vec_parser_range *vec, + bool (*fn)(const t_parser_range *), bool *result); +t_error vec_parser_range_any(t_vec_parser_range *vec, + bool (*fn)(const t_parser_range *), bool *result); +void vec_parser_range_iter(t_vec_parser_range *vec, + void (*fn)(t_usize index, t_parser_range *value, + void *state), + void *state); +void vec_parser_range_reverse(t_vec_parser_range *vec); +void vec_parser_range_sort(t_vec_parser_range *vec, + t_vec_parser_range_sort_fn is_sorted); + +#endif diff --git a/output/src/vec/vec_parser_range.c b/output/src/vec/vec_parser_range.c new file mode 100644 index 00000000..b3c18e5b --- /dev/null +++ b/output/src/vec/vec_parser_range.c @@ -0,0 +1,115 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* vec_parser_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/05 18:46:28 by maiboyer #+# #+# */ +/* Updated: 2023/12/09 17:54:11 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "me/mem/mem_alloc_array.h" +#include "me/mem/mem_copy.h" +#include "me/mem/mem_set_zero.h" +#include "me/types.h" +#include "me/vec/vec_parser_range.h" +#include + +t_vec_parser_range vec_parser_range_new(t_usize capacity, + t_free_parser_range_item free_function) +{ + t_vec_parser_range out; + + out = (t_vec_parser_range){0}; + out.free_func = free_function; + out.buffer = mem_alloc_array(capacity, sizeof(t_parser_range)); + if (out.buffer) + out.capacity = capacity; + return (out); +} + +/// Return true in case of an error +t_error vec_parser_range_push(t_vec_parser_range *vec, t_parser_range element) +{ + t_parser_range *temp_buffer; + size_t new_capacity; + + if (vec == NULL) + return (ERROR); + if (vec->len + 1 > vec->capacity) + { + new_capacity = (vec->capacity * 3) / 2 + 1; + while (vec->len + 1 > new_capacity) + new_capacity = (new_capacity * 3) / 2 + 1; + temp_buffer = mem_alloc_array(new_capacity, sizeof(t_parser_range)); + if (temp_buffer == NULL) + return (ERROR); + mem_copy(temp_buffer, vec->buffer, vec->len * sizeof(t_parser_range)); + free(vec->buffer); + vec->buffer = temp_buffer; + vec->capacity = new_capacity; + } + vec->buffer[vec->len] = element; + vec->len += 1; + return (NO_ERROR); +} + +/// Return true in case of an error +t_error vec_parser_range_reserve(t_vec_parser_range *vec, t_usize wanted_capacity) +{ + t_parser_range *temp_buffer; + size_t new_capacity; + + if (vec == NULL) + return (ERROR); + if (wanted_capacity > vec->capacity) + { + new_capacity = (vec->capacity * 3) / 2 + 1; + while (wanted_capacity > new_capacity) + new_capacity = (new_capacity * 3) / 2 + 1; + temp_buffer = mem_alloc_array(new_capacity, sizeof(t_parser_range)); + if (temp_buffer == NULL) + return (ERROR); + mem_copy(temp_buffer, vec->buffer, vec->len * sizeof(t_parser_range)); + free(vec->buffer); + vec->buffer = temp_buffer; + vec->capacity = new_capacity; + } + return (NO_ERROR); +} + +/// Return true if the vector is empty +/// This function is safe to call with value being NULL +t_error vec_parser_range_pop(t_vec_parser_range *vec, t_parser_range *value) +{ + t_parser_range temp_value; + t_parser_range *ptr; + + if (vec == NULL) + return (ERROR); + ptr = value; + if (vec->len == 0) + return (ERROR); + if (value == NULL) + ptr = &temp_value; + vec->len--; + *ptr = vec->buffer[vec->len]; + mem_set_zero(&vec->buffer[vec->len], sizeof(t_parser_range)); + return (NO_ERROR); +} + +/// This function is safe to call with `free_elem` being NULL +void vec_parser_range_free(t_vec_parser_range vec) +{ + if (vec.free_func) + { + while (vec.len) + { + vec.free_func(vec.buffer[vec.len - 1]); + vec.len--; + } + } + free(vec.buffer); +} diff --git a/output/src/vec/vec_parser_range_functions2.c b/output/src/vec/vec_parser_range_functions2.c new file mode 100644 index 00000000..b93ed9db --- /dev/null +++ b/output/src/vec/vec_parser_range_functions2.c @@ -0,0 +1,112 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* vec_parser_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */ +/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "me/mem/mem_alloc_array.h" +#include "me/mem/mem_copy.h" +#include "me/mem/mem_set_zero.h" +#include "me/types.h" +#include "me/vec/vec_parser_range.h" +#include + +t_error vec_parser_range_find(t_vec_parser_range *vec, + bool (*fn)(const t_parser_range *), t_usize *index) +{ + t_usize idx; + + if (vec == NULL || fn == NULL || index == NULL) + return (ERROR); + idx = 0; + while (idx < vec->len) + { + if (fn(&vec->buffer[idx])) + { + *index = idx; + return (NO_ERROR); + } + idx++; + } + return (ERROR); +} + +t_error vec_parser_range_find_starting(t_vec_parser_range *vec, + bool (*fn)(const t_parser_range *), + t_usize starting_index, t_usize *index) +{ + t_usize idx; + + if (vec == NULL || fn == NULL || index == NULL) + return (ERROR); + idx = starting_index; + while (idx < vec->len) + { + if (fn(&vec->buffer[idx])) + { + *index = idx; + return (NO_ERROR); + } + idx++; + } + return (ERROR); +} + +t_error vec_parser_range_all(t_vec_parser_range *vec, + bool (*fn)(const t_parser_range *), bool *result) +{ + t_usize idx; + + if (vec == NULL || fn == NULL || result == NULL) + return (ERROR); + idx = 0; + *result = true; + while (*result && idx < vec->len) + { + if (!fn(&vec->buffer[idx])) + *result = false; + idx++; + } + return (ERROR); +} + +t_error vec_parser_range_any(t_vec_parser_range *vec, + bool (*fn)(const t_parser_range *), bool *result) +{ + t_usize idx; + + if (vec == NULL || fn == NULL || result == NULL) + return (ERROR); + idx = 0; + *result = false; + while (*result && idx < vec->len) + { + if (fn(&vec->buffer[idx])) + *result = true; + idx++; + } + return (ERROR); +} + +void vec_parser_range_iter(t_vec_parser_range *vec, + void (*fn)(t_usize index, t_parser_range *value, + void *state), + void *state) +{ + t_usize idx; + + if (vec == NULL || fn == NULL) + return; + idx = 0; + while (idx < vec->len) + { + fn(idx, &vec->buffer[idx], state); + idx++; + } +} diff --git a/output/src/vec/vec_parser_range_functions3.c b/output/src/vec/vec_parser_range_functions3.c new file mode 100644 index 00000000..b7c4446e --- /dev/null +++ b/output/src/vec/vec_parser_range_functions3.c @@ -0,0 +1,73 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* vec_parser_range.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2023/12/30 17:59:28 by maiboyer #+# #+# */ +/* Updated: 2023/12/30 17:59:28 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "me/mem/mem_alloc_array.h" +#include "me/mem/mem_copy.h" +#include "me/mem/mem_set_zero.h" +#include "me/types.h" +#include "me/vec/vec_parser_range.h" +#include + +t_error vec_parser_range_push_front(t_vec_parser_range *vec, + t_parser_range element) +{ + t_usize i; + + if (vec->len == 0) + return (vec_parser_range_push(vec, element)); + i = vec->len - 1; + if (vec->capacity < vec->len + 1 && + vec_parser_range_reserve(vec, 3 * vec->len / 2 + 1)) + return (ERROR); + while (i > 0) + { + vec->buffer[i + 1] = vec->buffer[i]; + i--; + } + vec->buffer[1] = vec->buffer[0]; + vec->buffer[0] = element; + vec->len++; + return (NO_ERROR); +} + +t_error vec_parser_range_pop_front(t_vec_parser_range *vec, t_parser_range *value) +{ + t_usize i; + + if (vec->len <= 1) + return (vec_parser_range_pop(vec, value)); + i = 0; + *value = vec->buffer[0]; + vec->len--; + while (i < vec->len) + { + vec->buffer[i] = vec->buffer[i + 1]; + i++; + } + mem_set_zero(&vec->buffer[i], sizeof(*vec->buffer)); + return (NO_ERROR); +} + +void vec_parser_range_reverse(t_vec_parser_range *vec) +{ + t_parser_range temporary; + t_usize i; + + i = 0; + while (i < vec->len / 2) + { + temporary = vec->buffer[vec->len - 1 - i]; + vec->buffer[vec->len - 1 - i] = vec->buffer[i]; + vec->buffer[i] = temporary; + i++; + } +} diff --git a/parser/Makefile b/parser/Makefile index ea7b3e3a..91965b94 100644 --- a/parser/Makefile +++ b/parser/Makefile @@ -6,11 +6,11 @@ # By: maiboyer +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/03 13:20:01 by maiboyer #+# #+# # -# Updated: 2024/04/28 20:00:24 by maiboyer ### ########.fr # +# Updated: 2024/04/29 14:31:52 by maiboyer ### ########.fr # # # # **************************************************************************** # -BUILD_DIR = ./build +BUILD_DIR = ../build SRC_DIR = ./ BONUS_FLAGS = @@ -18,7 +18,7 @@ NAME = libgmr.a LIB_NAME ?= TARGET = $(BUILD_DIR)/$(NAME) CC = cc -CFLAGS = -Wall -Wextra -Werror -g3 -MMD -I./includes +CFLAGS = -Wall -Wextra -Werror -g3 -MMD -I./includes -I../includes -I../output/include include ./Filelist.mk diff --git a/parser/includes/api.h b/parser/includes/api.h index 1ed276b3..ef50fdb8 100644 --- a/parser/includes/api.h +++ b/parser/includes/api.h @@ -5,6 +5,8 @@ #include #include +#include "me/vec/vec_parser_range.h" + /****************************/ /* Section - ABI Versioning */ /****************************/ @@ -51,24 +53,10 @@ typedef enum TSSymbolType TSSymbolTypeAuxiliary, } TSSymbolType; -typedef struct TSPoint -{ - uint32_t row; - uint32_t column; -} TSPoint; - -typedef struct TSRange -{ - TSPoint start_point; - TSPoint end_point; - uint32_t start_byte; - uint32_t end_byte; -} TSRange; - typedef struct TSInput { void *payload; - const char *(*read)(void *payload, uint32_t byte_index, TSPoint position, + const char *(*read)(void *payload, uint32_t byte_index, t_point position, uint32_t *bytes_read); TSInputEncoding encoding; } TSInput; @@ -90,9 +78,9 @@ typedef struct TSInputEdit uint32_t start_byte; uint32_t old_end_byte; uint32_t new_end_byte; - TSPoint start_point; - TSPoint old_end_point; - TSPoint new_end_point; + t_point start_point; + t_point old_end_point; + t_point new_end_point; } TSInputEdit; typedef struct TSNode @@ -210,7 +198,7 @@ bool ts_parser_set_language(TSParser *self, const TSLanguage *language); * will not be assigned, and this function will return `false`. On success, * this function returns `true` */ -bool ts_parser_set_included_ranges(TSParser *self, const TSRange *ranges, +bool ts_parser_set_included_ranges(TSParser *self, const t_parser_range *ranges, uint32_t count); /** @@ -220,7 +208,8 @@ bool ts_parser_set_included_ranges(TSParser *self, const TSRange *ranges, * it or write to it. The length of the array will be written to the given * `count` pointer. */ -const TSRange *ts_parser_included_ranges(const TSParser *self, uint32_t *count); +const t_parser_range *ts_parser_included_ranges(const TSParser *self, + uint32_t *count); /** * Use the parser to parse some source code and create a syntax tree. @@ -387,7 +376,7 @@ TSNode ts_tree_root_node(const TSTree *self); * shifted forward by the given offset. */ TSNode ts_tree_root_node_with_offset(const TSTree *self, uint32_t offset_bytes, - TSPoint offset_extent); + t_point offset_extent); /** * Get the language that was used to parse the syntax tree. @@ -399,7 +388,7 @@ const TSLanguage *ts_tree_language(const TSTree *self); * * The returned pointer must be freed by the caller. */ -TSRange *ts_tree_included_ranges(const TSTree *self, uint32_t *length); +t_parser_range *ts_tree_included_ranges(const TSTree *self, uint32_t *length); /** * Edit the syntax tree to keep it in sync with source code that has been @@ -425,8 +414,9 @@ void ts_tree_edit(TSTree *self, const TSInputEdit *edit); * responsible for freeing it using `free`. The length of the array will be * written to the given `length` pointer. */ -TSRange *ts_tree_get_changed_ranges(const TSTree *old_tree, - const TSTree *new_tree, uint32_t *length); +t_parser_range *ts_tree_get_changed_ranges(const TSTree *old_tree, + const TSTree *new_tree, + uint32_t *length); /** * Write a DOT graph describing the syntax tree to the given file. @@ -474,7 +464,7 @@ uint32_t ts_node_start_byte(TSNode self); /** * Get the node's start position in terms of rows and columns. */ -TSPoint ts_node_start_point(TSNode self); +t_point ts_node_start_point(TSNode self); /** * Get the node's end byte. @@ -484,7 +474,7 @@ uint32_t ts_node_end_byte(TSNode self); /** * Get the node's end position in terms of rows and columns. */ -TSPoint ts_node_end_point(TSNode self); +t_point ts_node_end_point(TSNode self); /** * Get an S-expression representing the node as a string. @@ -629,8 +619,8 @@ uint32_t ts_node_descendant_count(TSNode self); */ TSNode ts_node_descendant_for_byte_range(TSNode self, uint32_t start, uint32_t end); -TSNode ts_node_descendant_for_point_range(TSNode self, TSPoint start, - TSPoint end); +TSNode ts_node_descendant_for_point_range(TSNode self, t_point start, + t_point end); /** * Get the smallest named node within this node that spans the given range @@ -638,8 +628,8 @@ TSNode ts_node_descendant_for_point_range(TSNode self, TSPoint start, */ TSNode ts_node_named_descendant_for_byte_range(TSNode self, uint32_t start, uint32_t end); -TSNode ts_node_named_descendant_for_point_range(TSNode self, TSPoint start, - TSPoint end); +TSNode ts_node_named_descendant_for_point_range(TSNode self, t_point start, + t_point end); /** * Edit the node to keep it in-sync with source code that has been edited. @@ -790,7 +780,7 @@ uint32_t ts_tree_cursor_current_depth(const TSTreeCursor *self); int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *self, uint32_t goal_byte); int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self, - TSPoint goal_point); + t_point goal_point); TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *cursor); @@ -976,8 +966,8 @@ void ts_query_cursor_set_match_limit(TSQueryCursor *self, uint32_t limit); */ void ts_query_cursor_set_byte_range(TSQueryCursor *self, uint32_t start_byte, uint32_t end_byte); -void ts_query_cursor_set_point_range(TSQueryCursor *self, TSPoint start_point, - TSPoint end_point); +void ts_query_cursor_set_point_range(TSQueryCursor *self, t_point start_point, + t_point end_point); /** * Advance to the next match of the currently running query. diff --git a/parser/includes/parser.h b/parser/includes/parser.h index 65ff0678..72451ada 100644 --- a/parser/includes/parser.h +++ b/parser/includes/parser.h @@ -9,48 +9,4 @@ #define TREE_SITTER_SERIALIZATION_BUFFER_SIZE 1024 -typedef struct s_language t_language; -typedef struct s_scanner -{ - const bool *states; - const t_symbol *symbol_map; - void *(*create)(void); - void (*destroy)(void *); - bool (*scan)(void *, t_lexer *, const bool *symbol_whitelist); - unsigned (*serialize)(void *, char *); - void (*deserialize)(void *, const char *, unsigned); -} t_scanner; - -struct s_language -{ - uint32_t version; - uint32_t symbol_count; - uint32_t alias_count; - uint32_t token_count; - uint32_t external_token_count; - uint32_t state_count; - uint32_t large_state_count; - uint32_t production_id_count; - uint32_t field_count; - uint16_t max_alias_sequence_length; - const uint16_t *parse_table; - const uint16_t *small_parse_table; - const uint32_t *small_parse_table_map; - const t_parse_action_entry *parse_actions; - const char *const *symbol_names; - const char *const *field_names; - const t_field_map_slice *field_map_slices; - const t_field_map_entry *field_map_entries; - const t_symbol_metadata *symbol_metadata; - const t_symbol *public_symbol_map; - const uint16_t *alias_map; - const t_symbol *alias_sequences; - const t_lex_modes *lex_modes; - bool (*lex_fn)(t_lexer *, t_state_id); - bool (*keyword_lex_fn)(t_lexer *, t_state_id); - t_symbol keyword_capture_token; - t_scanner external_scanner; - const t_state_id *primary_state_ids; -}; - #endif // TREE_SITTER_PARSER_H_ diff --git a/parser/includes/types/types_char_range.h b/parser/includes/types/types_char_range.h new file mode 100644 index 00000000..14e680c5 --- /dev/null +++ b/parser/includes/types/types_char_range.h @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_char_range.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 15:03:34 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 15:27:38 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_CHAR_RANGE_H +# define TYPES_CHAR_RANGE_H + +# include "me/types.h" + +typedef struct s_char_range +{ + t_i32 start; + t_i32 end; +} t_char_range; + +#endif /* TYPES_CHAR_RANGE_H */ diff --git a/parser/includes/types/types_field_entry.h b/parser/includes/types/types_field_entry.h new file mode 100644 index 00000000..06566509 --- /dev/null +++ b/parser/includes/types/types_field_entry.h @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_field_entry.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:51:21 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 15:35:36 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_FIELD_ENTRY_H +# define TYPES_FIELD_ENTRY_H + +# include "parser/types/types_field_id.h" + +typedef struct s_field_map_entry +{ + t_field_id field_id; + t_u8 child_index; + bool inherited; +} t_field_map_entry; + +#endif /* TYPES_FIELD_ENTRY_H */ diff --git a/parser/includes/types/types_field_id.h b/parser/includes/types/types_field_id.h new file mode 100644 index 00000000..5391a957 --- /dev/null +++ b/parser/includes/types/types_field_id.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_field_id.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:44:38 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:44:44 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_FIELD_ID_H +# define TYPES_FIELD_ID_H + +# include "me/types.h" + +typedef t_u16 t_field_id; + +#endif /* TYPES_FIELD_ID_H */ diff --git a/parser/includes/types/types_field_map_entry.h b/parser/includes/types/types_field_map_entry.h new file mode 100644 index 00000000..162504a1 --- /dev/null +++ b/parser/includes/types/types_field_map_entry.h @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_field_map_entry.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:51:45 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:53:31 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_FIELD_MAP_ENTRY_H +# define TYPES_FIELD_MAP_ENTRY_H + +# include "me/types.h" +# include "parser/types/types_field_id.h" + +typedef struct s_field_map_entry +{ + t_field_id field_id; + t_u8 child_index; + bool inherited; +} t_field_map_entry; + +#endif /* TYPES_FIELD_MAP_ENTRY_H */ diff --git a/parser/includes/types/types_field_map_slice.h b/parser/includes/types/types_field_map_slice.h new file mode 100644 index 00000000..26d55da2 --- /dev/null +++ b/parser/includes/types/types_field_map_slice.h @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_field_map_slice.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:54:41 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 15:08:21 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_FIELD_MAP_SLICE_H +# define TYPES_FIELD_MAP_SLICE_H + +# include "me/types.h" + +typedef struct s_field_map_slice +{ + t_u16 index; + t_u16 length; +} t_field_map_slice; + +#endif /* TYPES_FIELD_MAP_SLICE_H */ diff --git a/parser/includes/types/types_language.h b/parser/includes/types/types_language.h new file mode 100644 index 00000000..a65e31ec --- /dev/null +++ b/parser/includes/types/types_language.h @@ -0,0 +1,61 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_language.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:39:37 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 15:36:47 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_LANGUAGE_H +# define TYPES_LANGUAGE_H + +# include "me/types.h" +# include "parser/types/types_field_map_entry.h" +# include "parser/types/types_field_map_slice.h" +# include "parser/types/types_lex_modes.h" +# include "parser/types/types_lexer.h" +# include "parser/types/types_parse_action_entry.h" +# include "parser/types/types_scanner.h" +# include "parser/types/types_state_id.h" +# include "parser/types/types_symbol.h" +# include "parser/types/types_symbol_metadata.h" + +typedef bool (*t_lex_fn)(t_lexer *lex, t_state_id state); + +typedef struct s_language +{ + t_u32 version; + t_u32 symbol_count; + t_u32 alias_count; + t_u32 token_count; + t_u32 external_token_count; + t_u32 state_count; + t_u32 large_state_count; + t_u32 production_id_count; + t_u32 field_count; + t_u16 max_alias_sequence_length; + const t_u16 *parse_table; + const t_u16 *small_parse_table; + const t_u32 *small_parse_table_map; + const t_parse_action_entry *parse_actions; + const t_const_str *symbol_names; + const t_const_str *field_names; + const t_field_map_slice *field_map_slices; + const t_field_map_entry *field_map_entries; + const t_symbol_metadata *symbol_metadata; + const t_symbol *public_symbol_map; + const t_u16 *alias_map; + const t_symbol *alias_sequences; + const t_lex_modes *lex_modes; + t_lex_fn lex_fn; + t_lex_fn keyword_lex_fn; + t_symbol keyword_capture_token; + t_scanner external_scanner; + const t_state_id *primary_state_ids; +} t_language; + +#endif /* TYPES_LANGUAGE_H */ diff --git a/parser/includes/types/types_lex_modes.h b/parser/includes/types/types_lex_modes.h new file mode 100644 index 00000000..d9dd61d6 --- /dev/null +++ b/parser/includes/types/types_lex_modes.h @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_lex_modes.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 15:01:24 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 15:01:31 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_LEX_MODES_H +# define TYPES_LEX_MODES_H + +# include "me/types.h" + +typedef struct s_lex_modes +{ + t_u16 lex_state; + t_u16 external_lex_state; +} t_lex_modes; + +#endif /* TYPES_LEX_MODES_H */ diff --git a/parser/includes/types/types_lexer.h b/parser/includes/types/types_lexer.h new file mode 100644 index 00000000..601f2a34 --- /dev/null +++ b/parser/includes/types/types_lexer.h @@ -0,0 +1,30 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_lexer.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:45:45 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:46:48 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_LEXER_H +# define TYPES_LEXER_H + +# include "me/types.h" +# include "parser/types/types_symbol.h" + +typedef struct s_lexer +{ + t_u32 lookahead; + t_symbol result_symbol; + void (*advance)(struct s_lexer *, bool); + void (*mark_end)(struct s_lexer *); + t_u32 (*get_column)(struct s_lexer *); + bool (*is_at_included_range_start)(const struct s_lexer *); + bool (*eof)(const struct s_lexer *); +} t_lexer; + +#endif /* TYPES_LEXER_H */ diff --git a/parser/includes/types/types_lexer_state.h b/parser/includes/types/types_lexer_state.h new file mode 100644 index 00000000..a6e6e465 --- /dev/null +++ b/parser/includes/types/types_lexer_state.h @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_lexer_state.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:50:20 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:51:00 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_LEXER_STATE_H +# define TYPES_LEXER_STATE_H + +# include "me/types.h" +# include "parser/types/types_state_id.h" + +typedef struct s_lexer_state +{ + t_u32 lookahead; + t_state_id state; + bool result; + bool skip; + bool eof; +} t_lexer_state; + +#endif /* TYPES_LEXER_STATE_H */ diff --git a/parser/includes/types/types_parse_action_entry.h b/parser/includes/types/types_parse_action_entry.h new file mode 100644 index 00000000..89aa5ee2 --- /dev/null +++ b/parser/includes/types/types_parse_action_entry.h @@ -0,0 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_parse_action_entry.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 15:01:57 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 15:03:13 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_PARSE_ACTION_ENTRY_H +# define TYPES_PARSE_ACTION_ENTRY_H + +# include "me/types.h" +# include "parser/types/types_parse_actions.h" + +struct s_parse_actions_entry_entry +{ + t_u8 count; + bool reusable; +}; + +typedef union u_parse_actions_entry +{ + t_parse_actions action; + struct s_parse_actions_entry_entry entry; +} t_parse_action_entry; + +#endif /* TYPES_PARSE_ACTION_ENTRY_H */ diff --git a/parser/includes/types/types_parse_action_type.h b/parser/includes/types/types_parse_action_type.h new file mode 100644 index 00000000..751bde31 --- /dev/null +++ b/parser/includes/types/types_parse_action_type.h @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_parse_action_type.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:57:22 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:57:32 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_PARSE_ACTION_TYPE_H +# define TYPES_PARSE_ACTION_TYPE_H + +typedef enum e_parse_action_type +{ + ActionTypeShift, + ActionTypeReduce, + ActionTypeAccept, + ActionTypeRecover, +} t_parse_action_type; + +#endif /* TYPES_PARSE_ACTION_TYPE_H */ diff --git a/parser/includes/types/types_parse_actions.h b/parser/includes/types/types_parse_actions.h new file mode 100644 index 00000000..916f1679 --- /dev/null +++ b/parser/includes/types/types_parse_actions.h @@ -0,0 +1,44 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_parse_actions.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:58:36 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 15:00:51 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_PARSE_ACTIONS_H +# define TYPES_PARSE_ACTIONS_H + +# include "me/types.h" +# include "parser/types/types_state_id.h" +# include "parser/types/types_symbol.h" + +struct s_parse_action_shift +{ + t_u8 type; + t_state_id state; + bool extra; + bool repetition; +}; + +struct s_parse_action_reduce +{ + t_u8 type; + t_u8 child_count; + t_symbol symbol; + t_i16 dynamic_precedence; + t_u16 production_id; +}; + +typedef union u_parse_actions +{ + struct s_parse_action_shift shift; + struct s_parse_action_reduce reduce; + t_u8 type; +} t_parse_actions; + +#endif /* TYPES_PARSE_ACTIONS_H */ diff --git a/parser/includes/types/types_parser_node.h b/parser/includes/types/types_parser_node.h new file mode 100644 index 00000000..7aff2dbd --- /dev/null +++ b/parser/includes/types/types_parser_node.h @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_parser_node.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:36:46 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:37:36 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_PARSER_NODE_H +# define TYPES_PARSER_NODE_H + +# include "me/types.h" +# include "parser/types/types_parser_tree.h" + +typedef struct s_parser_node +{ + t_u32 context[4]; + const void *id; + const t_parser_tree *tree; +} t_parser_node; + +#endif /* TYPES_PARSER_NODE_H */ diff --git a/parser/includes/types/types_parser_range.h b/parser/includes/types/types_parser_range.h new file mode 100644 index 00000000..b7bd3507 --- /dev/null +++ b/parser/includes/types/types_parser_range.h @@ -0,0 +1,28 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_parser_range.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:11:26 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:25:11 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_PARSER_RANGE_H +# define TYPES_PARSER_RANGE_H + +# include "me/types.h" +# include "parser/types/types_point.h" + +typedef struct s_parser_range +{ + t_point start_point; + t_point end_point; + t_u32 start_byte; + t_u32 end_byte; + +} t_parser_range; + +#endif /* TYPES_PARSER_RANGE_H */ diff --git a/parser/includes/types/types_parser_subtree.h b/parser/includes/types/types_parser_subtree.h new file mode 100644 index 00000000..47e8c2e1 --- /dev/null +++ b/parser/includes/types/types_parser_subtree.h @@ -0,0 +1,16 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_parser_subtree.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:49:40 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:49:40 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_PARSER_SUBTREE_H +# define TYPES_PARSER_SUBTREE_H + +#endif /* TYPES_PARSER_SUBTREE_H */ diff --git a/parser/includes/types/types_parser_tree.h b/parser/includes/types/types_parser_tree.h new file mode 100644 index 00000000..cae03176 --- /dev/null +++ b/parser/includes/types/types_parser_tree.h @@ -0,0 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_parser_tree.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:37:41 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:49:20 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_PARSER_TREE_H +# define TYPES_PARSER_TREE_H + +# include "me/types.h" +# include "parser/types/types_language.h" +# include "parser/types/types_parser_range.h" +# include "parser/types/types_parser_subtree.h" + +typedef struct s_parser_tree +{ + t_parser_subtree root; + const t_language *language; + t_parser_range *included_ranges; + t_i32 included_range_count; +} t_parser_tree; + +#endif /* TYPES_PARSER_TREE_H */ diff --git a/parser/includes/types/types_point.h b/parser/includes/types/types_point.h new file mode 100644 index 00000000..c5ad853c --- /dev/null +++ b/parser/includes/types/types_point.h @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_point.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:20:34 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:21:16 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_POINT_H +# define TYPES_POINT_H + +# include "me/types.h" + +typedef struct s_point +{ + t_u32 row; + t_u32 column; +} t_point; + +#endif /* TYPES_POINT_H */ diff --git a/parser/includes/types/types_scanner.h b/parser/includes/types/types_scanner.h new file mode 100644 index 00000000..4ec77a65 --- /dev/null +++ b/parser/includes/types/types_scanner.h @@ -0,0 +1,39 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_scanner.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:42:52 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 15:34:21 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_SCANNER_H +# define TYPES_SCANNER_H + +# include "me/types.h" +# include "parser/types/types_lexer.h" +# include "parser/types/types_symbol.h" + +typedef bool (*t_scanner_scan)(void *self, t_lexer *lex, + const bool *symbol_whitelist); +typedef void *(*t_scanner_create)(void); +typedef void (*t_scanner_destroy)(void *ctx); +typedef unsigned (*t_scanner_serialize)(void *self, t_str s); +typedef void (*t_scanner_deserialize)(void *self, t_const_str s, + t_u32 len); + +typedef struct s_scanner +{ + const bool *states; + const t_symbol *symbol_map; + t_scanner_create create; + t_scanner_destroy destroy; + t_scanner_scan scan; + t_scanner_serialize serialize; + t_scanner_deserialize deserialize; +} t_scanner; + +#endif /* TYPES_SCANNER_H */ diff --git a/parser/includes/types/types_state_id.h b/parser/includes/types/types_state_id.h new file mode 100644 index 00000000..43b722ac --- /dev/null +++ b/parser/includes/types/types_state_id.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_state_id.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:44:15 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:44:47 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_STATE_ID_H +# define TYPES_STATE_ID_H + +# include "me/types.h" + +typedef t_u16 t_state_id; + +#endif /* TYPES_STATE_ID_H */ diff --git a/parser/includes/types/types_symbol.h b/parser/includes/types/types_symbol.h new file mode 100644 index 00000000..c9855e26 --- /dev/null +++ b/parser/includes/types/types_symbol.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_symbol.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:43:33 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:44:50 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_SYMBOL_H +# define TYPES_SYMBOL_H + +# include "me/types.h" + +typedef t_u16 t_symbol; + +#endif /* TYPES_SYMBOL_H */ diff --git a/parser/includes/types/types_symbol_metadata.h b/parser/includes/types/types_symbol_metadata.h new file mode 100644 index 00000000..69bfeb81 --- /dev/null +++ b/parser/includes/types/types_symbol_metadata.h @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* types_symbol_metadata.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/04/29 14:55:57 by maiboyer #+# #+# */ +/* Updated: 2024/04/29 14:56:04 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef TYPES_SYMBOL_METADATA_H +# define TYPES_SYMBOL_METADATA_H + +# include "me/types.h" + +typedef struct s_symbol_metadata +{ + bool visible; + bool named; + bool supertype; +} t_symbol_metadata; + +#endif /* TYPES_SYMBOL_METADATA_H */ diff --git a/parser/parse_types.h b/parser/parse_types.h index 7c5d651b..98e1c8a1 100644 --- a/parser/parse_types.h +++ b/parser/parse_types.h @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/04/24 23:01:45 by maiboyer #+# #+# */ -/* Updated: 2024/04/26 18:05:40 by maiboyer ### ########.fr */ +/* Updated: 2024/04/29 15:26:51 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -16,34 +16,27 @@ #include #include -typedef uint16_t t_state_id; -typedef uint16_t t_symbol; -typedef uint16_t t_field_id; - -typedef struct s_lexer t_lexer; - #define ts_builtin_sym_end 0 #define ts_builtin_sym_error -1 -struct s_lexer -{ - int32_t lookahead; - t_symbol result_symbol; - void (*advance)(t_lexer *, bool); - void (*mark_end)(t_lexer *); - uint32_t (*get_column)(t_lexer *); - bool (*is_at_included_range_start)(const t_lexer *); - bool (*eof)(const t_lexer *); -}; - -typedef struct s_lexer_state -{ - int32_t lookahead; - t_state_id state; - bool result; - bool skip; - bool eof; -} t_lexer_state; +#include "me/types.h" +#include "parser/types/types_field_id.h" +#include "parser/types/types_field_map_entry.h" +#include "parser/types/types_field_map_slice.h" +#include "parser/types/types_language.h" +#include "parser/types/types_lex_modes.h" +#include "parser/types/types_lexer.h" +#include "parser/types/types_lexer_state.h" +#include "parser/types/types_parse_action_entry.h" +#include "parser/types/types_parse_action_type.h" +#include "parser/types/types_parse_actions.h" +#include "parser/types/types_parser_range.h" +#include "parser/types/types_point.h" +#include "parser/types/types_scanner.h" +#include "parser/types/types_state_id.h" +#include "parser/types/types_symbol.h" +#include "parser/types/types_symbol_metadata.h" +#include "parser/types/types_char_range.h" static inline bool lex_skip(t_state_id state_value, t_lexer *lexer, t_lexer_state *s) @@ -78,13 +71,6 @@ static inline bool lex_end_state(t_lexer *lexer, t_lexer_state *s) return (false); }; -typedef struct -{ - t_field_id field_id; - uint8_t child_index; - bool inherited; -} t_field_map_entry; - static inline t_field_map_entry fmap_entry(t_field_id field_id, uint8_t child_index, bool inherited) { @@ -95,13 +81,7 @@ static inline t_field_map_entry fmap_entry(t_field_id field_id, }); }; -typedef struct -{ - uint16_t index; - uint16_t length; -} t_field_map_slice; - -static inline t_field_map_slice fmap_slice(uint16_t index, uint16_t length) +static inline t_field_map_slice fmap_slice(t_u16 index, t_u16 length) { return ((t_field_map_slice){ .index = index, @@ -109,15 +89,8 @@ static inline t_field_map_slice fmap_slice(uint16_t index, uint16_t length) }); }; -typedef struct -{ - bool visible; - bool named; - bool supertype; -} t_symbol_metadata; - static inline t_symbol_metadata sym_metadata(bool visible, bool named, - bool supertype) + bool supertype) { return ((t_symbol_metadata){ .visible = visible, @@ -126,48 +99,6 @@ static inline t_symbol_metadata sym_metadata(bool visible, bool named, }); }; -typedef enum -{ - ActionTypeShift, - ActionTypeReduce, - ActionTypeAccept, - ActionTypeRecover, -} t_parse_action_type; - -typedef union { - struct - { - uint8_t type; - t_state_id state; - bool extra; - bool repetition; - } shift; - struct - { - uint8_t type; - uint8_t child_count; - t_symbol symbol; - int16_t dynamic_precedence; - uint16_t production_id; - } reduce; - uint8_t type; -} t_parse_actions; - -typedef struct -{ - uint16_t lex_state; - uint16_t external_lex_state; -} t_lex_modes; - -typedef union { - t_parse_actions action; - struct - { - uint8_t count; - bool reusable; - } entry; -} t_parse_action_entry; - static inline t_parse_action_entry entry(uint8_t count, bool reusable) { return ((t_parse_action_entry){ @@ -198,7 +129,7 @@ static inline t_parse_action_entry shift_extra(void) static inline t_parse_action_entry reduce( t_symbol symbol, uint8_t child_count, int16_t dynamic_precedence, - uint16_t production_id) + t_u16 production_id) { return ( (t_parse_action_entry){{.reduce = { @@ -220,21 +151,15 @@ static inline t_parse_action_entry accept(void) return ((t_parse_action_entry){{.type = ActionTypeAccept}}); }; -typedef struct s_char_range -{ - int32_t start; - int32_t end; -} t_char_range; - -static inline bool set_contains(t_char_range *ranges, uint32_t len, +static inline bool set_contains(t_char_range *ranges, t_u32 len, int32_t lookahead) { - uint32_t index = 0; - uint32_t size = len - index; + t_u32 index = 0; + t_u32 size = len - index; while (size > 1) { - uint32_t half_size = size / 2; - uint32_t mid_index = index + half_size; + t_u32 half_size = size / 2; + t_u32 mid_index = index + half_size; t_char_range *range = &ranges[mid_index]; if (lookahead >= range->start && lookahead <= range->end) { @@ -250,16 +175,16 @@ static inline bool set_contains(t_char_range *ranges, uint32_t len, return (lookahead >= range->start && lookahead <= range->end); }; -static inline bool advance_map_inner(uint32_t *map, uint32_t elems, t_lexer *l, +static inline bool advance_map_inner(t_u32 *map, t_u32 elems, t_lexer *l, t_lexer_state *s) { - uint32_t i; - + t_u32 i; + (void)(l); i = 0; while (i < elems) { - if (map[i] == (uint32_t)s->lookahead) + if (map[i] == (t_u32)s->lookahead) { s->state = map[i + 1]; return true; @@ -269,8 +194,8 @@ static inline bool advance_map_inner(uint32_t *map, uint32_t elems, t_lexer *l, return (false); }; -static inline t_lex_modes lex_mode_external(uint16_t lex_state, - uint16_t ext_lex_state) +static inline t_lex_modes lex_mode_external(t_u16 lex_state, + t_u16 ext_lex_state) { return ((t_lex_modes){ .lex_state = lex_state, @@ -278,19 +203,19 @@ static inline t_lex_modes lex_mode_external(uint16_t lex_state, }); }; -static inline t_lex_modes lex_mode_normal(uint16_t lex_state) +static inline t_lex_modes lex_mode_normal(t_u16 lex_state) { return ((t_lex_modes){ .lex_state = lex_state, }); }; -static inline uint16_t actions(uint16_t val) +static inline t_u16 actions(t_u16 val) { return (val); }; -static inline uint16_t state(uint16_t val) +static inline t_u16 state(t_u16 val) { return (val); }; diff --git a/parser/src/language.c b/parser/src/language.c index f193e50b..efdc43cf 100644 --- a/parser/src/language.c +++ b/parser/src/language.c @@ -1,5 +1,5 @@ #include "./language.h" -#include "api.h" +#include "parser/api.h" #include const TSLanguage *ts_language_copy(const TSLanguage *self) { diff --git a/parser/src/length.h b/parser/src/length.h index dbae5ced..73812b13 100644 --- a/parser/src/length.h +++ b/parser/src/length.h @@ -4,11 +4,11 @@ #include #include #include "./point.h" -#include "api.h" +#include "parser/api.h" typedef struct { uint32_t bytes; - TSPoint extent; + t_point extent; } Length; static const Length LENGTH_UNDEFINED = {0, {0, 1}}; diff --git a/parser/src/lexer.c b/parser/src/lexer.c index 1d149a0f..ec75fb7d 100644 --- a/parser/src/lexer.c +++ b/parser/src/lexer.c @@ -18,7 +18,7 @@ static const int32_t BYTE_ORDER_MARK = 0xFEFF; -static const TSRange DEFAULT_RANGE = {.start_point = +static const t_parser_range DEFAULT_RANGE = {.start_point = { .row = 0, .column = 0, @@ -121,7 +121,7 @@ static void ts_lexer_goto(Lexer *self, Length position) bool found_included_range = false; for (unsigned i = 0; i < self->included_range_count; i++) { - TSRange *included_range = &self->included_ranges[i]; + t_parser_range *included_range = &self->included_ranges[i]; if (included_range->end_byte > self->current_position.bytes && included_range->end_byte > included_range->start_byte) { @@ -159,7 +159,7 @@ static void ts_lexer_goto(Lexer *self, Length position) else { self->current_included_range_index = self->included_range_count; - TSRange *last_included_range = + t_parser_range *last_included_range = &self->included_ranges[self->included_range_count - 1]; self->current_position = (Length){ .bytes = last_included_range->end_byte, @@ -188,7 +188,7 @@ static void ts_lexer__do_advance(Lexer *self, bool skip) } } - const TSRange *current_range = + const t_parser_range *current_range = &self->included_ranges[self->current_included_range_index]; while (self->current_position.bytes >= current_range->end_byte || current_range->end_byte == current_range->start_byte) @@ -253,12 +253,12 @@ static void ts_lexer__mark_end(TSLexer *_self) // If the lexer is right at the beginning of included range, // then the token should be considered to end at the *end* of the // previous included range, rather than here. - TSRange *current_included_range = + t_parser_range *current_included_range = &self->included_ranges[self->current_included_range_index]; if (self->current_included_range_index > 0 && self->current_position.bytes == current_included_range->start_byte) { - TSRange *previous_included_range = current_included_range - 1; + t_parser_range *previous_included_range = current_included_range - 1; self->token_end_position = (Length){ previous_included_range->end_byte, previous_included_range->end_point, @@ -308,7 +308,7 @@ static bool ts_lexer__is_at_included_range_start(const TSLexer *_self) const Lexer *self = (const Lexer *)_self; if (self->current_included_range_index < self->included_range_count) { - TSRange *current_range = + t_parser_range *current_range = &self->included_ranges[self->current_included_range_index]; return self->current_position.bytes == current_range->start_byte; } @@ -434,12 +434,12 @@ void ts_lexer_mark_end(Lexer *self) ts_lexer__mark_end(&self->data); } -bool ts_lexer_set_included_ranges(Lexer *self, const TSRange *ranges, +bool ts_lexer_set_included_ranges(Lexer *self, const t_parser_range *ranges, uint32_t count) { ranges = &DEFAULT_RANGE; count = 1; - size_t size = count * sizeof(TSRange); + size_t size = count * sizeof(t_parser_range); self->included_ranges = realloc(self->included_ranges, size); memcpy(self->included_ranges, ranges, size); self->included_range_count = count; @@ -447,7 +447,7 @@ bool ts_lexer_set_included_ranges(Lexer *self, const TSRange *ranges, return true; } -TSRange *ts_lexer_included_ranges(const Lexer *self, uint32_t *count) +t_parser_range *ts_lexer_included_ranges(const Lexer *self, uint32_t *count) { *count = self->included_range_count; return self->included_ranges; diff --git a/parser/src/lexer.h b/parser/src/lexer.h index a8cc38f1..b2331ae5 100644 --- a/parser/src/lexer.h +++ b/parser/src/lexer.h @@ -7,7 +7,7 @@ extern "C" { #include "./length.h" #include "./subtree.h" -#include "api.h" +#include "parser/api.h" #include "./parser.h" typedef struct { @@ -16,7 +16,7 @@ typedef struct { Length token_start_position; Length token_end_position; - TSRange *included_ranges; + t_parser_range *included_ranges; const char *chunk; TSInput input; TSLogger logger; @@ -39,8 +39,8 @@ void ts_lexer_start(Lexer *); void ts_lexer_finish(Lexer *, uint32_t *); void ts_lexer_advance_to_end(Lexer *); void ts_lexer_mark_end(Lexer *); -bool ts_lexer_set_included_ranges(Lexer *self, const TSRange *ranges, uint32_t count); -TSRange *ts_lexer_included_ranges(const Lexer *self, uint32_t *count); +bool ts_lexer_set_included_ranges(Lexer *self, const t_parser_range *ranges, uint32_t count); +t_parser_range *ts_lexer_included_ranges(const Lexer *self, uint32_t *count); #ifdef __cplusplus } diff --git a/parser/src/node.c b/parser/src/node.c index f9960213..a8986e6f 100644 --- a/parser/src/node.c +++ b/parser/src/node.c @@ -37,8 +37,8 @@ uint32_t ts_node_start_byte(TSNode self) { return self.context[0]; } -TSPoint ts_node_start_point(TSNode self) { - return (TSPoint) {self.context[1], self.context[2]}; +t_point ts_node_start_point(TSNode self) { + return (t_point) {self.context[1], self.context[2]}; } static inline uint32_t ts_node__alias(const TSNode *self) { @@ -366,8 +366,8 @@ static inline TSNode ts_node__descendant_for_byte_range( static inline TSNode ts_node__descendant_for_point_range( TSNode self, - TSPoint range_start, - TSPoint range_end, + t_point range_start, + t_point range_end, bool include_anonymous ) { TSNode node = self; @@ -380,7 +380,7 @@ static inline TSNode ts_node__descendant_for_point_range( TSNode child; NodeChildIterator iterator = ts_node_iterate_children(&node); while (ts_node_child_iterator_next(&iterator, &child)) { - TSPoint node_end = iterator.position.extent; + t_point node_end = iterator.position.extent; // The end of this node must extend far enough forward to touch // the end of the range and exceed the start of the range. @@ -409,7 +409,7 @@ uint32_t ts_node_end_byte(TSNode self) { return ts_node_start_byte(self) + ts_subtree_size(ts_node__subtree(self)).bytes; } -TSPoint ts_node_end_point(TSNode self) { +t_point ts_node_end_point(TSNode self) { return point_add(ts_node_start_point(self), ts_subtree_size(ts_node__subtree(self)).extent); } @@ -742,23 +742,23 @@ TSNode ts_node_named_descendant_for_byte_range( TSNode ts_node_descendant_for_point_range( TSNode self, - TSPoint start, - TSPoint end + t_point start, + t_point end ) { return ts_node__descendant_for_point_range(self, start, end, true); } TSNode ts_node_named_descendant_for_point_range( TSNode self, - TSPoint start, - TSPoint end + t_point start, + t_point end ) { return ts_node__descendant_for_point_range(self, start, end, false); } void ts_node_edit(TSNode *self, const TSInputEdit *edit) { uint32_t start_byte = ts_node_start_byte(*self); - TSPoint start_point = ts_node_start_point(*self); + t_point start_point = ts_node_start_point(*self); if (start_byte >= edit->old_end_byte) { start_byte = edit->new_end_byte + (start_byte - edit->old_end_byte); diff --git a/parser/src/parser.c b/parser/src/parser.c index 37dc9890..638fb30c 100644 --- a/parser/src/parser.c +++ b/parser/src/parser.c @@ -1,5 +1,3 @@ -#define _POSIX_C_SOURCE 200112L - #include "./array.h" #include "./error_costs.h" #include "./language.h" @@ -11,7 +9,7 @@ #include "./subtree.h" #include "./tree.h" -#include "api.h" +#include "parser/api.h" #include #include #include @@ -19,7 +17,8 @@ #include #include -typedef Array(TSRange) ArrayRange; +#include "me/vec/vec_parser_range.h" + typedef uint64_t TSDuration; typedef uint64_t TSClock; @@ -101,7 +100,7 @@ static const unsigned MAX_VERSION_COUNT = 6; static const unsigned MAX_VERSION_COUNT_OVERFLOW = 4; static const unsigned MAX_SUMMARY_DEPTH = 16; static const unsigned MAX_COST_DIFFERENCE = 16 * ERROR_COST_PER_SKIPPED_TREE; -//static const unsigned OP_COUNT_PER_TIMEOUT_CHECK = 100; +// static const unsigned OP_COUNT_PER_TIMEOUT_CHECK = 100; typedef struct { @@ -132,7 +131,7 @@ struct TSParser unsigned operation_count; const volatile size_t *cancellation_flag; Subtree old_tree; - ArrayRange included_range_differences; + t_vec_parser_range included_range_differences; unsigned included_range_difference_index; bool has_scanner_error; }; @@ -163,7 +162,7 @@ typedef struct // StringInput static const char *ts_string_input_read(void *_self, uint32_t byte, - TSPoint point, uint32_t *length) + t_point point, uint32_t *length) { (void)point; TSStringInput *self = (TSStringInput *)_self; @@ -1994,7 +1993,7 @@ TSParser *ts_parser_new(void) self->end_clock = 0; self->operation_count = 0; self->old_tree = NULL_SUBTREE; - self->included_range_differences = (ArrayRange)array_new(); + self->included_range_differences = vec_parser_range_new(0, NULL); self->included_range_difference_index = 0; ts_parser__set_cached_token(self, 0, NULL_SUBTREE, NULL_SUBTREE); return self; @@ -2011,7 +2010,7 @@ void ts_parser_delete(TSParser *self) { array_delete(&self->reduce_actions); } - if (self->included_range_differences.contents) + if (self->included_range_differences.buffer) { array_delete(&self->included_range_differences); } @@ -2105,13 +2104,14 @@ void ts_parser_set_timeout_micros(TSParser *self, uint64_t timeout_micros) self->timeout_duration = 0; } -bool ts_parser_set_included_ranges(TSParser *self, const TSRange *ranges, +bool ts_parser_set_included_ranges(TSParser *self, const t_parser_range *ranges, uint32_t count) { return ts_lexer_set_included_ranges(&self->lexer, ranges, count); } -const TSRange *ts_parser_included_ranges(const TSParser *self, uint32_t *count) +const t_parser_range *ts_parser_included_ranges(const TSParser *self, + uint32_t *count) { return ts_lexer_included_ranges(&self->lexer, count); } @@ -2148,7 +2148,7 @@ TSTree *ts_parser_parse(TSParser *self, const TSTree *old_tree, TSInput input) return NULL; ts_lexer_set_input(&self->lexer, input); - array_clear(&self->included_range_differences); + self->included_range_differences.len = 0; self->included_range_difference_index = 0; if (ts_parser_has_outstanding_parse(self)) @@ -2221,11 +2221,11 @@ TSTree *ts_parser_parse(TSParser *self, const TSTree *old_tree, TSInput input) } while (self->included_range_difference_index < - self->included_range_differences.size) + self->included_range_differences.len) { - TSRange *range = + t_parser_range *range = &self->included_range_differences - .contents[self->included_range_difference_index]; + .buffer[self->included_range_difference_index]; if (range->end_byte <= position) { self->included_range_difference_index++; diff --git a/parser/src/point.h b/parser/src/point.h index 942a86e1..ce1d9ed5 100644 --- a/parser/src/point.h +++ b/parser/src/point.h @@ -1,58 +1,58 @@ #ifndef TREE_SITTER_POINT_H_ #define TREE_SITTER_POINT_H_ -#include "api.h" +#include "parser/api.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}) -static inline TSPoint point__new(unsigned row, unsigned column) { - TSPoint result = {row, column}; +static inline t_point point__new(unsigned row, unsigned column) { + t_point result = {row, column}; return result; } -static inline TSPoint point_add(TSPoint a, TSPoint b) { +static inline t_point point_add(t_point a, t_point b) { if (b.row > 0) return point__new(a.row + b.row, b.column); else return point__new(a.row, a.column + b.column); } -static inline TSPoint point_sub(TSPoint a, TSPoint b) { +static inline t_point point_sub(t_point a, t_point b) { if (a.row > b.row) return point__new(a.row - b.row, a.column); else return point__new(0, a.column - b.column); } -static inline bool point_lte(TSPoint a, TSPoint b) { +static inline bool point_lte(t_point a, t_point b) { return (a.row < b.row) || (a.row == b.row && a.column <= b.column); } -static inline bool point_lt(TSPoint a, TSPoint b) { +static inline bool point_lt(t_point a, t_point b) { return (a.row < b.row) || (a.row == b.row && a.column < b.column); } -static inline bool point_gt(TSPoint a, TSPoint b) { +static inline bool point_gt(t_point a, t_point b) { return (a.row > b.row) || (a.row == b.row && a.column > b.column); } -static inline bool point_gte(TSPoint a, TSPoint b) { +static inline bool point_gte(t_point a, t_point b) { return (a.row > b.row) || (a.row == b.row && a.column >= b.column); } -static inline bool point_eq(TSPoint a, TSPoint b) { +static inline bool point_eq(t_point a, t_point b) { return a.row == b.row && a.column == b.column; } -static inline TSPoint point_min(TSPoint a, TSPoint b) { +static inline t_point point_min(t_point a, t_point b) { if (a.row < b.row || (a.row == b.row && a.column < b.column)) return a; else return b; } -static inline TSPoint point_max(TSPoint a, TSPoint b) { +static inline t_point point_max(t_point a, t_point b) { if (a.row > b.row || (a.row == b.row && a.column > b.column)) return a; else diff --git a/parser/src/reduce_action.h b/parser/src/reduce_action.h index 0637c24c..5f8beeb1 100644 --- a/parser/src/reduce_action.h +++ b/parser/src/reduce_action.h @@ -6,7 +6,7 @@ extern "C" { #endif #include "./array.h" -#include "api.h" +#include "parser/api.h" typedef struct { uint32_t count; diff --git a/parser/src/subtree.h b/parser/src/subtree.h index 0b3062e9..8fb94e1b 100644 --- a/parser/src/subtree.h +++ b/parser/src/subtree.h @@ -12,7 +12,7 @@ extern "C" { #include "./array.h" #include "./error_costs.h" #include "./host.h" -#include "api.h" +#include "parser/api.h" #include "./parser.h" #define TS_TREE_STATE_NONE USHRT_MAX diff --git a/parser/src/tree.c b/parser/src/tree.c index 2b4508ee..faf0da46 100644 --- a/parser/src/tree.c +++ b/parser/src/tree.c @@ -1,6 +1,6 @@ #define _POSIX_C_SOURCE 200112L -#include "api.h" +#include "parser/api.h" #include "./array.h" #include "./length.h" @@ -10,13 +10,13 @@ TSTree *ts_tree_new( Subtree root, const TSLanguage *language, - const TSRange *included_ranges, unsigned included_range_count + const t_parser_range *included_ranges, unsigned included_range_count ) { TSTree *result = malloc(sizeof(TSTree)); result->root = root; result->language = ts_language_copy(language); - result->included_ranges = calloc(included_range_count, sizeof(TSRange)); - memcpy(result->included_ranges, included_ranges, included_range_count * sizeof(TSRange)); + result->included_ranges = calloc(included_range_count, sizeof(t_parser_range)); + memcpy(result->included_ranges, included_ranges, included_range_count * sizeof(t_parser_range)); result->included_range_count = included_range_count; return result; } @@ -44,7 +44,7 @@ TSNode ts_tree_root_node(const TSTree *self) { TSNode ts_tree_root_node_with_offset( const TSTree *self, uint32_t offset_bytes, - TSPoint offset_extent + t_point offset_extent ) { Length offset = {offset_bytes, offset_extent}; return ts_node_new(self, &self->root, length_add(offset, ts_subtree_padding(self->root)), 0); @@ -56,7 +56,7 @@ const TSLanguage *ts_tree_language(const TSTree *self) { void ts_tree_edit(TSTree *self, const TSInputEdit *edit) { for (unsigned i = 0; i < self->included_range_count; i++) { - TSRange *range = &self->included_ranges[i]; + t_parser_range *range = &self->included_ranges[i]; if (range->end_byte >= edit->old_end_byte) { if (range->end_byte != UINT32_MAX) { range->end_byte = edit->new_end_byte + (range->end_byte - edit->old_end_byte); @@ -94,10 +94,10 @@ void ts_tree_edit(TSTree *self, const TSInputEdit *edit) { ts_subtree_pool_delete(&pool); } -TSRange *ts_tree_included_ranges(const TSTree *self, uint32_t *length) { +t_parser_range *ts_tree_included_ranges(const TSTree *self, uint32_t *length) { *length = self->included_range_count; - TSRange *ranges = calloc(self->included_range_count, sizeof(TSRange)); - memcpy(ranges, self->included_ranges, self->included_range_count * sizeof(TSRange)); + t_parser_range *ranges = calloc(self->included_range_count, sizeof(t_parser_range)); + memcpy(ranges, self->included_ranges, self->included_range_count * sizeof(t_parser_range)); return ranges; } diff --git a/parser/src/tree.h b/parser/src/tree.h index f012f888..6329084b 100644 --- a/parser/src/tree.h +++ b/parser/src/tree.h @@ -17,11 +17,11 @@ typedef struct { struct TSTree { Subtree root; const TSLanguage *language; - TSRange *included_ranges; + t_parser_range *included_ranges; unsigned included_range_count; }; -TSTree *ts_tree_new(Subtree root, const TSLanguage *language, const TSRange *, unsigned); +TSTree *ts_tree_new(Subtree root, const TSLanguage *language, const t_parser_range *, unsigned); TSNode ts_node_new(const TSTree *, const Subtree *, Length, TSSymbol); #ifdef __cplusplus diff --git a/parser/src/tree_cursor.c b/parser/src/tree_cursor.c index 57f2135b..c841b22d 100644 --- a/parser/src/tree_cursor.c +++ b/parser/src/tree_cursor.c @@ -1,4 +1,4 @@ -#include "api.h" +#include "parser/api.h" #include "./tree_cursor.h" #include "./language.h" @@ -259,7 +259,7 @@ bool ts_tree_cursor_goto_last_child(TSTreeCursor *self) { static inline int64_t ts_tree_cursor_goto_first_child_for_byte_and_point( TSTreeCursor *_self, uint32_t goal_byte, - TSPoint goal_point + t_point goal_point ) { TreeCursor *self = (TreeCursor *)_self; uint32_t initial_size = self->stack.size; @@ -302,7 +302,7 @@ int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *self, uint32_t go return ts_tree_cursor_goto_first_child_for_byte_and_point(self, goal_byte, POINT_ZERO); } -int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self, TSPoint goal_point) { +int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self, t_point goal_point) { return ts_tree_cursor_goto_first_child_for_byte_and_point(self, 0, goal_point); }