gros merge
This commit is contained in:
69
includes/parser/ast.h
Normal file
69
includes/parser/ast.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ast.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/24 08:23:27 by nalebrun #+# #+# */
|
||||
/* Updated: 2025/01/24 08:23:27 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef AST_H
|
||||
# define AST_H
|
||||
|
||||
/*# include "../../includes/env.h"*/
|
||||
# include "../minishell.h"
|
||||
|
||||
typedef enum e_state
|
||||
{
|
||||
UNDEF,
|
||||
_AND,
|
||||
_OR,
|
||||
_CMD,
|
||||
_PLINE,
|
||||
_SUBSH
|
||||
} t_state;
|
||||
|
||||
typedef enum e_redir
|
||||
{
|
||||
_NR,
|
||||
_RED_L,
|
||||
_RED_R,
|
||||
_RED_DR
|
||||
} t_redir;
|
||||
|
||||
typedef struct s_ast_n
|
||||
{
|
||||
t_state state;
|
||||
struct s_ast_n *parent;
|
||||
struct s_ast_n *left;
|
||||
struct s_ast_n *right;
|
||||
struct s_ast_n **pline;
|
||||
t_msh *msh;
|
||||
char *cmd;
|
||||
char **args;
|
||||
int fds[2];
|
||||
int _stdout;
|
||||
int _stdin;
|
||||
t_redir redir;
|
||||
char *infile;
|
||||
char *outfile;
|
||||
bool sh;
|
||||
} t_ast_n;
|
||||
|
||||
typedef struct s_nodell
|
||||
{
|
||||
t_node *node;
|
||||
struct s_nodell *next;
|
||||
} t_nodell;
|
||||
|
||||
t_ast_n *get_ast(t_msh *msh, t_node *lst);
|
||||
t_nodell *cutll(t_node *lst, t_node *expected, size_t limiter);
|
||||
t_node *get_top_token(t_node *lst, t_state *state);
|
||||
|
||||
// env TMP
|
||||
char **init_env(char **envp);
|
||||
|
||||
#endif
|
||||
43
includes/parser/drawio.h
Normal file
43
includes/parser/drawio.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* drawio.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/27 14:20:35 by nalebrun #+# #+# */
|
||||
/* Updated: 2025/01/27 14:20:35 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef DRAWIO_H
|
||||
# define DRAWIO_H
|
||||
|
||||
# include "../minishell.h"
|
||||
|
||||
typedef struct s_dio_node
|
||||
{
|
||||
const char *st;
|
||||
const char *redir;
|
||||
char *cmd;
|
||||
char *args;
|
||||
char *inf;
|
||||
char *outf;
|
||||
} t_dio_node;
|
||||
|
||||
typedef struct s_elems
|
||||
{
|
||||
t_dio_elem rect;
|
||||
t_dio_elem arrow;
|
||||
} t_elems;
|
||||
|
||||
// internal
|
||||
char *replace_ampercent(char *src);
|
||||
char *replace_left_red(char *src);
|
||||
t_dio_node get_cmd_txt(t_ast_n *node);
|
||||
int print_ast(t_ast_n *node, t_elems *e, int fd);
|
||||
|
||||
// external
|
||||
void gen_dio_linked_list(t_node *head, int fd);
|
||||
void gen_dio_ast(t_ast_n *head, int fd);
|
||||
#endif
|
||||
20
includes/parser/parsing.h
Normal file
20
includes/parser/parsing.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* parsing.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/24 14:45:28 by nalebrun #+# #+# */
|
||||
/* Updated: 2025/01/24 14:45:28 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef PARSING_H
|
||||
# define PARSING_H
|
||||
|
||||
# include "../minishell.h"
|
||||
|
||||
t_ast_n *parser(char *input, char **envp, t_msh *msh);
|
||||
|
||||
#endif
|
||||
66
includes/parser/tokenizer.h
Normal file
66
includes/parser/tokenizer.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* tokenizer.h :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: nalebrun <nalebrun@student.s19.be> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/01/15 13:30:12 by nalebrun #+# #+# */
|
||||
/* Updated: 2025/01/20 13:15:34 by nalebrun ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef TOKENIZER_H
|
||||
# define TOKENIZER_H
|
||||
|
||||
# include "../minishell.h"
|
||||
|
||||
typedef enum e_token
|
||||
{
|
||||
UNSET,
|
||||
OPERATOR,
|
||||
WORD
|
||||
} t_token;
|
||||
|
||||
typedef enum e_pres
|
||||
{
|
||||
UNDEFINED,
|
||||
COMMAND,
|
||||
AND,
|
||||
OR,
|
||||
PIPE,
|
||||
SUBSH_S,
|
||||
SUBSH_E,
|
||||
RED_L,
|
||||
RED_R,
|
||||
HEREDOC,
|
||||
D_RED_R,
|
||||
PARAMETER,
|
||||
RED_FILE,
|
||||
LIM
|
||||
} t_pres;
|
||||
|
||||
typedef struct s_node
|
||||
{
|
||||
struct s_node *next;
|
||||
char *val;
|
||||
enum e_token token;
|
||||
enum e_pres pressision;
|
||||
} t_node;
|
||||
|
||||
t_node *tokenize(char *str);
|
||||
t_node *create_node(char *val, t_token token);
|
||||
int add_node_back(t_node **head, char *val, t_token token, t_pres pres);
|
||||
int merge_with_next_node(t_node *node);
|
||||
void free_linked_list(t_node *stack);
|
||||
t_token get_token(char *str);
|
||||
t_pres get_pressision(char *s, t_token token, t_token last_token, t_pres last_pres);
|
||||
int create_node_after(t_node *elem, char *val);
|
||||
char *copy_meta_xor(char *val, int *copied, int rev);
|
||||
int is_meta(char c);
|
||||
int is_sticked(char *val);
|
||||
int trim_nodes(t_node *head);
|
||||
void debug_linked_list(t_node *head, char *msg);
|
||||
int find_quote_node(t_node *head, char q);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user