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
|
#pragma once
#include <stdbool.h>
#include <stdint.h>
typedef enum {
MoveLeft,
MoveRight,
Increment,
Decrement,
StartLoop,
EndLoop,
PutChar,
GetChar,
Allocate,
Free,
EnterTape,
LeaveTape,
PutString,
GetString,
Clear,
Eof,
Invalid
} Symbol;
typedef struct {
uint32_t len;
uint32_t index;
Symbol* data;
} Program;
void program_init(char* file_path, Program* program);
void program_peek(Program* program, Symbol* symbol);
void program_next(Program* program, Symbol* symbol);
void program_last(Program* program, Symbol* symbol);
void program_free(Program* program);
typedef struct {
uint32_t len;
uint32_t index;
uint8_t* data;
} Tape;
void tape_init(uint32_t len, Tape* tape);
void tape_left(Tape* tape);
void tape_right(Tape* tape);
uint8_t tape_get(Tape* tape);
void tape_set(Tape* tape, uint8_t value);
uint8_t* tape_ptr(Tape* tape);
void tape_free(Tape* tape);
|