No project description provided
Project description
BhauLang
BhauLang is a toy programming language inspired by BhaiLang. It includes basic constructs for variable declaration, printing, conditionals, and loops.
Features
- Variable declaration
- Printing to the console
- Conditional statements (
if
,else if
,else
) - While loops
Installation
You can install BhauLang directly from PyPI:
pip install BhauLang
Usage
After installing the package, you can run .bhau files using the bhau command. For example:
bhau example.bhau
Syntax
Variable Declaration
Declare a variable using he bagh followed by the variable name and value:
he bagh a = 10
he bagh name = "hello"
he bagh: This keyword is used to declare a new variable.
Printing
Print to the console using bol:
bol (a)
bol ("Hello, world!")
bol: This keyword is used to print the value of an expression or variable to the console.
Conditionals
Use jar, nasel tar, and nahi tar for conditional statements:
jar (a < 10) {
bol ("yes less than 10")
}
nasel tar (a < 20) {
bol ("yes less than 20")
}
nahi tar {
bol ("not less than 10 or 20")
}
- jar: This keyword is used for the if condition. If the condition is true, the block of code within the braces {} is executed.
- nasel tar: This keyword is used for the else if condition. If the previous if or else if condition was false, and this condition is true, the block of code within the braces {} is executed.
- nahi tar: This keyword is used for the else condition. If none of the previous if or else if conditions were true, the block of code within the braces {} is executed.
While Loops
Use joparyanta for while loops:
joparyanta (a < 5) {
bol (a)
a = a + 1
}
joparyanta: This keyword is used for a while loop. The loop continues to execute the block of code within the braces {} as long as the condition is true.
Examples
- Example 1 :
he bagh a = 10
bol (a)
jar (a<10){
bol ("yes less than 10")
}
nasel tar (a<20){
bol ("yes less than 20")
}
nahi tar{
bol ("not less than 10 or 20")
}
Expected Output:
10
yes less than 20
- Example 2
he bagh name = "hello"
bol (name)
he bagh number = 56
bol (number)
Expected Output:
hello
56
- Example 3
he bagh a = 0
joparyanta ( a<5 ){
bol (a)
a = a + 1
}
Expected Output:
0
1
2
3
4
- Example 4
he bagh countdown = 4
joparyanta (countdown > 0){
bol (countdown)
countdown = countdown - 1
}
Expected Output:
4
3
2
1
- Example 5
he bagh n = 5
he bagh i = 1
joparyanta (i <= n){
he bagh j = n - i
he bagh line = ""
joparyanta (j > 0){
line = line + " "
j = j - 1
}
he bagh j = 1
joparyanta (j <= 2 * i - 1){
line = line + "*"
j = j + 1
}
bol(line)
i = i + 1
}
he bagh i = n - 1
joparyanta (i > 0){
he bagh j = n - i
he bagh line = ""
joparyanta (j > 0){
line = line + " "
j = j - 1
}
he bagh j = 1
joparyanta (j <= 2 * i - 1){
line = line + "*"
j = j + 1
}
bol(line)
i = i - 1
}
Expected Output:
*
***
*****
*******
*********
*******
*****
***
*
- Example 6 (Fibonacci Sequence)
he bagh n = 10
he bagh a = 0
he bagh b = 1
he bagh i = 0
joparyanta (i < n){
bol(a)
he bagh temp = a
a = b
b = temp + b
i = i + 1
}
Expected Output :
0
1
1
2
3
5
8
13
21
34
- Example 7 (Factorial Calculation)
he bagh n = 5
he bagh factorial = 1
he bagh i = 1
joparyanta (i <= n){
factorial = factorial * i
i = i + 1
}
bol("Factorial of " , n , " is " , factorial)
Expected Output :
Factorial of 5 is 120
BhauLang currently lacks proper error handling, so it may crash or produce unexpected errors if incorrect syntax or unsupported features are encountered.
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
Built Distribution
File details
Details for the file BhauLang-0.3.tar.gz
.
File metadata
- Download URL: BhauLang-0.3.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1b302fd3a0a3c68e37c378c28c7cf1811f40625abcbd10a12352eb994b27823 |
|
MD5 | ba178892b7b4e06969451f383cdb988b |
|
BLAKE2b-256 | 486de3d807fd631304c3f033ae57b33c28939db811854058db62b7cf07f5b94a |
File details
Details for the file BhauLang-0.3-py3-none-any.whl
.
File metadata
- Download URL: BhauLang-0.3-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e504f1d92068d98a5b8f1f70ddbc4dcf7e81a849eb054979d747f2b6d42d9d19 |
|
MD5 | 2db7e03767466e7bd792af68ade2766f |
|
BLAKE2b-256 | c95f447789bf123cf1e5aec92eb4664f66a996fbb6f2a925dd4e8dac0bf02130 |