update: parser now uses tokens from lexer
fixes pending: - some functions are longer than norminette allows - find solution to a list of commands being returned, even though a syntax error is found when processing tokens (maybe delegate some work to the lexer and return only a syntax-valid list?)
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: sede-san <sede-san@student.42madrid.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/02/09 18:56:41 by sede-san #+# #+# */
|
||||
/* Updated: 2026/02/10 12:33:55 by sede-san ### ########.fr */
|
||||
/* Updated: 2026/02/11 02:06:36 by sede-san ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
static t_token *tokenize(const char *line, size_t *start);
|
||||
static t_token_type get_token_type(const char *str);
|
||||
static t_token *token_new(t_token_type type, char *text);
|
||||
static void token_clear(t_token *token);
|
||||
void token_clear(t_token *token);
|
||||
static t_token *read_token(t_token_type type, const char *line, size_t *i);
|
||||
static t_token *read_word(const char *line, size_t *i);
|
||||
static inline bool is_meta(char c);
|
||||
@@ -41,7 +41,7 @@ t_list *lex(
|
||||
while (ft_isspace(line[i]))
|
||||
i++;
|
||||
if (line[i] == '\0')
|
||||
break;
|
||||
break ;
|
||||
token = tokenize(line, &i);
|
||||
ft_lstadd_back(&tokens, ft_lstnew(token));
|
||||
if (token == NULL)
|
||||
@@ -117,7 +117,7 @@ static t_token *token_new(
|
||||
return (token);
|
||||
}
|
||||
|
||||
static void token_clear(
|
||||
void token_clear(
|
||||
t_token *token
|
||||
)
|
||||
{
|
||||
@@ -158,8 +158,6 @@ static t_token *read_word(
|
||||
in_double_quote = false;
|
||||
while (line[*i] != '\0')
|
||||
{
|
||||
char c = line[*i];
|
||||
(void)c;
|
||||
if (line[*i] == '\'' && !in_double_quote)
|
||||
in_single_quote = !in_single_quote;
|
||||
else if (line[*i] == '"' && !in_single_quote)
|
||||
|
||||
Reference in New Issue
Block a user