diff options
| author | nass1pro <nass1pro@gmail.com> | 2020-06-09 19:48:34 +0200 |
|---|---|---|
| committer | nass1pro <nass1pro@gmail.com> | 2020-06-13 11:31:00 +0200 |
| commit | 579a26f5593039ffbbd1a81e45ecf0ef8797cb5d (patch) | |
| tree | c5b6761db98e27d15bab3fb45ba9e0a646cf06e0 /test_mini/lexer_utils.c | |
| parent | 9fabc25a980550afc6337fd729632462f2680daa (diff) | |
| download | minishell-579a26f5593039ffbbd1a81e45ecf0ef8797cb5d.tar.gz minishell-579a26f5593039ffbbd1a81e45ecf0ef8797cb5d.tar.bz2 minishell-579a26f5593039ffbbd1a81e45ecf0ef8797cb5d.zip | |
add lexer
add single quote
Diffstat (limited to 'test_mini/lexer_utils.c')
| -rw-r--r-- | test_mini/lexer_utils.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/test_mini/lexer_utils.c b/test_mini/lexer_utils.c new file mode 100644 index 0000000..35050b3 --- /dev/null +++ b/test_mini/lexer_utils.c @@ -0,0 +1,81 @@ + +#include "lexer.h" + + +enum e_token_tag ret_token_sep_redir_append(char *input, int i) +{ + if (input[i + 1] == '>') + return(LTAG_REDIR_APPEND); + return (LTAG_REDIR_OUT); + +} + +enum e_token_tag ret_token_sep(char *input, int i) +{ + if (input[i] == ';') + return(LTAG_AND); + if (input[i] == '&') + return(LTAG_END); + if (input[i] == '|' && input[i + 1] == '|') + return(LTAG_OR); + if(input[i] == '|') + return(LTAG_PIPE); + if (input[i] == '>') + return(ret_token_sep_redir_append(input,i)); + if (input[i] == '<') + return(LTAG_REDIR_IN); + + return(0); + +} + + +int lexer_sep(char input) +{ + char *sep; + int i; + + i = 0; + sep = ";&|><()"; + while(sep[i] != '\0') + { + if(sep[i] == input) + return(1); + i++; + } + return (0); +} + +int lexe_space(char *input) +{ + int i; + + i=0; + while(input[i] == ' ') + i++; + return(i); +} + +int simple_cote(char *input, int i) +{ + int cote; + + cote = 39; + if (cote == input[i]) + return (1); + return(0); +} + + +int lexer_verif_entre_cote(char *input, int i) +{ + while((input[++i] != '"' || simple_cote(input,i)) && (input[i] != '\0')) + ; + //i++; + //if(input[i] == '"' || simple_cote(input,i)) + // return(lexer_verif_entre_cote(input, i)); + //if (input[i] == ' ') + // while(input[i] == ' ') + // i++; + return(i); +} |
