diff --git a/.clang-format b/.clang-format index 9d85bfc2..1dd4b436 100644 --- a/.clang-format +++ b/.clang-format @@ -1,6 +1,6 @@ BasedOnStyle: Microsoft IndentWidth: 4 -ColumnLimit: 1600 +ColumnLimit: 140 UseTab: Always SortIncludes: CaseInsensitive IndentPPDirectives: AfterHash diff --git a/parser/Makefile b/parser/Makefile index ee4d27e9..64bb9a3c 100644 --- a/parser/Makefile +++ b/parser/Makefile @@ -6,7 +6,7 @@ # By: rparodi +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/12 11:05:05 by rparodi #+# #+# # -# Updated: 2024/05/30 19:46:52 by maiboyer ### ########.fr # +# Updated: 2024/05/30 19:57:48 by maiboyer ### ########.fr # # # # **************************************************************************** # @@ -14,7 +14,7 @@ BUILD_DIR ?= ../build/ all: @$(MAKE) --no-print-directory -f Parser.mk "LIB_NAME=$(shell realpath .)/" "BUILD_DIR=$(shell realpath $(BUILD_DIR))" libparser.a - @$(MAKE) --no-print-directory -f Grammar.mk "LIB_NAME=$(shell realpath .)/" "BUILD_DIR=$(shell realpath $(BUILD_DIR))" libgmr.a + @#$(MAKE) --no-print-directory -f Grammar.mk "LIB_NAME=$(shell realpath .)/" "BUILD_DIR=$(shell realpath $(BUILD_DIR))" libgmr.a libparser.a: @$(MAKE) --no-print-directory -f Parser.mk "LIB_NAME=$(shell realpath .)/" "BUILD_DIR=$(shell realpath $(BUILD_DIR))" libparser.a diff --git a/parser/src/api_structs.h b/parser/src/api_structs.h index 3df6c1c2..ffd184a3 100644 --- a/parser/src/api_structs.h +++ b/parser/src/api_structs.h @@ -249,6 +249,7 @@ typedef enum e_tree_cursor_step // separately on the heap. struct s_external_scanner_state { + // TODO: extract this anonymous struct union { char *long_data; char short_data[24]; @@ -256,63 +257,24 @@ struct s_external_scanner_state uint32_t length; }; -#define SUBTREE_BITS \ - bool visible : 1; \ - bool named : 1; \ - bool extra : 1; \ - bool has_changes : 1; \ - bool is_missing : 1; \ - bool is_keyword : 1; - -#define SUBTREE_SIZE \ - uint8_t padding_columns; \ - uint8_t padding_rows : 4; \ - uint8_t lookahead_bytes : 4; \ - uint8_t padding_bytes; \ - uint8_t size_bytes; - -#if TS_BIG_ENDIAN -# if TS_PTR_SIZE == 32 - struct s_subtree_inline_data { - uint16_t parse_state; - uint8_t symbol; - SUBTREE_BITS - bool unused : 1; - bool is_inline : 1; - SUBTREE_SIZE -}; - -# else - -struct s_subtree_inline_data -{ - SUBTREE_SIZE - uint16_t parse_state; - uint8_t symbol; - SUBTREE_BITS - bool unused : 1; - bool is_inline : 1; -}; - -# endif -#else - -struct s_subtree_inline_data -{ - bool is_inline : 1; - SUBTREE_BITS + bool is_inline : 1; + bool visible : 1; + bool named : 1; + bool extra : 1; + bool has_changes : 1; + bool is_missing : 1; + bool is_keyword : 1; uint8_t symbol; uint16_t parse_state; - SUBTREE_SIZE + uint8_t padding_columns; + uint8_t padding_rows : 4; + uint8_t lookahead_bytes : 4; + uint8_t padding_bytes; + uint8_t size_bytes; }; -#endif - -#undef SUBTREE_BITS -#undef SUBTREE_SIZE - struct s_subtree_heap_data { volatile uint32_t ref_count; @@ -336,6 +298,7 @@ struct s_subtree_heap_data bool is_missing : 1; bool is_keyword : 1; + // TODO: extract these anonymous struct union { // Non-terminal subtrees (`child_count > 0`) struct @@ -382,6 +345,7 @@ struct s_subtree_pool }; union u_parse_action { + // TODO: extract this anonymous struct struct { uint8_t type; @@ -389,6 +353,7 @@ union u_parse_action { bool extra; bool repetition; } shift; + // TODO: extract this anonymous struct struct { uint8_t type; @@ -441,6 +406,7 @@ enum e_parse_action_type union u_parse_action_entry { t_parse_action action; + // TODO: extract this anonymous struct struct { uint8_t count; @@ -512,6 +478,7 @@ struct s_language bool (*lex_fn)(t_lexer_data *, t_state_id); bool (*keyword_lex_fn)(t_lexer_data *, t_state_id); t_symbol keyword_capture_token; + // TODO: extract this anonymous struct struct { const bool *states;