debug exec ou parsing

This commit is contained in:
AntoHesse 2017-02-16 17:35:44 +01:00
parent beb3723122
commit 7477cb4c0d
8 changed files with 20 additions and 22 deletions

View file

@ -170,6 +170,7 @@ main/shell_script.c\
main/sig_handler.c\
parser/parse.c\
parser/ft_parse.c\
parser/old_parse.c\
parser/produce_sym.c\
parser/eval_sym.c\
parser/aggregate_sym.c\

View file

@ -158,15 +158,7 @@ typedef struct s_stackmatch t_stackmatch;
extern t_stackmatch g_stackmatch[];
struct s_treematch g_treemacth[];
{
t_type token;
void (*add)(t_btree **ast, t_type )
};
typedef struct s_treematch t_treematch;
extern t_treematch g_treematch[];
int ft_parse2(t_btree **ast, t_list **token);
int ft_parse(t_btree **ast, t_list **token);
int produce_sym(t_sym stack, t_sym *new_sym, t_list **lst);
@ -208,8 +200,6 @@ int add_cmd(t_btree **ast, t_list **lst);
int join_ast(t_btree **ast, t_btree **new_node);
int gen_node(t_btree **ast);
/*
* Build AST
*

View file

@ -1 +1 @@
ls | cat
ls

View file

@ -23,12 +23,14 @@ int shell_script()
ast = NULL;
list_ast = NULL;
script = &data_singleton()->script;
while (script->size)
{
// while (script->size)
// {
if (ft_lexer(&token, &data_singleton()->script.buffer) || !token)
return (1);
DG("after post_tokenize");
token_print(token);
// if (ft_parse2(&ast, &token))
// return (1);
if (ft_parse(&ast, &token))
return (1);
btree_print(STDBUG, ast, &ft_putast);
@ -37,7 +39,7 @@ int shell_script()
ast = NULL;
script->size = 0;
get_script_content(script);
}
// }
close(script->fd);
return (0);
}

View file

@ -12,7 +12,7 @@
#include "parser.h"
int ft_parse(t_btree **ast, t_list **token)
int ft_parse2(t_btree **ast, t_list **token)
{
t_sym *new_sym;
t_sym *stack;

View file

@ -14,7 +14,6 @@
t_parser g_parser[] =
{
{INSTRUCTION, &get_sub_instruction},
{TK_AND_IF | TK_OR_IF, &parse_separator},
{TK_AMP, &parse_separator},
{TK_PIPE, &parse_separator},
@ -25,7 +24,7 @@ t_parser g_parser[] =
{TK_LESSAND, &parse_lessand},
{TK_GREATAND, &parse_greatand},
{TK_SUBSHELL, &parse_subshell},
{TK_WORD, &parse_word},
{TK_N_WORD, &parse_word},
{0, 0},
};
@ -35,6 +34,7 @@ int ft_parse(t_btree **ast, t_list **start)
t_astnode item;
int i;
DG("old parser");
i = 0;
if (!*start)
return (0);
@ -48,6 +48,7 @@ int ft_parse(t_btree **ast, t_list **start)
{
if ((lst = ft_lst_find(*start, &g_parser[i].type, &token_cmp_type)))
{
DG("match : %s", read_state(g_parser[i].type));
if (g_parser[i].f)
(*g_parser[i].f)(ast, start, &lst);
return (0);

View file

@ -18,6 +18,7 @@ int parse_word(t_btree **ast, t_list **start, t_list **lst)
t_token *token;
char **my_tab;
DG("parse word begin");
my_tab = NULL;
token = (*lst)->content;
node = (*ast)->item;
@ -27,5 +28,6 @@ int parse_word(t_btree **ast, t_list **start, t_list **lst)
ft_ld_pushback(&node->data.token, my_tab);
ft_parse(ast, &(*lst)->next);
ft_lst_delif(start, (*lst)->content, &ft_addrcmp, &token_free);
DG("parse word end");
return (0);
}

View file

@ -14,6 +14,8 @@
char *read_state(t_sym current)
{
if (current == TK_DLESS)
return ("TK_DLESS");
if (current == CMD_SUPERIOR)
return ("CMD_SUPERIOR");
if (current == TK_IO_NUMBER)