Skip to content

Latest commit

Β 

History

418 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Brainrot Programming Language

license CI

Brainrot is a meme-inspired programming language that translates common programming keywords into internet slang and meme references. It's built using Flex (lexical analyzer) and Bison (parser generator), making it a fun way to learn about language processing and compiler design.

History

The TRUE history behind the Brainrot programming language can be found here.

πŸ€” What is Brainrot?

Brainrot is a C-like programming language where traditional keywords are replaced with popular internet slang. For example:

  • void β†’ skibidi
  • int β†’ rizz
  • for β†’ flex
  • return β†’ bussin

πŸ“‹ Requirements

To build and run the Brainrot compiler, you'll need:

  • GCC (GNU Compiler Collection)
  • Flex (Fast Lexical Analyzer)
  • Bison (Parser Generator)

Installation on Different Platforms

Ubuntu/Debian

sudo apt-get update
sudo apt-get install gcc flex bison libfl-dev

Arch Linux

sudo pacman -S gcc flex bison

macOS (using Homebrew)

brew install gcc flex bison

Some macOS users are experiencing an error related to libfl. First, check if libfl is installed at:

/opt/homebrew/lib/libfl.dylib  # For Apple Silicon
/usr/local/lib/libfl.dylib  # For Intel Macs

And if not, you have to find it and symlink to it. Find it using:

find /opt/homebrew -name "libfl.*"  # For Apple Silicon
find /usr/local -name "libfl.*"  # For Intel Macs

And link it with:

sudo ln -s /path/to/libfl.dylib /opt/homebrew/lib/libfl.dylib  # For Apple Silicon
sudo ln -s /path/to/libfl.dylib /usr/local/lib/libfl.dylib  # For Intel Macs

For NixOS

git clone https://github.com/Brainrotlang/brainrot.git
cd brainrot
nix develop
# then create your .brainrot file
./result/bin/brainrot filename.brainrot

Or via a flake-based NixOS config (/etc/nixos/flake.nix), which always tracks the latest version:

# /etc/nixos/flake.nix
{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    brainrot.url = "github:Brainrotlang/brainrot";
  };

  outputs = { nixpkgs, brainrot, ... }: {
    nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
      modules = [
        ./configuration.nix
        {
          # For a specific user
          users.users.username = {
            packages = [ brainrot.packages.x86_64-linux.default ];
          };
          # For system-wide installation
          environment.systemPackages = [
            brainrot.packages.x86_64-linux.default
          ];
        }
      ];
    };
  };
}

Run nix flake update whenever you want to pull the latest version, then rebuild with sudo nixos-rebuild switch.

πŸš€ Building the Compiler

  1. Clone this repository:
git clone https://github.com/Brainrotlang/brainrot.git
cd brainrot
  1. Generate the parser and lexer:
bison -d -Wcounterexamples lang.y -o lang.tab.c
flex -o lang.lex.c lang.l
  1. Compile the compiler:
make

NOTE: The gcc version we use to test is v13 if you get any warnings remove -Werror flag from the Makefile

Installation

sudo make install

Uninstall

sudo make uninstall

🌐 WebAssembly build

make wasm builds brainrot.wasm + brainrot.mjs using Emscripten β€” this is what powers the in-browser playground. Requires emcc on your PATH (install via emsdk):

make wasm

The interpreter is statically linked for this target (no libstdrot.so, no dlopen β€” see stdrot.c's STDROT_STATIC path), and takes its source file the same way the native binary does, via argv[1] written into Emscripten's in-memory filesystem before calling callMain.

Known platform-specific difference from the native build: sizeof(giga) is 4, not 8 β€” wasm32 uses the ILP32 data model (long = 4 bytes) instead of native's LP64 (#177). Everything else, including stderr, matches native exactly.

node tests/run_wasm_tests.mjs runs the same fixtures as the native pytest suite against the wasm build (checking the one difference above against its wasm-correct value instead of native's), and node tests/run_wasm_examples_check.mjs diffs every examples/*.brainrot program's stdout against a real native run. Run both after make && make wasm to sanity-check a build.

chill() calls sleep() under the hood, which blocks the JS thread it runs on rather than yielding β€” fine in a short-lived CLI run, but something a browser embedder (e.g. a playground) should account for (run in a Worker, expect the tab to be unresponsive for the duration) rather than assume it behaves like an async delay.

πŸ’» Usage

  1. Create a Brainrot source file (e.g., hello.brainrot):
 skibidi main {
    yapping("Hello, World!");
    bussin 0;
}
  1. Run your Brainrot program:
./brainrot hello.brainrot

Check out the examples:

πŸ—ͺ Community

Join our community on:

πŸ“š Language Reference

Keywords

Brainrot C Equivalent Implemented?
skibidi void βœ…
rizz int βœ…
cap bool βœ…
flex for βœ…
bussin return βœ…
edgy if βœ…
amogus else βœ…
goon while βœ…
bruh break βœ…
grind continue βœ…
chad float βœ…
gigachad double βœ…
yap char βœ…
deadass const βœ…
sigma rule case βœ…
based default βœ…
mewing do βœ…
gyatt enum βœ…
whopper extern ❌
cringe goto ❌
giga long βœ…
smol short βœ…
nut signed βœ…
maxxing sizeof βœ…
salty static βœ…
gang struct βœ…
ohio switch βœ…
chungus union βœ…
nonut unsigned βœ…
schizo volatile βœ…
W true βœ…
L false βœ…
thicc long long βœ…
rant string type βœ…
lit typedef ❌

Preprocessor directives

Brainrot C Equivalent Implemented?
#cooked #include βœ…
#edgydef #ifdef ❌
#edgyndef #ifndef ❌
#endedgy #endif ❌
#slaps #define ❌
#aura #pragma ❌

#cooked "path/to/file.brainrot" splices another Brainrot file's functions and structs into the current one, resolved relative to the including file's directory. See the language reference for details (path resolution, include-once behavior, circular-include detection).

Builtin functions

Check the user documentation.

Operators

The language supports basic arithmetic operators:

  • + Addition
  • - Subtraction
  • * Multiplication
  • / Division
  • = Assignment
  • < Less than
  • > Greater than
  • && Logical AND
  • || Logical OR

⚠️ Limitations

Current limitations include:

  • Limited support for complex expressions
  • Basic error reporting
  • Struct/union function parameters and return values must be a plain struct/union variable of the exact declared type (no sub-expressions, e.g. a chained call or a member access) β€” arguments and return values are deep-copied, not aliased
  • Arrays cannot be passed or returned by value (only via a pointer parameter, which aliases the caller's array like in C)
  • ohio/based (switch/default): based fires as soon as the interpreter's scan reaches it, so its position among the sigma rule cases matters β€” placing it before a case that would otherwise match currently pre-empts that match (#179)

πŸ—ΊοΈ Roadmap

Where Brainrot is headed β€” a native C ABI, generated library bindings (raylib first), threads, hashmaps and sockets β€” is documented in the roadmap.

πŸ”Œ VSCode Extension

Brainrot has a Visual Studio Code extension to enhance your development experience with syntax highlighting and support for the Brainrot programming language. You can find it here:

Brainrot VSCode Extension

🀝 Contributing

Feel free to contribute to this project by:

  1. Forking the repository
  2. Creating a new branch for your feature
  3. Submitting a pull request

πŸ“ License

This project is licensed under the GPL License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • This project is created for educational purposes
  • Inspired by meme culture and internet slang
  • Built using Flex and Bison tools

πŸ› Issues

Please report any additional issues in the GitHub Issues section.

Releases

Used by

Contributors

Languages