turing/tape.h

25 lines
682 B
C

#ifndef _TAPE_H
#define _TAPE_H
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
#include "table.h"
#define TAPE_CHUNK_SIZE 100
struct tape
{
int head; // Head position
int blank; // Blank symbol
int *nsyms, *psyms; // Halves of the infinite tape for negative and positive indices
int ncapacity, pcapacity; // Capacities of the two tape halves
};
struct tape *tape_new(int blank);
int tape_read(struct tape *t, int pos);
void tape_write(struct tape *t, int pos, int sym);
int tape_load(struct tape *t, FILE *f, int offset, struct table *symbols);
void tape_print(struct tape *t, struct table *sym);
#endif