esolang

FakeC

brainfuck that a C compiler runs as it is.

None1, 2023 · Turing complete: yes · ●○○ easy · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: A

The idea

None1 made FakeC in 2023. Every brainfuck command is replaced by one line of C, and the program is wrapped in a main with a tape of 1,000,000 chars. So a FakeC program is also a C program, and the specification suggests compiling it with GCC and -O2 to get a brainfuck program that runs fast.

Read the story

Because it is C, the end of the input works as in C. getchar gives EOF, which is -1, and a char keeps that as 255. The cat therefore does not stop at the end of its input. It stops at a 0 byte.

The machine

brainfuckFakeC
start#include<stdio.h> char tape[1000000]; int p; int main(){
+ -++tape[p]; --tape[p];
> <++p; --p;
, .tape[p]=getchar(); putchar(tape[p]);
[ ]while(tape[p]){ }
endreturn 0; }

The specification's table leaves the brace off while(tape[p]), but both of its examples have it, and so does this implementation. Spaces and line breaks are passed over, so a command may share a line. Cells wrap as bytes, and a cell outside the tape is an error.

Example

Eight times eight plus one is 65, an A.

Eight times eight plus one is 65, an A.

One character in and out.

Expected: x

The Hello World has 106 command lines, the usual brainfuck one turned line by line, and it prints Hello World! and a line feed.

Patterns it teaches

Further

FakeC builds on Brainfuck.

Esoteric subset

Brainfuck equivalents

Write your own in Run Convert a program from FakeC

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: fakec.

Command line

shib run fakec -e '#include<stdio.h>
char tape[1000000];
int p;
int main(){
tape[p]=getchar();
while(tape[p]){
putchar(tape[p]);
tape[p]=getchar();
}
return 0;
}' --input 'FakeC'
shib manual fakec

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/fakec.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org