aboutsummaryrefslogtreecommitdiff
path: root/src/checker/checker.h
blob: a6a2cc3378d49963930fbcb0777e229063c1413b (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   checker.h                                          :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/01/18 10:16:12 by cacharle          #+#    #+#             */
/*   Updated: 2020/01/18 10:51:42 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef CHECKER_H
# define CHECKER_H

# include <unistd.h>
# include "common.h"
# include "libft.h"

typedef enum
{
	STATUS_SUCCESS,
	STATUS_FAILURE,
	STATUS_ERROR,
	STATUS_EOF,
}	t_status;

typedef enum
{
	ACTION_SA,
	ACTION_SB,
	ACTION_SS,
	ACTION_PA,
	ACTION_PB,
	ACTION_RA,
	ACTION_RB,
	ACTION_RR,
	ACTION_RRA,
	ACTION_RRB,
	ACTION_RRR,
	ACTION_ERROR,
	ACTION_EOF
}	t_action_id;



# define FLAG_ARG_A    (1 << 0)
# define FLAG_ARG_B    (1 << 1)
# define FLAG_ARG_A_B  (1 << 2)
# define FLAG_ARG_B_A  (1 << 3)

typedef char	t_flag_arg;

typedef struct
{
	char		*id;
	t_flag_arg	args;
	union
	{
		void (*arg_1)(t_stack *);
		void (*arg_2)(t_stack *, t_stack *);
	}			func;
}				t_action;

t_status	check(t_stack *a, t_stack *b);
t_status	read_action(t_stack *a, t_stack *b);
t_status	exec_action(char *action_id, t_stack *a, t_stack *b);
t_bool		stack_sorted(t_stack *stack);

#endif