-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfuckbees.c
61 lines (47 loc) · 1.06 KB
/
fuckbees.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <assert.h>
#include "brainfuck.h"
#include "bfir.h"
#include "front.h"
#include "in.h"
Error fuckbees_parse(In_Channel *in, Bfir_Entry *entry, Front_Aux *aux) {
assert(aux == NULL || aux->sign.quad == brainfuck_front.sign.quad);
uint8_t c;
while (in_read(in, &c, 1) == 1) {
Bfir_Instr instr;
switch (c) {
case 'c':
bfir_instr_init(&instr, BFIR_ADD, 1);
break;
case 'k':
bfir_instr_init(&instr, BFIR_ADD, -1);
break;
case 'f':
bfir_instr_init(&instr, BFIR_ADDP, 1);
break;
case 'u':
bfir_instr_init(&instr, BFIR_ADDP, -1);
break;
case 'e':
bfir_instr_init(&instr, BFIR_READ, 1);
break;
case 'b':
bfir_instr_init(&instr, BFIR_WRITE, 1);
break;
case 'E':
bfir_instr_init(&instr, BFIR_JMPF, 0);
break;
case 's':
bfir_instr_init(&instr, BFIR_JMPB, 0);
break;
default:
continue;
}
bfir_entry_append(entry, &instr);
}
Error error = { NULL };
return error;
}
const Front_Info fuckbees_front = {
.sign.quad = 0xffeeffee000000,
.parse_f = fuckbees_parse,
};