bfx
An interpreter, compiler, and REPL for brainfuck-like languages
Loading...
Searching...
No Matches
util.h File Reference

Language-independent utility function definitions. More...

#include "bfx.h"

Go to the source code of this file.

Macros

#define BFX_MAX_THREADS   128
 Maximum number of threads allowed in multithreaded languages.
 

Functions

BFX_Error bfx_build_loops (BFX *)
 Builds the loop structure for the BFX instance.
 
BFX_Error bfx_parse_ops (BFX *, BFX_Error(*[128])(BFX *, BFX_FileIndex *))
 Executes operations on the BFX instance.
 

Detailed Description

Language-independent utility function definitions.

Macro Definition Documentation

◆ BFX_MAX_THREADS

#define BFX_MAX_THREADS   128

Maximum number of threads allowed in multithreaded languages.

Function Documentation

◆ bfx_build_loops()

BFX_Error bfx_build_loops ( BFX bfx)

Builds the loop structure for the BFX instance.

This function scans the BFX program and constructs the necessary data structures to efficiently handle loop constructs ('[' and ']'). It ensures that matching brackets are correctly paired, allowing for proper execution flow during interpretation.

Parameters
bfxThe BFX instance to build loops for.
Note
This function does not return a value. If an error occurs (such as exceeding MAX_LOOPS), it prints an error message and terminates the program using exit(EXIT_FAILURE).

◆ bfx_parse_ops()

BFX_Error bfx_parse_ops ( BFX bfx,
BFX_Error(*[128])(BFX *, BFX_FileIndex *)  ops 
)

Executes operations on the BFX instance.

Parameters
bfxThe BFX instance to run
opsOperation map
Returns
Error code