lexing comment remove

This commit is contained in:
LuckyLaszlo
2021-12-01 16:02:25 +01:00
parent 025ef76c01
commit b08da252de

View File

@@ -6,7 +6,7 @@
/* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */ /* By: lperrey <lperrey@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/19 08:38:55 by lperrey #+# #+# */ /* Created: 2021/10/19 08:38:55 by lperrey #+# #+# */
/* Updated: 2021/12/01 15:48:05 by lperrey ### ########.fr */ /* Updated: 2021/12/01 16:00:48 by lperrey ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@@ -20,19 +20,16 @@ int fill_token(t_token *t, char *input, int *i, int *t_i)
{ {
static int quotes_state = 0; static int quotes_state = 0;
// operators
if (!quotes_state) if (!quotes_state)
{ {
if (check_operators(t, input, i, t_i) == DELIMITE_TOKEN) if (check_operators(t, input, i, t_i) == DELIMITE_TOKEN)
return (DELIMITE_TOKEN); return (DELIMITE_TOKEN);
} }
// quoting
if (quoting(&quotes_state, input, i)) if (quoting(&quotes_state, input, i))
{ {
t->content[(*t_i)++] = input[(*i)++]; t->content[(*t_i)++] = input[(*i)++];
return (CONTINUE_TOKEN); return (CONTINUE_TOKEN);
} }
// blanks
if (!quotes_state && (input[*i] == ' ' || input[*i] == '\t')) if (!quotes_state && (input[*i] == ' ' || input[*i] == '\t'))
{ {
while (input[*i] == ' ' || input[*i] == '\t') while (input[*i] == ' ' || input[*i] == '\t')
@@ -50,7 +47,7 @@ static int quoting(int *quotes_state, char *input, int *i)
{ {
if (*quotes_state == IN_QUOTES) if (*quotes_state == IN_QUOTES)
*quotes_state = 0; *quotes_state = 0;
else if (ft_strchr(&input[*i + 1], '\'')) // if closed quotes else if (ft_strchr(&input[*i + 1], '\''))
*quotes_state = IN_QUOTES; *quotes_state = IN_QUOTES;
return (CONTINUE_TOKEN); return (CONTINUE_TOKEN);
} }
@@ -58,7 +55,7 @@ static int quoting(int *quotes_state, char *input, int *i)
{ {
if (*quotes_state == IN_DQUOTES) if (*quotes_state == IN_DQUOTES)
*quotes_state = 0; *quotes_state = 0;
else if (ft_strchr(&input[*i + 1], '\"')) // if closed dquotes else if (ft_strchr(&input[*i + 1], '\"'))
*quotes_state = IN_DQUOTES; *quotes_state = IN_DQUOTES;
return (CONTINUE_TOKEN); return (CONTINUE_TOKEN);
} }