-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparser.c
32 lines (29 loc) · 1.24 KB
/
parser.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parser.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: omoussao <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/26 17:09:44 by omoussao #+# #+# */
/* Updated: 2022/03/01 19:35:27 by omoussao ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
// Parser
t_cmdtree *parser(t_lexer *tokens)
{
t_cmdtree *syntax_tree;
t_node *tokp;
if (!tokens || tokens->len <= 1)
return (NULL);
tokp = tokens->top;
syntax_tree = parse_cmdline(&tokp);
if (!syntax_tree
|| (tokp && current(tokp) != ENDOFCMD))
{
_error("parser", "syntax error!", NULL, 2);
return (NULL);
}
return (syntax_tree);
}