diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-06-18 14:34:27 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-06-18 14:39:17 +0200 |
| commit | bf97035e8d444c141725c0cf91aaaa285ae712af (patch) | |
| tree | 3b87d3996c8e3e550f3a0dd18b1f55d8c69d16ff /src/debug.c | |
| parent | 52bc3c1a6035dae4e45015c48a8c65681a31512a (diff) | |
| download | minishell-bf97035e8d444c141725c0cf91aaaa285ae712af.tar.gz minishell-bf97035e8d444c141725c0cf91aaaa285ae712af.tar.bz2 minishell-bf97035e8d444c141725c0cf91aaaa285ae712af.zip | |
Fixing little bug in env_search
Diffstat (limited to 'src/debug.c')
| -rw-r--r-- | src/debug.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/debug.c b/src/debug.c new file mode 100644 index 0000000..cde4e4c --- /dev/null +++ b/src/debug.c @@ -0,0 +1,59 @@ + +#include <stdio.h> +#include "lexer.h" +#include "ast.h" + +void token_debug(void *v) +{ + t_token *t; + + t= v; + printf("[%4d %d] (%s)\n", t->tag, !!(t->tag & TAG_STICK), t->content); +} + +void token_put(void *v) +{ + t_token *t; + + t= v; + printf("%s ", t->content); +} + +void print_level(int level) +{ + while (level-- > 0) + printf(" "); +} + +void ast_print(int level, t_ast *ast) +{ + if (ast->tag == AST_CMD) + { + print_level(level); + printf("cmd: [ "); + ft_lstiter(ast->cmd_argv, token_put); + printf(" ] redirs: ["); + ft_lstiter(ast->redirs, token_put); + printf(" ]"); + } + else + { + /* print_level(level); */ + /* printf("SEP: %d\n", ast->op.sep); */ + print_level(level); + printf("{\n"); + + print_level(level); + printf(" left:\n"); + ast_print(level + 1, ast->op.left); + + printf("\n"); + print_level(level); + printf(" right:\n"); + ast_print(level + 1, ast->op.right); + + printf("\n"); + print_level(level); + printf("}\n"); + } +} |
