BFC-Compiler
A C23 Brainfuck compiler
Loading...
Searching...
No Matches
bfc_io.h
Go to the documentation of this file.
1
8#ifndef BFC_IO_H
9#define BFC_IO_H
10
11#include <stddef.h>
12
13#include "bfc_error.h"
14
20typedef struct bfc_program_t
21{
22 char* path;
23 char* buffer;
24 size_t file_size;
25 size_t line_count;
27
38[[gnu::nonnull(1, 2)]]
39bfc_error_t bfc_program_create(bfc_program_t** program, char const* file_path);
40
44void bfc_program_destroy(bfc_program_t** pprogram);
45
51[[nodiscard, gnu::pure, gnu::nonnull(1), gnu::returns_nonnull]]
52char const* bfc_program_getname(bfc_program_t const* const program);
53
64[[nodiscard, gnu::malloc, gnu::nonnull(1)]]
65char* bfc_program_getline(bfc_program_t const* const program, size_t const n);
66
67#endif // BFC_IO_H
Compiler error values and diagnostics.
bfc_error_t bfc_program_create(bfc_program_t **program, char const *file_path)
Loads an entire source file into memory.
Definition bfc_io.c:21
char * bfc_program_getline(bfc_program_t const *const program, size_t const n)
Copies one source line into a new allocation.
Definition bfc_io.c:170
void bfc_program_destroy(bfc_program_t **pprogram)
Releases a source program and nulls the caller pointer.
Definition bfc_io.c:135
char const * bfc_program_getname(bfc_program_t const *const program)
Returns the base name of the source path.
Definition bfc_io.c:152
Error value propagated through compiler stages.
Definition bfc_error.h:42
Owning representation of a loaded source file.
Definition bfc_io.h:21