fixed some stuff

This commit is contained in:
Maieul BOYER 2024-04-30 16:09:01 +02:00
parent c967e4bfd0
commit 126bd81712
No known key found for this signature in database
3 changed files with 4 additions and 79 deletions

View file

@ -367,11 +367,7 @@ static bool ts_parser__better_version_exists(t_parser *self,
return true; return true;
} }
<<<<<<< HEAD
t_parse_length position = ts_stack_position(self->stack, version); t_parse_length position = ts_stack_position(self->stack, version);
=======
t_parse_length position = ts_stack_position(self->stack, version);
>>>>>>> master
t_error_status status = { t_error_status status = {
.cost = cost, .cost = cost,
.is_in_error = is_in_error, .is_in_error = is_in_error,
@ -510,7 +506,6 @@ static Subtree ts_parser__lex(t_parser *self, StackVersion version,
return NULL_SUBTREE; return NULL_SUBTREE;
} }
<<<<<<< HEAD
const t_parse_length start_position = const t_parse_length start_position =
ts_stack_position(self->stack, version); ts_stack_position(self->stack, version);
const Subtree external_token = const Subtree external_token =
@ -526,31 +521,11 @@ static Subtree ts_parser__lex(t_parser *self, StackVersion version,
t_i32 lookahead_end_byte = 0; t_i32 lookahead_end_byte = 0;
t_i32 external_scanner_state_len = 0; t_i32 external_scanner_state_len = 0;
bool external_scanner_state_changed = false; bool external_scanner_state_changed = false;
======= bool found_token;
const t_parse_length start_position = ts_stack_position(self->stack, version);
const Subtree external_token =
ts_stack_last_external_token(self->stack, version);
bool found_external_token = false;
bool error_mode = parse_state == ERROR_STATE;
bool skipped_error = false;
bool called_get_column = false;
t_i32 first_error_character = 0;
t_parse_length error_start_position = length_zero();
t_parse_length error_end_position = length_zero();
t_i32 lookahead_end_byte = 0;
t_i32 external_scanner_state_len = 0;
bool external_scanner_state_changed = false;
>>>>>>> master
ts_lexer_reset(&self->lexer, start_position); ts_lexer_reset(&self->lexer, start_position);
for (;;) for (;;)
{ {
<<<<<<< HEAD
bool found_token = false;
=======
bool found_token = false;
>>>>>>> master
t_parse_length current_position = self->lexer.current_position; t_parse_length current_position = self->lexer.current_position;
if (lex_mode.external_lex_state != 0) if (lex_mode.external_lex_state != 0)
@ -652,25 +627,17 @@ static Subtree ts_parser__lex(t_parser *self, StackVersion version,
Subtree result; Subtree result;
if (skipped_error) if (skipped_error)
{ {
<<<<<<< HEAD
t_parse_length padding = t_parse_length padding =
length_sub(error_start_position, start_position); length_sub(error_start_position, start_position);
t_parse_length size = t_parse_length size =
length_sub(error_end_position, error_start_position); length_sub(error_end_position, error_start_position);
t_u32 lookahead_bytes = lookahead_end_byte - error_end_position.bytes; t_u32 lookahead_bytes = lookahead_end_byte - error_end_position.bytes;
=======
t_parse_length padding = length_sub(error_start_position, start_position);
t_parse_length size = length_sub(error_end_position, error_start_position);
t_u32 lookahead_bytes =
lookahead_end_byte - error_end_position.bytes;
>>>>>>> master
result = ts_subtree_new_error(&self->tree_pool, first_error_character, result = ts_subtree_new_error(&self->tree_pool, first_error_character,
padding, size, lookahead_bytes, padding, size, lookahead_bytes,
parse_state, self->language); parse_state, self->language);
} }
else else
{ {
<<<<<<< HEAD
bool is_keyword = false; bool is_keyword = false;
t_symbol symbol = self->lexer.data.result_symbol; t_symbol symbol = self->lexer.data.result_symbol;
t_parse_length padding = t_parse_length padding =
@ -678,15 +645,6 @@ static Subtree ts_parser__lex(t_parser *self, StackVersion version,
t_parse_length size = length_sub(self->lexer.token_end_position, t_parse_length size = length_sub(self->lexer.token_end_position,
self->lexer.token_start_position); self->lexer.token_start_position);
t_u32 lookahead_bytes = t_u32 lookahead_bytes =
=======
bool is_keyword = false;
t_symbol symbol = self->lexer.data.result_symbol;
t_parse_length padding =
length_sub(self->lexer.token_start_position, start_position);
t_parse_length size = length_sub(self->lexer.token_end_position,
self->lexer.token_start_position);
t_u32 lookahead_bytes =
>>>>>>> master
lookahead_end_byte - self->lexer.token_end_position.bytes; lookahead_end_byte - self->lexer.token_end_position.bytes;
if (found_external_token) if (found_external_token)
@ -1343,19 +1301,11 @@ static bool ts_parser__recover_to_state(t_parser *self, StackVersion version,
static void ts_parser__recover(t_parser *self, StackVersion version, static void ts_parser__recover(t_parser *self, StackVersion version,
Subtree lookahead) Subtree lookahead)
{ {
<<<<<<< HEAD
bool did_recover = false; bool did_recover = false;
unsigned previous_version_count = ts_stack_version_count(self->stack); unsigned previous_version_count = ts_stack_version_count(self->stack);
t_parse_length position = ts_stack_position(self->stack, version); t_parse_length position = ts_stack_position(self->stack, version);
StackSummary *summary = ts_stack_get_summary(self->stack, version); StackSummary *summary = ts_stack_get_summary(self->stack, version);
unsigned node_count_since_error = unsigned node_count_since_error =
=======
bool did_recover = false;
unsigned previous_version_count = ts_stack_version_count(self->stack);
t_parse_length position = ts_stack_position(self->stack, version);
StackSummary *summary = ts_stack_get_summary(self->stack, version);
unsigned node_count_since_error =
>>>>>>> master
ts_stack_node_count_since_error(self->stack, version); ts_stack_node_count_since_error(self->stack, version);
unsigned current_error_cost = ts_stack_error_cost(self->stack, version); unsigned current_error_cost = ts_stack_error_cost(self->stack, version);
@ -1567,13 +1517,8 @@ static void ts_parser__handle_error(t_parser *self, StackVersion version,
// lookahead. After skipping one or more invalid tokens, the parser might // lookahead. After skipping one or more invalid tokens, the parser might
// find a token that would have allowed a reduction to take place. // find a token that would have allowed a reduction to take place.
ts_parser__do_all_potential_reductions(self, version, 0); ts_parser__do_all_potential_reductions(self, version, 0);
<<<<<<< HEAD
t_u32 version_count = ts_stack_version_count(self->stack); t_u32 version_count = ts_stack_version_count(self->stack);
t_parse_length position = ts_stack_position(self->stack, version); t_parse_length position = ts_stack_position(self->stack, version);
=======
t_u32 version_count = ts_stack_version_count(self->stack);
t_parse_length position = ts_stack_position(self->stack, version);
>>>>>>> master
// Push a discontinuity onto the stack. Merge all of the stack versions that // Push a discontinuity onto the stack. Merge all of the stack versions that
// were created in the previous step. // were created in the previous step.
@ -2198,12 +2143,8 @@ void ts_parser_reset(t_parser *self)
self->has_scanner_error = false; self->has_scanner_error = false;
} }
<<<<<<< HEAD
t_parse_tree *ts_parser_parse(t_parser *self, const t_parse_tree *old_tree, t_parse_tree *ts_parser_parse(t_parser *self, const t_parse_tree *old_tree,
t_parse_input input) t_parse_input input)
=======
t_parse_tree *ts_parser_parse(t_parser *self, const t_parse_tree *old_tree, t_parse_input input)
>>>>>>> master
{ {
t_parse_tree *result = NULL; t_parse_tree *result = NULL;
old_tree = NULL; old_tree = NULL;
@ -2324,16 +2265,10 @@ t_parse_tree *ts_parser_parse_string(t_parser *self,
InputEncoding8); InputEncoding8);
} }
<<<<<<< HEAD
t_parse_tree *ts_parser_parse_string_encoding(t_parser *self, t_parse_tree *ts_parser_parse_string_encoding(t_parser *self,
const t_parse_tree *old_tree, const t_parse_tree *old_tree,
const char *string, t_u32 length, const char *string, t_u32 length,
t_input_encoding encoding) t_input_encoding encoding)
=======
t_parse_tree *ts_parser_parse_string_encoding(t_parser *self, const t_parse_tree *old_tree,
const char *string, t_u32 length,
t_input_encoding encoding)
>>>>>>> master
{ {
t_string_input input = {string, length}; t_string_input input = {string, length};
return ts_parser_parse(self, old_tree, return ts_parser_parse(self, old_tree,

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/29 11:35:51 by rparodi #+# #+# */ /* Created: 2024/03/29 11:35:51 by rparodi #+# #+# */
/* Updated: 2024/04/13 20:15:37 by rparodi ### ########.fr */ /* Updated: 2024/04/30 16:07:48 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -34,15 +34,7 @@ void ft_free_strs(t_str *strs)
void ft_free_utils(t_utils *s) void ft_free_utils(t_utils *s)
{ {
if (s->name_shell) (void)(s);
ft_free(s->name_shell);
if (s->str_input)
ft_free(s->str_input);
if (s->strs_input)
ft_free_strs(s->strs_input);
if (s->path)
ft_free_strs(s->path);
free(s);
} }
void ft_exit(t_utils *maiboyerlpb, t_u8 exit_status) void ft_exit(t_utils *maiboyerlpb, t_u8 exit_status)

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */ /* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
/* Updated: 2024/04/30 13:02:39 by maiboyer ### ########.fr */ /* Updated: 2024/04/30 16:06:00 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -46,9 +46,7 @@ void ft_take_args(t_utils *shcat)
shcat->strs_input = ft_split(shcat->str_input, ' '); shcat->strs_input = ft_split(shcat->str_input, ' ');
if (!shcat->strs_input) if (!shcat->strs_input)
exit(1); exit(1);
ft_check(shcat, shcat->strs_input);
add_history(shcat->str_input); add_history(shcat->str_input);
ft_free_strs(shcat->strs_input);
free(shcat->str_input); free(shcat->str_input);
i++; i++;
} }