BFC-Compiler
A C23 Brainfuck compiler
Loading...
Searching...
No Matches
bfc_token.h File Reference

Brainfuck token definitions and token-stream ownership. More...

#include <stddef.h>
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  bfc_token_t
 One Brainfuck token and its one-based source location. More...
struct  bfc_token_stream_t
 Owning token sequence produced by the lexer. More...

Macros

#define TOKEN_MAP
 Single source of truth for Brainfuck characters and token kinds.
#define X(tok_type, ...)

Enumerations

enum  bfc_token_type_t { TOKEN_MAP }
 Token kinds emitted by the lexer.

Functions

bfc_token_t bfc_make_token (bfc_token_type_t const tok_type, uint32_t const line, uint32_t const col)
 Constructs a token value without allocating memory.
void bfc_token_stream_destroy (bfc_token_stream_t **ptok_stream)
 Releases a token stream and nulls the caller pointer.

Detailed Description

Brainfuck token definitions and token-stream ownership.

Defines token kinds, source locations, stream storage, construction, and destruction.

Macro Definition Documentation

◆ TOKEN_MAP

#define TOKEN_MAP
Value:
X(TT_INC, '+') \
X(TT_DEC, '-') \
X(TT_PTR_RIGHT, '>') \
X(TT_PTR_LEFT, '<') \
X(TT_LOOP_START, '[') \
X(TT_LOOP_END, ']') \
X(TT_OUTPUT, '.') \
X(TT_INPUT, ',')

Single source of truth for Brainfuck characters and token kinds.

◆ X

#define X ( tok_type,
... )
Value:
tok_type,

Function Documentation

◆ bfc_make_token()

bfc_token_t bfc_make_token ( bfc_token_type_t const tok_type,
uint32_t const line,
uint32_t const col )
nodiscard

Constructs a token value without allocating memory.

Constructs a token value from its kind and source coordinates.

Constructs a token value without allocating memory.

◆ bfc_token_stream_destroy()

void bfc_token_stream_destroy ( bfc_token_stream_t ** ptok_stream)

Releases a token stream and nulls the caller pointer.

Releases the owned token array and stream object, then nulls the caller pointer.

Releases a token stream and nulls the caller pointer.