BFC-Compiler
A C23 Brainfuck compiler
Loading...
Searching...
No Matches
bfc_jumptable.c File Reference

Bracket-matching validation pass. More...

#include "bfc_jumptable.h"
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "bfc_memory.h"

Functions

bfc_error_t bfc_parse_jump_table (int64_t **jump_table, bfc_token_stream_t const *const tok_stream)
 Validates nested brackets and fills a bidirectional matching-index table.
void bfc_jump_table_destroy (int64_t **pjump_table)
 Releases the matching-index table and nulls the caller pointer.

Detailed Description

Bracket-matching validation pass.

Uses a stack of opening-bracket indices to build a bidirectional jump table and produce source-aware bracket errors.

Function Documentation

◆ bfc_jump_table_destroy()

void bfc_jump_table_destroy ( int64_t ** pjump_table)

Releases the matching-index table and nulls the caller pointer.

Releases a jump table and nulls the caller pointer.

Releases the matching-index table and nulls the caller pointer.

◆ bfc_parse_jump_table()

bfc_error_t bfc_parse_jump_table ( int64_t ** jump_table,
bfc_token_stream_t const *const tok_stream )

Validates nested brackets and fills a bidirectional matching-index table.

Validates loop delimiters and builds matching bracket indices.

Validates nested brackets and fills a bidirectional matching-index table.

Parameters
[out]jump_tableReceives an allocated table indexed by token position.
[in]tok_streamToken stream to validate.
Returns
BFC_ERR_OK on success; otherwise an allocation or bracket error.
Note
Non-bracket entries contain -1.