# 🧠 BrainrotScript

A brainrot programming language that compiles to JavaScript. Because why write normal code when you can write code that's absolutely sending you? 💀

## What is BrainrotScript?

BrainrotScript (.brainrot) is a programming language that uses Gen Z/brainrot slang as keywords instead of traditional programming keywords. It compiles directly to JavaScript, so you get all the power of JS but with the rizz of brainrot terminology.

## Installation

```bash
# Install globally from npm (coming soon!)
npm install -g brainrotscript

# Or install locally for development
npm install
```

## Quick Start

1. **Write your brainrot code** in a `.brainrot` file:
```brainrot
job_application greet(name) {
    vibe_check (name) {
        console.log("Hello, " + name + "! No cap! 🧢");
    } big_yikes {
        console.log("Hello, anonymous user!");
    }
}

greet("World");
```

2. **Run it directly**:
```bash
# Method 1: Direct execution (if installed globally)
brainrot index.brainrot

# Method 2: Using the run command
brainrot run index.brainrot

# Method 3: Local development
node bin/brs-cli.js index.brainrot
```

3. **Or compile to JavaScript**:
```bash
brainrot compile index.brainrot -o output.js
```

## Keyword Mappings 🗺️

| JavaScript | BrainrotScript | Example |
|------------|----------------|---------|
| `function` | `job_application` | `job_application greet() {}` |
| `return` | `its_giving` | `its_giving result;` |
| `const` | `lock_in` | `lock_in name = "Chad";` |
| `let` | `whatever` | `whatever count = 0;` |
| `if` | `vibe_check` | `vibe_check (condition) {}` |
| `else` | `big_yikes` | `big_yikes { console.log("nah"); }` |
| `for` | `flex` | `flex (whatever i = 0; i < 10; i++) {}` |
| `while` | `goon` | `goon (condition) {}` |
| `class` | `squad` | `squad MyClass {}` |
| `this` | `me_fr` | `me_fr.property = value;` |
| `true` | `wallahi` | `lock_in isTrue = wallahi;` |
| `false` | `no_cap` | `lock_in isFalse = no_cap;` |
| `null` | `ghost` | `lock_in empty = ghost;` |
| `try` | `fuck_around` | `fuck_around { /* code */ }` |
| `catch` | `caught_4k` | `caught_4k (error) {}` |
| `async` | `brb` | `brb job_application getData() {}` |
| `await` | `hold_up` | `hold_up response;` |
| `new` | `spawn` | `lock_in obj = spawn MyClass();` |
| `extends` | `inherits_drip` | `squad Child inherits_drip Parent` |

[View complete mapping in brainrot-map.json](./brainrot-map.json)

## CLI Commands

```bash
# Run a .brainrot file directly
brainrot <file.brainrot>

# Run with explicit run command
brainrot run <file.brainrot>

# Compile to JavaScript  
brainrot compile <file.brainrot> [-o output.js]

# Show all available keywords
brainrot keywords

# Show help
brainrot --help
```

## Examples

### Basic Example (`examples/hello.brainrot`)
```brainrot
job_application main() {
    lock_in message = "Hello from BrainrotScript!";
    console.log(message);
    
    vibe_check (wallahi) {
        console.log("This condition is true - no cap! 🧢");
    }
    
    flex (whatever i = 0; i < 3; i++) {
        console.log(`Loop ${i + 1}: Still got the rizz! 🔥`);
    }
}

main();
```

### Advanced Example (`examples/advanced.brainrot`)
```brainrot
squad VibeManager {
    job_application constructor(vibes) {
        me_fr.vibes = vibes || 0;
    }
    
    brb job_application addVibes(amount) {
        hold_up new Promise(resolve => {
            me_fr.vibes += amount;
            resolve(me_fr.vibes);
        });
    }
}

brb job_application main() {
    fuck_around {
        lock_in manager = spawn VibeManager(100);
        hold_up manager.addVibes(200);
        console.log("Total vibes:", manager.vibes);
    } caught_4k (error) {
        console.error("Something went wrong:", error);
    }
}

main();
```

## How It Works

1. **Lexical Translation**: The compiler reads your `.brs` file and replaces all brainrot keywords with their JavaScript equivalents using regex with word boundaries
2. **Compilation**: The translated code is saved as a `.js` file
3. **Execution**: Node.js runs the compiled JavaScript
4. **Cleanup**: Temporary files are automatically removed

## Development

```bash
# Test with the hello world example
npm test

# Run a specific example
brainrot examples/advanced.brainrot

# Check available keywords
brainrot keywords
```

## File Structure

```
brainrotscript/
├── src/
│   └── compiler.js          # Core compiler logic
├── bin/
│   └── brs-cli.js          # CLI interface
├── examples/
│   ├── hello.brainrot      # Basic example
│   └── advanced.brainrot   # Advanced features
├── brainrot-map.json       # Keyword mappings
├── package.json
└── README.md
```

## Contributing

Want to add more brainrot keywords? Edit `brainrot-map.json` and the compiler will automatically use them!

## License

MIT - Use this however you want, just don't blame us if your code reviews get spicy 🌶️

---

**Built with 💀 and excessive amounts of brainrot**

*"It's giving main character energy but make it programming" - BrainrotScript Users, probably* 