fixes: fixed error when parsing failed
This commit is contained in:
parent
77e7f65b41
commit
a567a5323b
4 changed files with 23 additions and 27 deletions
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/09/06 16:31:41 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/10 17:39:40 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/10/10 17:48:06 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -26,8 +26,8 @@
|
|||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
void ft_exit(t_state *maiboyerlpb, t_u8 exit_status);
|
||||
void parse_str(t_state *state);
|
||||
void ft_exit(t_state *maiboyerlpb, t_u8 exit_status);
|
||||
t_error parse_str(t_state *state);
|
||||
|
||||
t_error get_user_input(t_state *state)
|
||||
{
|
||||
|
|
@ -78,7 +78,11 @@ void ft_take_args(t_state *state)
|
|||
if (state->str_input == NULL)
|
||||
ft_exit(state, 0);
|
||||
line_history_add(state->str_input);
|
||||
parse_str(state);
|
||||
if (parse_str(state))
|
||||
{
|
||||
mem_free(state->str_input);
|
||||
continue;
|
||||
}
|
||||
exec_shcat(state);
|
||||
mem_free(state->str_input);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/03/28 14:40:38 by rparodi #+# #+# */
|
||||
/* Updated: 2024/10/10 17:37:45 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/10/10 17:47:24 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
|
@ -83,25 +83,25 @@ t_error populate_env(t_hashmap_env *env, t_str envp[])
|
|||
|
||||
t_error yarn(t_vec_token ts, t_vec_ast *output);
|
||||
|
||||
void parse_str(t_state *state)
|
||||
t_error parse_str(t_state *state)
|
||||
{
|
||||
t_vec_token tokens;
|
||||
t_vec_ast ast;
|
||||
|
||||
if (tokenize(state->str_input, &tokens))
|
||||
return;
|
||||
return (ERROR);
|
||||
if (ts_apply_passes(tokens, &tokens))
|
||||
return;
|
||||
// TODO: remove
|
||||
ts_print(&tokens);
|
||||
return (ERROR);
|
||||
ts_print(&tokens); // TODO: remove
|
||||
if (yarn(tokens, &ast))
|
||||
return ((void)printf("failed to ast build\n"));
|
||||
return ((void)printf("failed to ast build\n"), (ERROR));
|
||||
if (ast.len != 1)
|
||||
me_abort("Unhandled error: ast.len != 1");
|
||||
return (ERROR);
|
||||
vec_ast_pop(&ast, &state->ast);
|
||||
ast_print(state->ast);
|
||||
printf("\nast\n");
|
||||
vec_ast_free(ast);
|
||||
return (NO_ERROR);
|
||||
}
|
||||
|
||||
t_i32 main(t_i32 argc, t_str argv[], t_str envp[])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue