Merge branch 'main' of https://github.com/gazhonsepaskwa/m_moat_point_d_interogation
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "tokenizer/tokenizer.h"
|
#include "tokenizer/tokenizer.h"
|
||||||
|
/*#include "../includes/env.h"*/
|
||||||
|
|
||||||
void truncate_comment(char *str)
|
void truncate_comment(char *str)
|
||||||
{
|
{
|
||||||
@@ -30,18 +31,28 @@ void truncate_comment(char *str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int ac, char **av)
|
/*static t_data *init_data(char **envp)*/
|
||||||
|
/*{*/
|
||||||
|
/* t_data *data;*/
|
||||||
|
/**/
|
||||||
|
/* data = malloc (sizeof(t_data));*/
|
||||||
|
/* data->env = init_env(envp);*/
|
||||||
|
/* return (data);*/
|
||||||
|
/*}*/
|
||||||
|
|
||||||
|
int main(int ac, char **av, char **envp)
|
||||||
{
|
{
|
||||||
t_node *lst;
|
t_node *lst;
|
||||||
char *expanded;
|
|
||||||
|
|
||||||
(void)ac;
|
(void)ac;
|
||||||
|
(void)envp;
|
||||||
|
/*t_data data;*/
|
||||||
|
|
||||||
|
/*data = init_data(envp);*/
|
||||||
truncate_comment(av[1]);
|
truncate_comment(av[1]);
|
||||||
expanded = expander(av[1]);
|
lst = tokenize(av[1]);
|
||||||
lst = tokenize(expanded);
|
|
||||||
if (!lst)
|
if (!lst)
|
||||||
return (free(expanded), 1);
|
return (1);
|
||||||
ft_free(expanded);
|
|
||||||
debug_linked_list(lst, "Tokenized");
|
debug_linked_list(lst, "Tokenized");
|
||||||
free_linked_list(lst);
|
free_linked_list(lst);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ t_node *create_node(char *val, t_token token)
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
node->val = ft_strdup(val);
|
node->val = ft_strdup(val);
|
||||||
node->token = token;
|
node->token = token;
|
||||||
|
node->pressision = 0;
|
||||||
node->next = NULL;
|
node->next = NULL;
|
||||||
return (node);
|
return (node);
|
||||||
}
|
}
|
||||||
@@ -86,21 +87,38 @@ void debug_linked_list(t_node *head, char *msg)
|
|||||||
{
|
{
|
||||||
t_node *current;
|
t_node *current;
|
||||||
char *token;
|
char *token;
|
||||||
|
char *pres;
|
||||||
|
|
||||||
current = head;
|
current = head;
|
||||||
printf("----------------------------------------------------------{%s} \n",
|
printf("----------------------------------------------------------{%s} \n",
|
||||||
msg);
|
msg);
|
||||||
while (current != NULL)
|
while (current != NULL)
|
||||||
{
|
{
|
||||||
|
// set val for base token
|
||||||
if (current->token == OPERATOR)
|
if (current->token == OPERATOR)
|
||||||
token = ft_strdup("OPERATOR");
|
token = ft_strdup("OPERATOR");
|
||||||
else if (current->token == WORD)
|
else if (current->token == WORD)
|
||||||
token = ft_strdup("WORD ");
|
token = ft_strdup(" WORD");
|
||||||
else if (current->token == UNSET)
|
else if (current->token == UNSET)
|
||||||
token = ft_strdup("UNSET ");
|
token = ft_strdup(" UNSET");
|
||||||
else
|
else
|
||||||
token = ft_strdup("??? ");
|
token = ft_strdup(" ???");
|
||||||
printf("| Node - TOKEN: %s -> val: |%s|\n", token, current->val);
|
|
||||||
|
// set vals for pressision token
|
||||||
|
if (current->pressision == AND)
|
||||||
|
pres = ft_strdup("AND ");
|
||||||
|
if (current->pressision == OR)
|
||||||
|
pres = ft_strdup("OR ");
|
||||||
|
if (current->pressision == PIPE)
|
||||||
|
pres = ft_strdup("PIPE ");
|
||||||
|
if (current->pressision == SUBSH_S)
|
||||||
|
pres = ft_strdup("SUBSH_S");
|
||||||
|
if (current->pressision == SUBSH_E)
|
||||||
|
pres = ft_strdup("SUBSH_E");
|
||||||
|
else
|
||||||
|
pres = ft_strdup("??? ");
|
||||||
|
|
||||||
|
printf("| Node - TOKEN: %s.%s -> val: |%s|\n", token, pres, current->val);
|
||||||
free(token);
|
free(token);
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,21 @@ typedef enum e_token
|
|||||||
WORD
|
WORD
|
||||||
} t_token;
|
} t_token;
|
||||||
|
|
||||||
|
typedef enum e_pres
|
||||||
|
{
|
||||||
|
AND,
|
||||||
|
OR,
|
||||||
|
PIPE,
|
||||||
|
SUBSH_S,
|
||||||
|
SUBSH_E
|
||||||
|
} t_pres;
|
||||||
|
|
||||||
typedef struct s_node
|
typedef struct s_node
|
||||||
{
|
{
|
||||||
struct s_node *next;
|
struct s_node *next;
|
||||||
char *val;
|
char *val;
|
||||||
enum e_token token;
|
enum e_token token;
|
||||||
|
enum e_pres pressision;
|
||||||
} t_node;
|
} t_node;
|
||||||
|
|
||||||
t_node *tokenize(char *str);
|
t_node *tokenize(char *str);
|
||||||
|
|||||||
Reference in New Issue
Block a user