From a9a4417919a07c80aacacbe8867d8df310f5110a Mon Sep 17 00:00:00 2001 From: maix0 Date: Tue, 8 Oct 2024 13:44:54 +0200 Subject: [PATCH] update: moved yarn and fixed leak --- parser/Filelist.parser.mk | 1 + parser/src/passes.c | 7 ++++--- parser/src/passes/fold_cmd.c | 4 ++-- parser/src/token_utils.c | 23 +++++++++++++---------- parser/{ => src}/yarn/yarn.c | 0 sources/main.c | 2 +- 6 files changed, 21 insertions(+), 16 deletions(-) rename parser/{ => src}/yarn/yarn.c (100%) diff --git a/parser/Filelist.parser.mk b/parser/Filelist.parser.mk index f74117a6..e7399632 100644 --- a/parser/Filelist.parser.mk +++ b/parser/Filelist.parser.mk @@ -20,6 +20,7 @@ token_utils \ tokenizer \ tokenizer_utils \ ts_print \ +yarn/yarn \ GEN_FILES = \ \ diff --git a/parser/src/passes.c b/parser/src/passes.c index 9fc1804a..a9b89b72 100644 --- a/parser/src/passes.c +++ b/parser/src/passes.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/02 18:41:16 by maiboyer #+# #+# */ -/* Updated: 2024/10/07 18:15:14 by rparodi ### ########.fr */ +/* Updated: 2024/10/08 13:40:48 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -15,6 +15,7 @@ #include "me/types.h" #include "me/vec/vec_token.h" #include "parser/token.h" +#include /// This is a list what of kind of passes we need to make on the tokenstream /// they'll all have the same function signature, basically taking a token @@ -71,7 +72,7 @@ t_error ts_apply_passes(t_vec_token ts, t_vec_token *out) else me_printf("Applied '%s' pass\n", g_ts_passes[i].name); ts = next; - ts_print(&ts); + //ts_print(&ts); i++; } return (*out = ts, NO_ERROR); @@ -103,7 +104,7 @@ t_error ts_dq_apply_passes(t_vec_token ts, t_vec_token *out) else me_printf("Applied '%s' dq_pass\n", g_ts_dq_passes[i].name); ts = next; - ts_print(&ts); + //ts_print(&ts); i++; } return (*out = ts, NO_ERROR); diff --git a/parser/src/passes/fold_cmd.c b/parser/src/passes/fold_cmd.c index 9edb940b..8960f82d 100644 --- a/parser/src/passes/fold_cmd.c +++ b/parser/src/passes/fold_cmd.c @@ -6,7 +6,7 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/02 19:04:32 by maiboyer #+# #+# */ -/* Updated: 2024/10/07 16:45:41 by maiboyer ### ########.fr */ +/* Updated: 2024/10/08 13:40:23 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ @@ -46,7 +46,7 @@ t_error ts_fold_cmd(t_vec_token input, t_vec_token *output) if (_is_cmd_node(input.buffer[i].type)) { j = 0; - tmp = token_new(TOK_CMD); + tmp = token_new_meta(TOK_CMD); while (i + j < input.len \ && _is_cmd_node(input.buffer[i + j].type)) vec_token_push(&tmp.subtokens, token_clone(&input.buffer[i + j++])); diff --git a/parser/src/token_utils.c b/parser/src/token_utils.c index 3978d910..03551d5c 100644 --- a/parser/src/token_utils.c +++ b/parser/src/token_utils.c @@ -6,34 +6,37 @@ /* By: maiboyer +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/10/06 13:33:12 by maiboyer #+# #+# */ -/* Updated: 2024/10/06 13:33:48 by maiboyer ### ########.fr */ +/* Updated: 2024/10/08 13:40:57 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */ #include "me/types.h" #include "parser/token.h" +#include + + +t_str token_name(t_token *token); t_token token_clone(t_token *tok) { - t_token out; + t_token ret; t_usize i; - out = token_new_none(); - out.type = tok->type; + ret = token_new_none(); + ret.type = tok->type; if (tok->string.buf != NULL) { - out.string = string_new(tok->string.capacity); - string_push(&out.string, tok->string.buf); + ret.string = string_new(tok->string.capacity); + string_push(&ret.string, tok->string.buf); } if (tok->subtokens.buffer != NULL) { - out.subtokens = vec_token_new(tok->subtokens.capacity, token_free); + ret.subtokens = vec_token_new(tok->subtokens.capacity, token_free); i = 0; while (i < tok->subtokens.len) - vec_token_push(&out.subtokens, \ - token_clone(&tok->subtokens.buffer[i++])); + vec_token_push(&ret.subtokens, token_clone(&tok->subtokens.buffer[i++])); } - return (out); + return (ret); } bool token_is_noquote(enum e_token ttype) diff --git a/parser/yarn/yarn.c b/parser/src/yarn/yarn.c similarity index 100% rename from parser/yarn/yarn.c rename to parser/src/yarn/yarn.c diff --git a/sources/main.c b/sources/main.c index b78c827e..8003659b 100644 --- a/sources/main.c +++ b/sources/main.c @@ -6,7 +6,7 @@ /* By: rparodi +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */ -/* Updated: 2024/10/05 18:54:45 by maiboyer ### ########.fr */ +/* Updated: 2024/10/08 13:29:30 by maiboyer ### ########.fr */ /* */ /* ************************************************************************** */