norm
This commit is contained in:
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* minishell.h :+: :+: :+: */
|
/* minishell.h :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/27 11:25:25 by lderidde #+# #+# */
|
/* Created: 2025/01/27 11:25:25 by lderidde #+# #+# */
|
||||||
/* Updated: 2025/02/07 10:22:28 by lderidde ### ########.fr */
|
/* Updated: 2025/02/07 17:22:16 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -53,5 +53,4 @@ void free_child(t_msh *msh);
|
|||||||
# define POW4 "\033[0;38;2;204;205;209;48;2;39;39;39m"
|
# define POW4 "\033[0;38;2;204;205;209;48;2;39;39;39m"
|
||||||
# define POW5 "\033[1;38;2;39;39;39m"
|
# define POW5 "\033[1;38;2;39;39;39m"
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/05 07:57:33 by nalebrun #+# #+# */
|
/* Created: 2025/02/05 07:57:33 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/02/05 07:57:33 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 17:57:01 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ast.c :+: :+: :+: */
|
/* ast.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/24 08:22:16 by lderidde #+# #+# */
|
/* Created: 2025/01/24 08:22:16 by lderidde #+# #+# */
|
||||||
/* Updated: 2025/02/05 14:04:12 by lderidde ### ########.fr */
|
/* Updated: 2025/02/07 17:57:10 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/05 07:48:37 by nalebrun #+# #+# */
|
/* Created: 2025/02/05 07:48:37 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/02/05 07:48:37 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 18:00:41 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -64,6 +64,7 @@ char **get_args(t_node *start)
|
|||||||
void create_cmd(t_ast_n *self, t_node *lst)
|
void create_cmd(t_ast_n *self, t_node *lst)
|
||||||
{
|
{
|
||||||
char **cmd_args;
|
char **cmd_args;
|
||||||
|
int i;
|
||||||
|
|
||||||
self->state = _CMD;
|
self->state = _CMD;
|
||||||
self->files = NULL;
|
self->files = NULL;
|
||||||
@@ -73,8 +74,9 @@ void create_cmd(t_ast_n *self, t_node *lst)
|
|||||||
self->args = cmd_args;
|
self->args = cmd_args;
|
||||||
self->cmd = ft_strdup(cmd_args[0]);
|
self->cmd = ft_strdup(cmd_args[0]);
|
||||||
create_redir(lst, self);
|
create_redir(lst, self);
|
||||||
// debug
|
if (DEBUG)
|
||||||
int i = -1;
|
{
|
||||||
|
i = -1;
|
||||||
ft_debug("==== CMD REDIR\n");
|
ft_debug("==== CMD REDIR\n");
|
||||||
while (self->files && self->files[++i])
|
while (self->files && self->files[++i])
|
||||||
ft_debug("redi : [%d]%s\n", self->redir[i], self->files[i]);
|
ft_debug("redi : [%d]%s\n", self->redir[i], self->files[i]);
|
||||||
@@ -84,3 +86,4 @@ void create_cmd(t_ast_n *self, t_node *lst)
|
|||||||
ft_debug("args : %s\n", self->args[i], self->args[i]);
|
ft_debug("args : %s\n", self->args[i], self->args[i]);
|
||||||
ft_debug("==== CMD DONE\n\n");
|
ft_debug("==== CMD DONE\n\n");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* cutll.c :+: :+: :+: */
|
/* cutll.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/31 09:56:34 by lderidde #+# #+# */
|
/* Created: 2025/01/31 09:56:34 by lderidde #+# #+# */
|
||||||
/* Updated: 2025/01/31 14:05:12 by lderidde ### ########.fr */
|
/* Updated: 2025/02/07 17:56:37 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -41,7 +41,8 @@ static t_node *get_node(t_node **lst, t_node *expected, int limiter)
|
|||||||
add_node_back(&node, (*lst)->val, (*lst)->token, (*lst)->pressision);
|
add_node_back(&node, (*lst)->val, (*lst)->token, (*lst)->pressision);
|
||||||
(*lst) = (*lst)->next;
|
(*lst) = (*lst)->next;
|
||||||
}
|
}
|
||||||
while (limiter == -1 && (*lst) && ft_strncmp((*lst)->val, expected->val, ft_strlen((*lst)->val)))
|
while (limiter == -1 && (*lst) && ft_strncmp((*lst)->val, expected->val,
|
||||||
|
ft_strlen((*lst)->val)))
|
||||||
{
|
{
|
||||||
add_node_back(&node, (*lst)->val, (*lst)->token, (*lst)->pressision);
|
add_node_back(&node, (*lst)->val, (*lst)->token, (*lst)->pressision);
|
||||||
(*lst) = (*lst)->next;
|
(*lst) = (*lst)->next;
|
||||||
@@ -54,6 +55,7 @@ t_nodell *cutll(t_node *lst, t_node *expected, size_t limiter)
|
|||||||
t_nodell *out;
|
t_nodell *out;
|
||||||
t_node *node;
|
t_node *node;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
t_nodell *tmp;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
out = NULL;
|
out = NULL;
|
||||||
@@ -63,7 +65,7 @@ t_nodell *cutll(t_node *lst, t_node *expected, size_t limiter)
|
|||||||
if (!node)
|
if (!node)
|
||||||
break ;
|
break ;
|
||||||
add_nodell(&out, node);
|
add_nodell(&out, node);
|
||||||
t_nodell *tmp = out;
|
tmp = out;
|
||||||
while (tmp)
|
while (tmp)
|
||||||
tmp = tmp->next;
|
tmp = tmp->next;
|
||||||
if (lst && lst->next)
|
if (lst && lst->next)
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* free_ast.c :+: :+: :+: */
|
/* free_ast.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/05 14:39:28 by lderidde #+# #+# */
|
/* Created: 2025/02/05 14:39:28 by lderidde #+# #+# */
|
||||||
/* Updated: 2025/02/07 09:20:16 by lderidde ### ########.fr */
|
/* Updated: 2025/02/07 17:57:21 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/05 07:38:26 by nalebrun #+# #+# */
|
/* Created: 2025/02/05 07:38:26 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/02/05 11:41:23 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 17:57:42 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* subsh.c :+: :+: :+: */
|
/* subsh.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/05 07:51:27 by lderidde #+# #+# */
|
/* Created: 2025/02/05 07:51:27 by lderidde #+# #+# */
|
||||||
/* Updated: 2025/02/07 09:12:41 by lderidde ### ########.fr */
|
/* Updated: 2025/02/07 18:01:31 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -43,6 +43,7 @@ t_node *remove_parentheses(t_node *lst)
|
|||||||
void create_subsh(t_ast_n *self, t_node *lst, t_msh *msh)
|
void create_subsh(t_ast_n *self, t_node *lst, t_msh *msh)
|
||||||
{
|
{
|
||||||
t_node *cutted;
|
t_node *cutted;
|
||||||
|
int i;
|
||||||
|
|
||||||
self->sh = true;
|
self->sh = true;
|
||||||
cutted = remove_parentheses(lst);
|
cutted = remove_parentheses(lst);
|
||||||
@@ -51,12 +52,13 @@ void create_subsh(t_ast_n *self, t_node *lst, t_msh *msh)
|
|||||||
self->redir = ft_calloc(1, sizeof(t_redir));
|
self->redir = ft_calloc(1, sizeof(t_redir));
|
||||||
self->redir[0] = _NR;
|
self->redir[0] = _NR;
|
||||||
create_redir_subsh(lst, self);
|
create_redir_subsh(lst, self);
|
||||||
// debug
|
if (DEBUG)
|
||||||
int i = -1;
|
{
|
||||||
|
i = -1;
|
||||||
ft_debug("==== SUBSH REDIR\n");
|
ft_debug("==== SUBSH REDIR\n");
|
||||||
while (self->redir[++i])
|
while (self->redir[++i])
|
||||||
ft_debug("subsh_redir : [%d]%s\n", self->redir[i], self->files[i]);
|
ft_debug("subsh_redir : [%d]%s\n", self->redir[i], self->files[i]);
|
||||||
ft_debug("==== SUBSH DONE\n\n");
|
ft_debug("==== SUBSH DONE\n\n");
|
||||||
|
|
||||||
free_linked_list(cutted);
|
free_linked_list(cutted);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/31 17:14:26 by nalebrun #+# #+# */
|
/* Created: 2025/01/31 17:14:26 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/01/31 17:14:26 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 17:56:02 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -27,10 +27,9 @@ static int last_tok_redir(t_node *lst)
|
|||||||
{
|
{
|
||||||
while (lst)
|
while (lst)
|
||||||
{
|
{
|
||||||
if ((lst->next == NULL
|
if ((lst->next == NULL || lst->next->pressision == D_RED_R
|
||||||
|| lst->next->pressision == D_RED_R
|
|| lst->next->pressision == RED_R) && !ft_strncmp(lst->val, ")",
|
||||||
|| lst->next->pressision == RED_R)
|
1))
|
||||||
&& !ft_strncmp(lst->val, ")", 1))
|
|
||||||
return (1);
|
return (1);
|
||||||
lst = lst->next;
|
lst = lst->next;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/29 09:21:09 by nalebrun #+# #+# */
|
/* Created: 2025/01/29 09:21:09 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/01/29 09:21:09 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 18:02:51 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -31,21 +31,6 @@ const char *translate_state(t_state state)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
// const char *translate_redir(t_redir redir)
|
|
||||||
// {
|
|
||||||
// const char *out;
|
|
||||||
//
|
|
||||||
// if (redir == _RED_L)
|
|
||||||
// out = "redir : RED_L ";
|
|
||||||
// else if (redir == _RED_R)
|
|
||||||
// out = "redir : RED_R ";
|
|
||||||
// else if (redir == _RED_DR)
|
|
||||||
// out = "redir : _RED_DR ";
|
|
||||||
// else
|
|
||||||
// out = "Not redirected ";
|
|
||||||
// return (out);
|
|
||||||
// }
|
|
||||||
|
|
||||||
t_dio_node get_cmd_txt(t_ast_n *node)
|
t_dio_node get_cmd_txt(t_ast_n *node)
|
||||||
{
|
{
|
||||||
t_dio_node txt;
|
t_dio_node txt;
|
||||||
@@ -59,9 +44,6 @@ t_dio_node get_cmd_txt(t_ast_n *node)
|
|||||||
args = ft_tabstr(node->args);
|
args = ft_tabstr(node->args);
|
||||||
txt.args = ft_sprintf("%s%s%s", NL, args, NL);
|
txt.args = ft_sprintf("%s%s%s", NL, args, NL);
|
||||||
free(args);
|
free(args);
|
||||||
// txt.redir = translate_redir(node->redir);
|
|
||||||
// txt.inf = ft_sprintf("Infile : %s%s", node->infile, NL);
|
|
||||||
// txt.outf = ft_sprintf("Outfile : %s", node->outfile);
|
|
||||||
txt.files = ft_sprintf("redir: UNCHECKED\n");
|
txt.files = ft_sprintf("redir: UNCHECKED\n");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* drawio_print_ast.c :+: :+: :+: */
|
/* drawio_print_ast.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/29 09:54:31 by lderidde #+# #+# */
|
/* Created: 2025/01/29 09:54:31 by lderidde #+# #+# */
|
||||||
/* Updated: 2025/02/07 09:09:01 by lderidde ### ########.fr */
|
/* Updated: 2025/02/07 17:27:47 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -23,8 +23,7 @@ char *get_node_txt(t_ast_n *node)
|
|||||||
subsh = ft_strdup(" (subsh) ");
|
subsh = ft_strdup(" (subsh) ");
|
||||||
else
|
else
|
||||||
subsh = ft_strdup("");
|
subsh = ft_strdup("");
|
||||||
out = ft_sprintf("%s%s%s%s%s", txt.st, txt.cmd, txt.args,
|
out = ft_sprintf("%s%s%s%s%s", txt.st, txt.cmd, txt.args, subsh, txt.files);
|
||||||
subsh, txt.files);
|
|
||||||
free(txt.cmd);
|
free(txt.cmd);
|
||||||
free(txt.args);
|
free(txt.args);
|
||||||
free(txt.files);
|
free(txt.files);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/27 15:09:16 by nalebrun #+# #+# */
|
/* Created: 2025/01/27 15:09:16 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/01/27 15:09:16 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 17:36:08 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -28,6 +28,15 @@ static int get_char_count(char *str, char c)
|
|||||||
return (count);
|
return (count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void write_ampercent(char *out)
|
||||||
|
{
|
||||||
|
out[0] = '&';
|
||||||
|
out[1] = 'a';
|
||||||
|
out[2] = 'm';
|
||||||
|
out[3] = 'p';
|
||||||
|
out[4] = ';';
|
||||||
|
}
|
||||||
|
|
||||||
char *replace_ampercent(char *src)
|
char *replace_ampercent(char *src)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -43,11 +52,7 @@ char *replace_ampercent(char *src)
|
|||||||
{
|
{
|
||||||
if (src[i] == '&')
|
if (src[i] == '&')
|
||||||
{
|
{
|
||||||
out[j] = '&';
|
write_ampercent(&out[j]);
|
||||||
out[j + 1] = 'a';
|
|
||||||
out[j + 2] = 'm';
|
|
||||||
out[j + 3] = 'p';
|
|
||||||
out[j + 4] = ';';
|
|
||||||
j += 5;
|
j += 5;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -58,6 +63,18 @@ char *replace_ampercent(char *src)
|
|||||||
return (out);
|
return (out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void write_left_redi(char *out)
|
||||||
|
{
|
||||||
|
out[0] = '&';
|
||||||
|
out[1] = 'a';
|
||||||
|
out[2] = 'm';
|
||||||
|
out[3] = 'p';
|
||||||
|
out[4] = ';';
|
||||||
|
out[5] = 'l';
|
||||||
|
out[6] = 't';
|
||||||
|
out[7] = ';';
|
||||||
|
}
|
||||||
|
|
||||||
char *replace_left_red(char *src)
|
char *replace_left_red(char *src)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -73,14 +90,7 @@ char *replace_left_red(char *src)
|
|||||||
{
|
{
|
||||||
if (src[i] == '<')
|
if (src[i] == '<')
|
||||||
{
|
{
|
||||||
out[j] = '&';
|
write_left_redi(&out[j]);
|
||||||
out[j + 1] = 'a';
|
|
||||||
out[j + 2] = 'm';
|
|
||||||
out[j + 3] = 'p';
|
|
||||||
out[j + 4] = ';';
|
|
||||||
out[j + 5] = 'l';
|
|
||||||
out[j + 6] = 't';
|
|
||||||
out[j + 7] = ';';
|
|
||||||
j += 8;
|
j += 8;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/15 08:23:41 by nalebrun #+# #+# */
|
/* Created: 2025/01/15 08:23:41 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/02/07 12:08:40 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 17:59:43 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -60,7 +60,6 @@ t_ast_n *parser(char *input, t_msh *msh)
|
|||||||
{
|
{
|
||||||
gen_dio_ast(ast, dio);
|
gen_dio_ast(ast, dio);
|
||||||
drawio_end_file(dio);
|
drawio_end_file(dio);
|
||||||
ft_debug(" draw.io file generated !\n");
|
|
||||||
}
|
}
|
||||||
free_linked_list(lst);
|
free_linked_list(lst);
|
||||||
return (ast);
|
return (ast);
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/02/07 12:08:53 by nalebrun #+# #+# */
|
/* Created: 2025/02/07 12:08:53 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/02/07 12:08:53 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 17:58:30 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -21,18 +21,17 @@ int only_operator(t_node *head)
|
|||||||
|
|
||||||
int syntax_err_mess(char *token)
|
int syntax_err_mess(char *token)
|
||||||
{
|
{
|
||||||
ft_fprintf(2, "minishell : syntax error near unexpected token `%s'\n", token);
|
ft_fprintf(2, "minishell : syntax error near unexpected token `%s'\n",
|
||||||
|
token);
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int unexpected_token(t_node *node)
|
int unexpected_token(t_node *node)
|
||||||
{
|
{
|
||||||
if (!ft_strncmp(node->val, "%", 1)
|
if (!ft_strncmp(node->val, "%", 1) || (!ft_strncmp(node->val, "&", 1)
|
||||||
|| (!ft_strncmp(node->val, "&", 1) && ft_strncmp(node->val, "&&", 2))
|
&& ft_strncmp(node->val, "&&", 2)) || !ft_strncmp(node->val, ";", 1)
|
||||||
|| !ft_strncmp(node->val, ";", 1)
|
|
||||||
|| !ft_strncmp(node->val, "[", 1) || !ft_strncmp(node->val, "]", 1)
|
|| !ft_strncmp(node->val, "[", 1) || !ft_strncmp(node->val, "]", 1)
|
||||||
|| !ft_strncmp(node->val, "{", 1) || !ft_strncmp(node->val, "}", 1)
|
|| !ft_strncmp(node->val, "{", 1) || !ft_strncmp(node->val, "}", 1))
|
||||||
)
|
|
||||||
return (1);
|
return (1);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@@ -50,6 +49,5 @@ int syntax_error(t_node *head)
|
|||||||
return (syntax_err_mess(cpy->val));
|
return (syntax_err_mess(cpy->val));
|
||||||
cpy = cpy->next;
|
cpy = cpy->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* linked_list.c :+: :+: :+: */
|
/* linked_list.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/15 13:38:49 by lderidde #+# #+# */
|
/* Created: 2025/01/15 13:38:49 by lderidde #+# #+# */
|
||||||
/* Updated: 2025/01/31 13:20:13 by lderidde ### ########.fr */
|
/* Updated: 2025/02/07 17:27:00 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/21 08:54:32 by nalebrun #+# #+# */
|
/* Created: 2025/01/21 08:54:32 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/01/21 08:54:32 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 17:26:33 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -39,22 +39,22 @@ t_token get_token(char *str)
|
|||||||
{
|
{
|
||||||
t_token token;
|
t_token token;
|
||||||
|
|
||||||
if (!ft_strncmp(str, "&", 1) || !ft_strncmp(str, "|", 1)
|
if (!ft_strncmp(str, "&", 1) || !ft_strncmp(str, "|", 1) || !ft_strncmp(str,
|
||||||
|| !ft_strncmp(str, "(", 1) || !ft_strncmp(str, ")", 1)
|
"(", 1) || !ft_strncmp(str, ")", 1) || !ft_strncmp(str, "<", 1)
|
||||||
|| !ft_strncmp(str, "<", 1) || !ft_strncmp(str, ">", 1))
|
|| !ft_strncmp(str, ">", 1))
|
||||||
token = OPERATOR;
|
token = OPERATOR;
|
||||||
else
|
else
|
||||||
token = WORD;
|
token = WORD;
|
||||||
return (token);
|
return (token);
|
||||||
}
|
}
|
||||||
|
|
||||||
t_pres get_pressision(char *s, t_token token,
|
t_pres get_pressision(char *s, t_token token, t_token last_token,
|
||||||
t_token last_token, t_pres last_pres)
|
t_pres last_pres)
|
||||||
{
|
{
|
||||||
if (token == OPERATOR)
|
if (token == OPERATOR)
|
||||||
return (get_operator(s));
|
return (get_operator(s));
|
||||||
else if (last_token == OPERATOR && (last_pres == RED_R
|
else if (last_token == OPERATOR && (last_pres == RED_R || last_pres == RED_L
|
||||||
|| last_pres == RED_L || last_pres == D_RED_R))
|
|| last_pres == D_RED_R))
|
||||||
return (RED_FILE);
|
return (RED_FILE);
|
||||||
else if (last_token == OPERATOR && last_pres == HEREDOC)
|
else if (last_token == OPERATOR && last_pres == HEREDOC)
|
||||||
return (LIM);
|
return (LIM);
|
||||||
|
|||||||
@@ -3,10 +3,10 @@
|
|||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* tokenizer.c :+: :+: :+: */
|
/* tokenizer.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: lderidde <lderidde@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/15 13:27:57 by lderidde #+# #+# */
|
/* Created: 2025/01/15 13:27:57 by lderidde #+# #+# */
|
||||||
/* Updated: 2025/01/31 13:24:28 by lderidde ### ########.fr */
|
/* Updated: 2025/02/07 17:26:04 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -45,7 +45,8 @@ static void set_token(t_node *head)
|
|||||||
while (it != NULL)
|
while (it != NULL)
|
||||||
{
|
{
|
||||||
it->token = get_token(it->val);
|
it->token = get_token(it->val);
|
||||||
it->pressision = get_pressision(it->val, it->token, last_token, last_pres);
|
it->pressision = get_pressision(it->val, it->token, last_token,
|
||||||
|
last_pres);
|
||||||
last_token = it->token;
|
last_token = it->token;
|
||||||
last_pres = it->pressision;
|
last_pres = it->pressision;
|
||||||
it = it->next;
|
it = it->next;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2025/01/22 14:24:05 by nalebrun #+# #+# */
|
/* Created: 2025/01/22 14:24:05 by nalebrun #+# #+# */
|
||||||
/* Updated: 2025/01/22 14:24:05 by nalebrun ### ########.fr */
|
/* Updated: 2025/02/07 18:04:31 by nalebrun ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -76,8 +76,6 @@ int trim_nodes(t_node *head)
|
|||||||
if (!in_quote)
|
if (!in_quote)
|
||||||
{
|
{
|
||||||
tmp = ft_strtrim(it->val, " \t\n");
|
tmp = ft_strtrim(it->val, " \t\n");
|
||||||
if (!tmp)
|
|
||||||
return (0);
|
|
||||||
free(it->val);
|
free(it->val);
|
||||||
it->val = tmp;
|
it->val = tmp;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user