blob: cde4e4c3aeacad2324e1b61dbabd934899dd4c91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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");
}
}
|