banglascript-transpiler
v1.0.0
Published
A BanglaScript to JavaScript transpiler.
Downloads
71
Readme
BanglaScript Transpiler
BanglaScript is a beginner-friendly toy programming language that translates Bangladeshi GEZ-Z slang into JavaScript.
Features
- BanglaScript keywords for familiar and intuitive programming.
- Transpiles BanglaScript code into executable JavaScript code.
- Easy installation and usage via npm.
- Optional syntax highlighting support in VS Code.
Installation
To install BanglaScript globally from npm, run the following command:
npm install -g banglascript-transpiler
This will make the banglascript
CLI tool available globally on your system.
Usage
Setting Up BanglaScript in Your Project
Create a BanglaScript file with the
.bns
extension (e.g.,input.bns
).Use the
banglascript
command to transpile the BanglaScript code into JavaScript:banglascript input.bns output.js
Run the transpiled JavaScript file using Node.js:
node output.js
Example Code
Here is a sample BanglaScript program saved as input.bns
:
bro taka = 100;
funde discount(taka) {
jodi (taka > 500) {
bolchi("Boro taka:", taka - 50);
} naile {
bolchi("Chhoto taka:", taka - 10);
}
oi mama taka;
}
discount(taka);
arre bhai {
bar-bar (bro i = 0; i < 5; i++) {
bolchi(`Loop e ase: ${i}`);
}
} bujhso na (err) {
katlay porbi("Error:", err);
} jhamela shesh {
bolchi("Shob thik ache");
}
Transpile and execute the file:
banglascript input.bns output.js
node output.js
Output:
Chhoto taka: 90
Loop e ase: 0
Loop e ase: 1
Loop e ase: 2
Loop e ase: 3
Loop e ase: 4
Shob thik ache
BanglaScript Keywords
The following table maps BanglaScript keywords to their JavaScript equivalents:
| BanglaScript | JavaScript | Description |
| ---------------- | --------------- | --------------------------------- |
| bro
| let
| Declaring variables |
| mamu
| const
| Declaring constants |
| funde
| function
| Function declaration |
| jodi
| if
| Conditional if |
| naile
| else
| Conditional else |
| bolchi
| console.log
| Print to console |
| bar-bar
| for
| For loop |
| ghurtey
| while
| While loop |
| oi mama
| return
| Return statement |
| cooked
| setTimeout
| Set timeout |
| baba re
| throw
| Throw error or exception |
| arre bhai
| try
| Try block |
| bujhso na
| catch
| Catch block |
| jhamela shesh
| finally
| Finally block |
| matha noshto
| null
| Null value |
| besh besh
| true
| Boolean true |
| na re bhai
| false
| Boolean false |
| shuru theke
| start
| Loop or process start placeholder |
| shesh porjonto
| end
| Loop or process end placeholder |
| tui genius
| console.info
| Info log |
| arektu boro
| console.warn
| Warning log |
| katlay porbi
| console.error
| Error log |
Syntax Highlighting for BanglaScript
To enable syntax highlighting for BanglaScript in Visual Studio Code, install the BanglaScript Syntax Colors extension from the VS Code Marketplace. You can find it here.
Contributing
Contributions are welcome! If you find bugs or have suggestions, feel free to create an issue or submit a pull request.
License
This project is licensed under the ISC License.
Start writing in BanglaScript today and make coding fun and intuitive!