|
|
@ -3,10 +3,10 @@ |
|
|
|
/* ::: :::::::: */ |
|
|
|
/* lexer.c :+: :+: :+: */ |
|
|
|
/* +:+ +:+ +:+ */ |
|
|
|
/* By: mea <marvin@42.fr> +#+ +:+ +#+ */ |
|
|
|
/* By: mea <mea@student.42.fr> +#+ +:+ +#+ */ |
|
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
|
/* Created: 2022/05/02 13:44:57 by narnaud #+# #+# */ |
|
|
|
/* Updated: 2022/05/16 12:53:40 by narnaud ### ########.fr */ |
|
|
|
/* Updated: 2022/05/17 15:58:09 by mea ### ########.fr */ |
|
|
|
/* */ |
|
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
@ -24,7 +24,7 @@ void tmp_dealer(t_datas *datas, t_lexer *lex, char *line, char *tmp) |
|
|
|
if (check_state(lex, &line)) |
|
|
|
continue ; |
|
|
|
if (lex->state != S_QUOTE_ST && lex->deep == 0 && *line == '$' |
|
|
|
&& (line[1] != '\0' && !isspace(line[1]))) |
|
|
|
&& (line[1] != '\0' && !ft_isspace(line[1]))) |
|
|
|
{ |
|
|
|
tmp_i = replace_var(datas, &line, tmp, tmp_i); |
|
|
|
lex->empty = 1; |
|
|
@ -35,6 +35,8 @@ void tmp_dealer(t_datas *datas, t_lexer *lex, char *line, char *tmp) |
|
|
|
&& (*line == '"' || *line == '\''))) |
|
|
|
tmp[tmp_i++] = *(line++); |
|
|
|
} |
|
|
|
if (!*tmp && (*(line - 1) == '"' || *(line - 1) == '\'')) |
|
|
|
lex->empty = 1; |
|
|
|
} |
|
|
|
|
|
|
|
t_token *lexer(t_datas *datas, char *line) |
|
|
@ -52,7 +54,10 @@ t_token *lexer(t_datas *datas, char *line) |
|
|
|
else |
|
|
|
create_token(lex, tmp); |
|
|
|
free(tmp); |
|
|
|
ret = lex->tokens; |
|
|
|
if (lex->state != ROOT_ST) |
|
|
|
ret = NULL; |
|
|
|
else |
|
|
|
ret = lex->tokens; |
|
|
|
free(lex); |
|
|
|
return (ret); |
|
|
|
} |
|
|
@ -126,16 +131,15 @@ static int check_register(t_lexer *lex, char **line, char *tmp) |
|
|
|
return (create_token(lex, tmp)); |
|
|
|
if (check_ope(lex, line, tmp)) |
|
|
|
return (1); |
|
|
|
if (**line == '(' || spaces) |
|
|
|
if ((**line == '(' && ++lex->deep) || spaces) |
|
|
|
{ |
|
|
|
if (**line == '(') |
|
|
|
lex->deep++; |
|
|
|
if (*tmp || lex->empty) |
|
|
|
{ |
|
|
|
if (lex->type == WORD && lex->wc) |
|
|
|
return (create_wc(lex, tmp)); |
|
|
|
return (create_token(lex, tmp)); |
|
|
|
} |
|
|
|
return (1); |
|
|
|
} |
|
|
|
return (0); |
|
|
|
} |
|
|
|