-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfind_opcode.c
More file actions
45 lines (41 loc) · 718 Bytes
/
Copy pathfind_opcode.c
File metadata and controls
45 lines (41 loc) · 718 Bytes
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
#include "monty.h"
/**
* func - pointers to functions
* @tokens: arguments
* Return: function
*/
void (*func(char *tokens))(stack_t **stack, unsigned int num_line)
{
instruction_t ops[] = {
{"push", _push},
{"pall", _pall},
{"pint", _pint},
{"pop", _pop},
{"swap", _swap},
{"add", _add},
{"nop", _nop},
{"sub", _sub},
{"div", _div},
{"mul", _mul},
{"mod", _mod},
{"pchar", _pchar},
{"pstr", _pstr},
{"rotl", _rotl},
{"rotr", _rotr},
{"stack", _stack},
{"queue", _queue},
{"err", _error},
{"#", _nop},
{NULL, NULL}
};
int i = 0;
int opc;
while (i < 19)
{
opc = strcmp(ops[i].opcode, tokens);
if (opc == 0)
return (ops[i].f);
i++;
}
return (ops[17].f);
}