Skip to main content

Bro Code - The Ultimate Vibe Check Programming Language

Project description

Bro Code 🤙

The Ultimate Vibe Check Programming Language

Bro Code is a high-level, dynamically typed esoteric programming language designed for the ultimate vibe check. It combines the block structure of C++ with the simplicity of Python.

License: MIT Python 3.8+ PyPI

Installation

Via pip

pip install brocode-lang

Manual Installation

# Clone the repository
git clone https://github.com/Prashithshetty/Bro-CODE.git
cd Bro-CODE

# Install in development mode
pip install -e .

# Or just run directly without installing
python -m brocode examples/hello.homie

Quick Start

# Run a .homie file
brocode examples/hello.homie

# Or use the Python module directly
python -m brocode examples/hello.homie

# Or use the wrapper script
chmod +x bro
./bro examples/hello.homie

Hello World

Create hello.homie:

sup {
    spit("Hello World!");
    peace;
}

Run it:

python -m brocode hello.homie

Language Features

Variables & Data Types

var name = "Bro";           // String
var age = 21;               // Integer
var price = 4.20;           // Float
var isAwesome = no_cap;     // Boolean (true)
var isBoring = cap;         // Boolean (false)
var nothing = ghost;        // Null
const PI = 3.14;            // Constant

Input/Output

spit("Hello!");                         // Print to console
var name = listen("Enter your name: "); // Read input

Conditionals

fr (energy > 80) {
    spit("Hyper mode");
} 
meh (energy > 20) {
    spit("Chilling");
} 
nah {
    spit("Need coffee");
}

// Equality check with is_vibe
fr (score is_vibe 100) {
    spit("Perfect!");
}

Loops

// While loop
var i = 0;
hold_up (i < 5) {
    spit(i);
    i = i + 1;
}

// For loop
cycle (var i in range(0, 10)) {
    spit(i);
}

Functions

gig add(a, b) {
    pay a + b;
}

sup {
    var result = add(5, 3);
    spit(result);  // Outputs: 8
    peace;
}

Arrays (Squads)

var squad = [1, 2, 3];
spit(squad[0]);        // Access: 1
squad.push(4);         // Add: [1, 2, 3, 4]
var last = squad.pop(); // Remove & return: 4
spit(len(squad));      // Length: 3

Error Handling

shoot {
    var result = 10 / 0;
} 
fumble (error) {
    spit("Error: " + error);
}

Quick Reference

Feature Bro Code Python
Main block sup { } if __name__ == "__main__":
Exit peace; exit()
Print spit(x) print(x)
Input listen(prompt) input(prompt)
Variable var x = 1; x = 1
Constant const X = 1; X = 1 (by convention)
True/False no_cap / cap True / False
Null ghost None
If fr (cond) { } if cond:
Else if meh (cond) { } elif cond:
Else nah { } else:
While hold_up (cond) { } while cond:
For cycle (var i in range(0, n)) { } for i in range(n):
Break dip; break
Continue skip; continue
Function gig name(x = 10) { } def name(x=10):
Return pay x; return x
Equality is_vibe or == ==
Try shoot { } try:
Catch fumble (e) { } except Exception as e:

Operators

  • Arithmetic: +, -, *, /, %, ** (power), // (integer division)
  • Comparison: >, <, >=, <=, !=, ==, is_vibe
  • Logical: && (AND), || (OR), ! (NOT)
  • Assignment: =, +=, -=, *=, /=, %=
  • Increment/Decrement: ++, --

Built-in Functions

Category Functions
I/O spit(value), listen(prompt)
Type int(v), float(v), str(v), type(v)
Math abs(x), min(a,b), max(a,b), pow(x,y), sqrt(x), floor(x), ceil(x), round(x)
String upper(s), lower(s), trim(s), split(s,d), join(arr,d), replace(s,old,new), contains(s,sub), starts_with(s,p), ends_with(s,p), char_at(s,i), substring(s,start,end)
Array len(arr), range(start,end,step), sort(arr), reverse(arr), slice(arr,s,e), index_of(arr,v), includes(arr,v), concat(a,b)
Utility random(), random_int(min,max), time()

CLI Options

python -m brocode <file.homie>     # Run a file
python -m brocode --version        # Show version
python -m brocode --tokens file    # Debug: show tokens
python -m brocode --ast file       # Debug: show AST

Examples

Check out the examples/ directory for sample programs:

  • hello.homie - Hello World
  • variables.homie - Data types and operations
  • conditionals.homie - fr/meh/nah
  • loops.homie - hold_up and cycle
  • functions.homie - gig/pay with recursion
  • squads.homie - Array operations
  • fibonacci.homie - Fibonacci sequence
  • fizzbuzz.homie - Classic FizzBuzz
  • error_handling.homie - shoot/fumble
  • input.homie - Interactive input

Project Structure

Bro-CODE/
├── brocode/
│   ├── __init__.py      # Package info
│   ├── __main__.py      # CLI entry point
│   ├── tokens.py        # Token definitions
│   ├── lexer.py         # Tokenizer
│   ├── parser.py        # AST builder
│   ├── ast_nodes.py     # AST node classes
│   ├── interpreter.py   # Executor
│   ├── builtins.py      # Built-in functions
│   └── errors.py        # Exception classes
├── examples/            # Sample programs
├── docs/                # Documentation
├── bro                  # CLI wrapper script
└── README.md

Requirements

  • Python 3.8+

No external dependencies required!

License

MIT License - See LICENSE file.


Created for CSI Code Wars

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brocode_lang-1.2.3.tar.gz (73.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brocode_lang-1.2.3-py3-none-any.whl (23.4 kB view details)

Uploaded Python 3

File details

Details for the file brocode_lang-1.2.3.tar.gz.

File metadata

  • Download URL: brocode_lang-1.2.3.tar.gz
  • Upload date:
  • Size: 73.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for brocode_lang-1.2.3.tar.gz
Algorithm Hash digest
SHA256 6da1a8f1bbd883fdad9ecc346cb8b5e67d08a5e88cd5bef6bbc00d9861f1e77a
MD5 d2010734c39ffa7a9a08524f3ad367af
BLAKE2b-256 42c3e69a3f3146d40f7a221d7a0f94586cd913e8f87c6335c8998e0bd8374d24

See more details on using hashes here.

File details

Details for the file brocode_lang-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: brocode_lang-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for brocode_lang-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4e66bb6aec78faac5a11c874beef2b430084af4ac9594ac35dfc92a4b0fe755d
MD5 4c0916e42cdcc94c1446caff9c76e15b
BLAKE2b-256 372d0307cc55b547536b2115da044ddfd33f79f286982a1f81e39691c20e7da2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page