This repository has been archived by the owner on Sep 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathactions.c
46 lines (41 loc) · 1.51 KB
/
actions.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
43
44
45
46
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* actions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ebouvier <ebouvier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/08/28 13:00:35 by ebouvier #+# #+# */
/* Updated: 2023/08/28 13:01:37 by ebouvier ### ########.fr */
/* */
/* ************************************************************************** */
#include "parser.h"
t_bool accept(t_parser *parser, t_type type)
{
if (type == parser->current_tok->type)
{
parser->current_tok = parser->current_tok->next;
return (true);
}
return (false);
}
t_bool peek(t_parser *parser, t_type type)
{
if (type == parser->current_tok->type)
return (true);
return (false);
}
t_bool expect(t_parser *parser, t_type type)
{
if (accept(parser, type))
return (true);
return (false);
}
t_bool peek_next(t_parser *parser, t_type type)
{
if (parser && parser->current_tok && !parser->current_tok->next)
return (false);
if (type == parser->current_tok->next->type)
return (true);
return (false);
}