Package Exports
- brocode-cli
- brocode-cli/dist/cli.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (brocode-cli) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
BROCODE
A toy programming language for Bros that allows you to write code using Hindi-style syntax. It makes programming more accessible and fun for Hindi speakers! 🎉
Documentation
For detailed documentation, check out the official BROCODE documentation:
Official Website
Visit the official website for BROCODE:
Installation
npm install -g brocode-cli@latest
Usage
1. Create a file with a .bc
extension:
// hello.bc
// A basic program to find the factorial of a number
bro function FACTORIAL(n) {
bro maanle fact hai 1;
bro maanle i hai 1;
bro jbb tk (i <= n) hai {
bro maanle fact hai fact * i;
i++;
}
bro dikha de("Factorial of " + n + " is: " + fact);
}
FACTORIAL(5);
2. Run your code:
brocode your-file.bc
OR
npx brocode your-file.bc
Command Line Options
- Basic usage:
brocode filename.bc
- Debug mode:
brocode filename.bc --debug
Features
- Hindi-style syntax for better understanding
- Clear error messages
- Debug mode for development
- Easy to use CLI interface
BROCODE syntax
1. Declaring a Variable:
// Declaring variable 'num' and assigning value 5
bro maanle num hai 5;
2. Print something:
bro dikha de("Hello World!");
3. Function Declaration:
bro function <functionName>(pram_a, param_b) {
bro dikha de(pram_a + param_b);
}
<functionName>(5, 3);
4. Conditional Statements:
//Declaring num with 2
bro maanle num hai 2;
// if statement
bro agar (num < 3){
bro dikha de("Number is less than 3");
}
//else statement
bro leave it{
bro dikha de("Number is greater than 3");
}
5. While Loop:
// Declaring initial value from where loop starts
bro maanle num hai 2;
// defining while loop with condition num < 3
bro jbb tk (num < 3) hai {
bro dikha de(num);
// break statement
bro nikal;
// incrementing num
num++;
}
How to Setup DOM with BROCODE
To set up DOM functionality in your project, follow these steps:
- Add this in the
<head>
tag:
<script src="https://brocode-cli.vercel.app/api/ajj-kuch-tufani-krte-hai"></script>
- Create a
<bro-script>
tag at the end of your body tag:
<bro-script src="index.bc"></bro-script>
Make sure to provide the correct path to your .bc
file.
That's it! You're good to go. 🎉
BROCODE DOM Statements
Select an element by its ID
bro ye id ("<id>") wala lake <variable> me rakhde;
Select an element using a CSS selector
bro isko ("<selector>") uthake <variable> me rakhde;
Select all elements matching a CSS selector
bro iske ("<selector>") jese sab uthake <variable> me rakhde;
Change the inner HTML of an element
bro <element> ka html bdl ke ("<new content>") krde;
Change the text content of an element
bro <element> ka text bdl ke ("<new content>") krde;
Set an attribute value on an element
bro <element> ka attribute ("<name>", "<value>") set krde;
Get an attribute value from an element
bro <element> ka attribute ("<name>") le aa;
Remove an attribute from an element
bro <element> ka attribute ("<name>") hta de;
Change the style property of an element
bro <element> ka <property> "<value>" krde;
Add a class to an element
bro <element> ki classes me "<className>" add krde;
Remove a class from an element
bro <element> ki classes me "<className>" remove krde;
Toggle a class on an element
bro <element> ki classes me "<className>" toggle krde;
Add an event listener to an element
bro <element> pe sun ("<event>", <function()>);
Remove an event listener from an element
bro <element> pe sunna bnd kr ("<event>", <function()>);
Create a new element
bro document me "<tagName>" ka nya element <variable> me bna de;
Append a child element to a parent element
bro <element> me <childElement> append krde;
Remove an element from the DOM
bro <element> hta de;
Get the parent node of an element
bro <element> ka parent <variable> me rakhde;
Get the child elements of an element
bro <element> ka children <variable> me rakhde;
Get the value of a form input element
bro <inputElement> ki value <variable> me rakhde;
Scroll an element into view
bro <element> me scroll krde;
Scroll the window to a specific position
bro window ko (x, y) tkk scroll krde;
See what BROCODE can do:
Yes now you can make basic web applications with BROCODE 💀
To-Do-list made with html,css and BROCODE
License
MIT License - see LICENSE file for details.