feat: adding the and / or treatment
This commit is contained in:
parent
390c7976b4
commit
4d56158633
1 changed files with 27 additions and 2 deletions
|
|
@ -6,11 +6,12 @@
|
|||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/10/09 12:44:53 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/10/09 12:46:06 by maiboyer ### ########.fr */
|
||||
/* Updated: 2024/10/10 15:19:20 by rparodi ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "ast/ast.h"
|
||||
#include "me/types.h"
|
||||
#include "parser/token.h"
|
||||
#include "me/vec/vec_ast.h"
|
||||
#include "me/vec/vec_token.h"
|
||||
|
|
@ -25,4 +26,28 @@
|
|||
/// struct s_ast_list if (tok.type == TOK_AND || tok.type == TOK_OR)
|
||||
/// struct s_ast_pipeline if (tok.type == TOK_PIPE)
|
||||
/// `ast/include/ast/_raw_structs.h`
|
||||
t_ast_node ast_from_op(t_token tok, t_vec_ast *output_queue);
|
||||
t_ast_node ast_from_op(t_token tok, t_vec_ast *output_queue)
|
||||
{
|
||||
t_ast_node tmp;
|
||||
|
||||
if (tok.type != TOK_AND && tok.type != TOK_OR && tok.type != TOK_PIPE)
|
||||
me_abort("ast_from_op not the good token type gived !\n");
|
||||
if (tok.type == TOK_AND)
|
||||
{
|
||||
tmp = ast_alloc(AST_LIST);
|
||||
tmp->data.list.op = AST_LIST_AND;
|
||||
vec_ast_pop(output_queue, &tmp->data.list.right);
|
||||
vec_ast_pop(output_queue, &tmp->data.list.left);
|
||||
}
|
||||
if (tok.type == TOK_OR)
|
||||
{
|
||||
tmp = ast_alloc(AST_LIST);
|
||||
tmp->data.list.op = AST_LIST_OR;
|
||||
vec_ast_pop(output_queue, &tmp->data.list.right);
|
||||
vec_ast_pop(output_queue, &tmp->data.list.left);
|
||||
}
|
||||
if (tok.type == TOK_PIPE)
|
||||
{
|
||||
tmp = ast_alloc(AST_PIPELINE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue