Print also the contents of tokens
authorLukas Jiriste <ljiriste@student.42prague.com>
Thu, 27 Jun 2024 07:13:43 +0000 (09:13 +0200)
committerLukas Jiriste <ljiriste@student.42prague.com>
Thu, 27 Jun 2024 07:13:43 +0000 (09:13 +0200)
This makes debugging easier, though the output is harder to read

ft_parse/ft_parse_tree_print.c

index eab297d7cf35538c2ad7cce36db475e11673458d..bb468139600b2df0683f37cca564364d696b8e5e 100644 (file)
@@ -54,7 +54,7 @@ static void   print_last_at_depth(t_parse_tree_node *node,
                ft_printf("%s\n", node);
                return ;
        }
-       ft_printf("%s-%s\n", branches, node->token.type);
+       ft_printf("%s-%s - %s\n", branches, node->token.type, node->token.str);
        branches[ft_strlen(branches) - 1] = ' ';
        ft_strlcat(branches, " |", MAX_WIDTH);
        print_children_at_depth(node, depth, branches);
@@ -70,12 +70,12 @@ static void print_node_at_depth(t_parse_tree_node *node,
        }
        if (depth == 0)
        {
-               ft_printf("%s\n", node->token.type);
+               ft_printf("%s - %s\n", node->token.type, node->token.str);
                ft_strlcat(branches, "|", MAX_WIDTH);
        }
        else
        {
-               ft_printf("%s-%s\n", branches, node->token.type);
+               ft_printf("%s-%s - %s\n", branches, node->token.type, node->token.str);
                ft_strlcat(branches, " |", MAX_WIDTH);
        }
        print_children_at_depth(node, depth, branches);