-
Notifications
You must be signed in to change notification settings - Fork 1
/
parse.c
42 lines (37 loc) · 1.45 KB
/
parse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariahi <ariahi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/21 18:34:05 by ariahi #+# #+# */
/* Updated: 2022/09/17 19:39:35 by ariahi ### ########.fr */
/* */
/* ************************************************************************** */
#include "parse/parse.h"
#include "parse/lexer.h"
t_parse *parse_line(t_lexer *lexer)
{
t_token token;
t_parse *pipline;
pipline = parse_pipline(lexer);
if (!pipline || pipline == RULE_E)
return (pipline);
token = lexer_next(lexer);
if (token.type != EOF_T)
return (print_err(lexer, token), free_tree(&pipline), pipline);
return (pipline);
}
t_parse *parse(char *line)
{
t_parse *parse;
t_lexer lexer;
line = expand(enc_quotes(line));
lexer = lexer_int(line);
parse = parse_line(&lexer);
free(line);
if (!parse || parse == RULE_E)
return (NULL);
return (parse);
}