update: added debug print of ts after every pass

This commit is contained in:
maix0 2024-10-05 18:58:42 +02:00
parent 7cb3582b1a
commit 71d9a201b5
9 changed files with 172 additions and 39 deletions

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
/* Updated: 2024/10/03 22:47:05 by maiboyer ### ########.fr */
/* Updated: 2024/10/05 18:54:45 by maiboyer ### ########.fr */
/* */
/* ************************************************************************** */
@ -101,32 +101,6 @@ void print_node_data(t_node *t, t_usize depth)
}
*/
t_str token_name(t_token *out);
void func(t_usize i, t_token *token, void *vdepth)
{
t_usize depth;
t_string sdepth;
depth = 0;
if (vdepth != NULL)
depth = *(t_usize *)vdepth;
sdepth = string_new(16);
i = 0;
while (i++ < depth)
string_push_char(&sdepth, '\t');
if (token->subtokens.buffer != NULL)
{
depth++;
printf("%s[" COL_GREEN "%10s"RESET"]\n", sdepth.buf ,token_name(token));
vec_token_iter(&token->subtokens, func, &depth);
}
else
printf("%s[" COL_GREEN "%10s"RESET"] '"COL_YELLOW"%s"RESET"'\n",\
sdepth.buf ,token_name(token), token->string.buf);
string_free(sdepth);
}
void parse_str(t_state *state)
{
t_vec_token tokens;
@ -134,7 +108,8 @@ void parse_str(t_state *state)
return ;
if (ts_apply_passes(tokens, &tokens))
return ;
vec_token_iter(&tokens, func, NULL);
printf("\n\nEND TOKENS\n");
ts_print(&tokens);
vec_token_free(tokens);
}