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

Main logic for the brainfuck-like language interpreter/compiler. More...

#include "bfx.h"
#include "interpret.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

Functions

void bfx_free (BFX *bfx)
 Frees the memory allocated for the BFX instance.
 
BFX_Error bfx_run_file (const char *path, BFX *bfx)
 Runs the program loaded from a file.
 
BFX_Error bfx_run_repl (BFX *bfx)
 Runs the BFX interpreter in REPL (Read-Eval-Print Loop) mode.
 

Detailed Description

Main logic for the brainfuck-like language interpreter/compiler.

Public definitions for main logic for the brainfuck-like language interpreter/compiler.

Function Documentation

◆ bfx_free()

void bfx_free ( BFX bfx)

Frees the memory allocated for the BFX instance.

This function frees the memory allocated for the BFX instance, including the program buffer, tape buffer, and loop buffer. It does not free the BFX instance itself.

Parameters
bfxPointer to the BFX instance.

◆ bfx_run_file()

BFX_Error bfx_run_file ( const char *  path,
BFX bfx 
)

Runs the program loaded from a file.

This function builds the loop structure for the BFX instance, then iterates through the program instructions, interpreting each one until the end of the program is reached.

Returns
BFX_Error The error code indicating the result of the operation.

◆ bfx_run_repl()

BFX_Error bfx_run_repl ( BFX bfx)

Runs the BFX interpreter in REPL (Read-Eval-Print Loop) mode.

This function continuously reads input from the user, appends it to the program, and interprets the instructions until the user terminates the program.