From 6bb9eafa5fe8de5194801ab5ff3bd898a853c9fb Mon Sep 17 00:00:00 2001 From: nass1pro Date: Mon, 15 Jun 2020 17:49:27 +0200 Subject: change name function --- src/lexer/trim.c | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/lexer/trim.c (limited to 'src/lexer/trim.c') diff --git a/src/lexer/trim.c b/src/lexer/trim.c new file mode 100644 index 0000000..9fbb6cc --- /dev/null +++ b/src/lexer/trim.c @@ -0,0 +1,7 @@ + +#include "lexer.h" + +t_ftlst *lexe_trim_out(t_ftlst *lst) +{ + return (lst); +} -- cgit From 7b383ea28c818441ae5a75ed573dc03e992cd89f Mon Sep 17 00:00:00 2001 From: nass1pro Date: Mon, 15 Jun 2020 19:24:25 +0200 Subject: Update lexer --- src/lexer/trim.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) (limited to 'src/lexer/trim.c') diff --git a/src/lexer/trim.c b/src/lexer/trim.c index 9fbb6cc..0f2cde1 100644 --- a/src/lexer/trim.c +++ b/src/lexer/trim.c @@ -1,7 +1,60 @@ #include "lexer.h" +char *del_space(char *str) +{ + int i; + char *s; + + i = 0; + while(str[++i] != '\0') + { + if(str[i] == '\\' && str[i + 1] == ' ') + i += 2; + if(str[i] == ' ') + break; + } + s = ft_strsubf(str, 0, i); + return(s); +} + +char *del_quote(char *str) +{ + int i; + char *s; + + i = 1; + while(str[++i] != '\0') + if (str[i] == '\'' || str[i] == '"') + break; + s = ft_strsubf(str, 1, i - 1); + return (s); +} + t_ftlst *lexe_trim_out(t_ftlst *lst) { - return (lst); + t_ftlst *first; + t_token *tk; + + first = lst; + while(lst != NULL) + { + tk = lst->data; + if (tk->tag >= TAG_STR_DOUBLE || tk->tag >= TAG_STR_SINGLE) + { + tk->content = del_quote(tk->content); + if(lst->next == NULL) + if (tk->tag & TAG_STICK) + tk->tag -= TAG_STICK; + } + else + { + tk->content = del_space(tk->content); + if(lst->next == NULL) + if (tk->tag & TAG_STICK) + tk->tag -= TAG_STICK; + } + lst = lst->next; + } + return (first); } -- cgit From 209c15cee6e0c3604d34a1d1d656e045e71b1c9d Mon Sep 17 00:00:00 2001 From: nass1pro Date: Mon, 15 Jun 2020 19:50:47 +0200 Subject: Update lexer stick OK --- src/lexer/trim.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/lexer/trim.c') diff --git a/src/lexer/trim.c b/src/lexer/trim.c index 0f2cde1..ad696a4 100644 --- a/src/lexer/trim.c +++ b/src/lexer/trim.c @@ -1,20 +1,24 @@ #include "lexer.h" -char *del_space(char *str) +char *del_space(t_token *tk) { int i; char *s; i = 0; - while(str[++i] != '\0') + while(tk->content[++i] != '\0') { - if(str[i] == '\\' && str[i + 1] == ' ') + if(tk->content[i] == '\\' && tk->content[i + 1] == ' ') + { i += 2; - if(str[i] == ' ') + if (tk->content[i] == '\0') + tk->tag = tk->tag | TAG_STICK; + } + if(tk->content[i] == ' ') break; } - s = ft_strsubf(str, 0, i); + s = ft_strsubf(tk->content, 0, i); return(s); } @@ -49,7 +53,7 @@ t_ftlst *lexe_trim_out(t_ftlst *lst) } else { - tk->content = del_space(tk->content); + tk->content = del_space(tk); if(lst->next == NULL) if (tk->tag & TAG_STICK) tk->tag -= TAG_STICK; -- cgit