BrainfuckSharpCompiler
A brainfuck compiler written in C#. Compiles to an executable .NET assembly
Install / Use
/learn @NickStrupat/BrainfuckSharpCompilerREADME
BrainfuckSharpCompiler
A brainfuck compiler written in C#. It compiles brainfuck programs to an executable .NET/Mono assembly.
There is some boring stuff like setting up the assembly, module, type, Main method, stack, and stack pointer for emitting IL instructions and finally by writing the assembly to the file system as a .NET/Mono executable. By default, the compiler builds a safe implementation. I went with using a Byte[] for the stack, and an Int32 for an index of the stack (effectively acting like a stack pointer). If the unsafe switch (/u) is provided as a command line argument, the compiler will produce an unsafe implementation using a stack-allocated array of Byte for the stack and a Byte * for the stack pointer. This will be faster than a safe implementation in many cases, but is susceptible to undefined behaviour if a brainfuck program overruns the stack.
Here's the fun stuff...
When compiling the brainfuck program, we read the file character by character. The only valid ones, of course, are the eight valid operations...
<>+-,.[]
... for each of these we just need to emit the correct IL instructions which correspond to the correct behaviour at run-time in the CLR environment.
Related Skills
node-connect
351.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
