bfx
An interpreter, compiler, and REPL for brainfuck-like languages
Loading...
Searching...
No Matches
compile.c File Reference
#include "compile.h"
#include "bfx.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>

Macros

#define BFX_SET_PROPERTY_BOOL(property, value)
 
#define BFX_SET_PROPERTY_INT(property, value)   fprintf(output, "bfx.%s = %d;", property, value)
 
#define BFX_SET_PROPERTY_SIZE_T(property, value)   fprintf(output, "bfx.%s = %ld;", property, value)
 
#define BFX_SET_PROPERTY_UINT16_T(property, value)   fprintf(output, "bfx.%s = %d;", property, value)
 
#define BFX_SET_PROPERTY_CONST_CHAR(property, value)    fprintf(output, "bfx.%s = \"%s\";", property, value)
 

Functions

void bfx_compile (const char *input_path, const char *output_path, BFX *bfx)
 Compile Brainfuck code from input_path to output_path.
 

Detailed Description

This file contains the implementation of the Brainfuck-like language compiler.

Macro Definition Documentation

◆ BFX_SET_PROPERTY_BOOL

#define BFX_SET_PROPERTY_BOOL (   property,
  value 
)
Value:
if (value) { \
fprintf(output, "bfx.%s = true;", property); \
} else { \
fprintf(output, "bfx.%s = false;", property); \
}

◆ BFX_SET_PROPERTY_CONST_CHAR

#define BFX_SET_PROPERTY_CONST_CHAR (   property,
  value 
)     fprintf(output, "bfx.%s = \"%s\";", property, value)

◆ BFX_SET_PROPERTY_INT

#define BFX_SET_PROPERTY_INT (   property,
  value 
)    fprintf(output, "bfx.%s = %d;", property, value)

◆ BFX_SET_PROPERTY_SIZE_T

#define BFX_SET_PROPERTY_SIZE_T (   property,
  value 
)    fprintf(output, "bfx.%s = %ld;", property, value)

◆ BFX_SET_PROPERTY_UINT16_T

#define BFX_SET_PROPERTY_UINT16_T (   property,
  value 
)    fprintf(output, "bfx.%s = %d;", property, value)

Function Documentation

◆ bfx_compile()

void bfx_compile ( const char *  input_path,
const char *  output_path,
BFX bfx 
)

Compile Brainfuck code from input_path to output_path.

This function takes a Brainfuck source code file specified by input_path, compiles it into a C program, compiles the C program, and writes the resulting code to the file specified by output_path. If input_path is NULL, the function will read from stdin. If output_path is NULL, the function will write to ./a.out.

Parameters
input_pathPath to the input Brainfuck source code file.
output_pathPath to the output binary or C file.
bfxBFX configuration to use for compilation.