|
@ -6,7 +6,7 @@ |
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* +#+#+#+#+#+ +#+ */ |
|
|
/* Created: 2022/05/02 13:44:57 by narnaud #+# #+# */ |
|
|
/* Created: 2022/05/02 13:44:57 by narnaud #+# #+# */ |
|
|
/* Updated: 2022/05/03 09:19:36 by narnaud ### ########.fr */ |
|
|
/* Updated: 2022/05/03 11:42:26 by narnaud ### ########.fr */ |
|
|
/* */ |
|
|
/* */ |
|
|
/* ************************************************************************** */ |
|
|
/* ************************************************************************** */ |
|
|
|
|
|
|
|
@ -18,7 +18,10 @@ int create_token(t_lexer *lex, char str[]) |
|
|
t_type type; |
|
|
t_type type; |
|
|
|
|
|
|
|
|
type = lex->type; |
|
|
type = lex->type; |
|
|
lex->type = (lex->next_type || WORD); |
|
|
if (lex->next_type) |
|
|
|
|
|
lex->type = lex->next_type; |
|
|
|
|
|
else |
|
|
|
|
|
lex->type = WORD; |
|
|
lex->next_type = WORD; |
|
|
lex->next_type = WORD; |
|
|
if (!str[0]) |
|
|
if (!str[0]) |
|
|
return (0); |
|
|
return (0); |
|
@ -34,6 +37,8 @@ int create_token(t_lexer *lex, char str[]) |
|
|
} |
|
|
} |
|
|
tok->type = type; |
|
|
tok->type = type; |
|
|
tok->value = strdup(str); |
|
|
tok->value = strdup(str); |
|
|
|
|
|
if (DEBUG) |
|
|
|
|
|
printf("token value : %s - token type : %d\n", tok->value, type); |
|
|
if (!lex->tokens) |
|
|
if (!lex->tokens) |
|
|
lex->tokens = tok; |
|
|
lex->tokens = tok; |
|
|
return (1); |
|
|
return (1); |
|
@ -76,7 +81,7 @@ int check_register(t_lexer *lex, char **line, char *tmp) |
|
|
create_token(lex, tmp); |
|
|
create_token(lex, tmp); |
|
|
return (create_token(lex, "|")); |
|
|
return (create_token(lex, "|")); |
|
|
} |
|
|
} |
|
|
if (!spaces) |
|
|
if (!spaces || !*tmp) |
|
|
return (0); |
|
|
return (0); |
|
|
return (create_token(lex, tmp)); |
|
|
return (create_token(lex, tmp)); |
|
|
} |
|
|
} |
|
|