Skip to content

k1114linux/meow-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

meow-compiler - Brainfuck Compiler in C (x86_64 Linux ELF Output)

meow-compiler is a minimalistic Brainfuck-inspired compiler written in C. It translates a cat-themed Brainfuck dialect into a standalone x86_64 ELF binary for Linux.

Instead of standard Brainfuck symbols, meow-compiler uses feline keywords:

Brainfuck meow-compiler Keyword What it does
> meow Move the pointer to the right (next memory cell)
< purr Move the pointer to the left (previous memory cell)
+ hiss Increment the value at the current memory cell by 1
- growl Decrement the value at the current memory cell by 1
. chirp Output the value at the current memory cell (usually as a character)
, mew Input a value and store it at the current memory cell
[ scratch Start a loop: if the current cell is 0, jump past the matching ] (nap)
] nap End a loop: jump back to the matching [ (scratch) if the current cell is not 0

Features

  • Compiles meow-compiler source code directly to an ELF executable.
  • Generates standalone Linux x86_64 binaries (no interpreter needed).
  • Supports loops and standard Brainfuck I/O.
  • Implements memory tape using mmap (default 30_000 bytes).
  • Lightweight and minimal dependencies (only standard C library).

Requirements

  • Linux x86_64
  • GCC or any C99-compatible compiler

Build

make

Usage

./kk <source.kcc> <output_binary>
  • <source.kcc>: Your meow-c source file
  • <output_binary>: Name of the generated ELF executable

Example:

./kk hello.kcc hello
./hello

How It Works

  1. Lexer: Converts meow-compiler keywords into internal instruction representation.
  2. Code Generator: Translates instructions to x86_64 machine code.
  3. ELF Writer: Produces a fully linked ELF64 binary executable.
  4. Memory Management: Uses mmap to allocate a 30_000byte tape for Brainfuck operations.

License

Apache-2.0 license.

About

Minimalistic Brainfuck-inspired compiler written in C. It translates a cat-themed Brainfuck dialect into a standalone x86_64 ELF binary for Linux.

Topics

Resources

License

Stars

Watchers

Forks

Contributors