BroLang is a high-level programming language that infuses bro slang and street language into coding, making it both fun and relatable. Below is the complete ruleset for BroLang.
- Case Sensitivity: BroLang is case-insensitive, but it's stylish to write keywords in lowercase.
- Statements: Each statement ends with a semicolon
;. - Comments:
- Single-line comments start with
//.// This is a single-line comment - Multi-line comments are enclosed within
/*and*/./* This is a multi-line comment */
- Single-line comments start with
- Chill: Represents integer numbers.
yo age = 25; // Chill - Fluid: Represents floating-point numbers.
yo piApprox = 3.14; // fluid - Vibes: Represents strings of text.
yo greeting = "What's up, bro?"; // Vibes - Flex: Represents boolean values.
dopefortrue.nopeforfalse.
yo isChill = dope; // Flex - Squad: Represents arrays or lists.
yo squad numbers = [1, 2, 3, 4, 5];
- Variable Declaration: Use the keyword
yoto declare a variable.yo gains = 100; // Chill yo mood = "lit"; // Vibes yo isSwole = nope; // Flex yo score = 99.5; // Fluid - Constant Declaration: Use
nocapbeforeyoto declare a constant that cannot be changed.Attempting to modify a constant will result in an error.nocap yo pi = 3.14159; // Fluid constant nocap yo maxLevel = 99; // Chill constant
- Addition:
+ - Subtraction:
- - Multiplication:
* - Division:
/ - Modulo:
%
yo total = gains + 50;
- Equal to:
== - Not equal to:
!= - Greater than:
> - Less than:
< - Greater than or equal to:
>= - Less than or equal to:
<=
if (score >= 90) {
// code block
}
- And:
&&orand - Or:
||oror - Not:
!ornot
if (isSwole and hasGains) {
// code block
}
if (condition) {
// code block
}
else if (anotherCondition) {
// code block
}
else {
// code block
}
Use swag and vibeCheck for switch-case structures.
swag (variable) {
vibeCheck value1:
// code block
break;
vibeCheck value2:
// code block
break;
default:
// code block
}
while (condition) {
// code block
}
for (yo i = 0; i < limit; i++) {
// code block
}
Use forEvery keyword.
forEvery (item in squad) {
// code block
}
- Break: Use
break;to exit a loop early. - Continue: Use
continue;to skip to the next iteration.
Use the keyword brofunc to declare a function.
brofunc functionName(parameters) {
// code block
}
Example:
brofunc addGains(yo a, yo b) {
bounce a + b;
}
yo result = addGains(10, 20);
Use bounce to return a value from a function.
Use spill to print output.
spill "Yo, what's up?";
spill "Total gains: " + total;
Use holla to get input from the user.
yo name = holla "What's your name?";
Use the data type squad.
yo squad gains = [10, 20, 30];
yo squad names = ["Bro", "Dude", "Mate"];
yo firstGain = gains[0];
gains[2] = 35;
- Add Element:
squad.push(value); - Remove Last Element:
squad.pop(); - Length of Array:
squad.length;
gains.push(40);
yo totalGains = gains.length;
Use bigBro to declare a class.
bigBro ClassName {
// properties and methods
}
Example:
bigBro GymBro {
yo gains;
brofunc init(yo initialGains) {
me.gains = initialGains;
}
brofunc flex() {
spill "Flexing with " + me.gains + " gains!";
}
}
yo bro1 = new GymBro(100);
bro1.flex();
Use me to refer to the current object.
Use noWorries and allGood for try-catch structures.
noWorries {
// code that might throw an error
} allGood (yo error) {
spill "Chill, an error occurred: " + error;
}
Use bringIn to import external modules.
bringIn "mathBro";
- Return Statement:
bounce - Null Value:
ghostyo nothingHere = ghost; - New Keyword:
newto create a new object instance. - This Keyword:
meto refer to the current object.
yo numberAsString = (vibes) 123; // Cast integer to string
yo stringAsNumber = (chill) "456"; // Cast string to integer
Use inherits to extend a class.
bigBro SuperGymBro inherits GymBro {
brofunc superFlex() {
spill "Super flex with " + me.gains * 2 + " gains!";
}
}
Use brofunc without a name.
yo add = brofunc (yo x, yo y) {
bounce x + y;
};
yo result = add(5, 10);
Use options to declare an enumeration.
options GymStatus {
newbie,
intermediate,
pro
}
yo status = GymStatus.pro;
Use readBro and writeBro.
yo data = readBro "data.txt";
writeBro "output.txt", data;
Use squadGoals to create concurrent threads.
squadGoals {
// code to run concurrently
}
Use /// for documentation comments that can be used by a documentation generator.
///
/// This function adds two numbers.
///
brofunc add(yo a, yo b) {
bounce a + b;
}
The entry point of a BroLang program is the main function.
brofunc main() {
// code to execute
}
brofunc main() {
spill "Welcome to BroLang!";
yo squad gainsList = [10, 20, 30];
forEvery (gain in gainsList) {
spill "Gain: " + gain;
}
yo totalGains = 0;
for (yo i = 0; i < gainsList.length; i++) {
totalGains = totalGains + gainsList[i];
}
spill "Total Gains: " + totalGains;
brofunc getMotivation(yo level) {
if (level > 50) {
bounce "You're on fire, bro!";
} else {
bounce "Keep pushing, bro!";
}
}
yo message = getMotivation(totalGains);
spill message;
}
Note: This ruleset is designed to make coding in BroLang a fun and engaging experience, blending programming concepts with bro slang. Feel free to expand and customize it to fit your specific needs.