The Bad Language Compiler (Blan) is a specialized programming language compiler implemented in C++. Inspired by the Zen Programming Language Compiler, this project translates code written in a culturally unique syntax—utilizing Hindi slang and profanities for keywords and functions—into an executable program.
The language strictly enforces designated entry and exit points for scope management.
- Entry Point:
Haan Meri Jaanmarks the beginning of the program. - Exit Point:
Bhag Bsdkmarks the safe termination of the program. Any tokens found after this point will result in a syntax error.
Canonical keywords for conditionals are:
agar(if)tab(then)warna(else-if)nahi_toh(else)khtm(end-if)
Canonical keywords for While-loop are:
JabTak(while)TabTak(Do)hogya(end-while)
Legacy aliases are still accepted for backward compatibility:
warna_agar->warnanhi_toh->nahi_tohbas_itna_hi->khtm
Single-line comments are supported and function identically to C++ or JavaScript.
// This is a single-line comment and will be ignored by the parser.
The evaluator utilizes a Value class (implemented via std::variant) to support the following data types:
- Numbers: Implemented internally as double-precision floating-point numbers (
double). - Strings: Dynamically typed sequence of characters. String concatenation is supported.
- Booleans: Represents true (
sach) or false (jhooth). - Null / Monostate: Represents an empty or uninitialized state.
Variables are declared and assigned using the language's specific keyword set.
bhadwais used for variable declaration.matlbserves as the assignment operator (=).
bolna: Evaluates the subsequent expression and prints the result to the standard output console.
The language supports standard operations with enforced type checking during evaluation:
- Arithmetic:
+,-,*,/,%- The addition operator supports both numerical addition and string concatenation. Type mismatches (e.g., subtracting strings) will result in a semantic error.
- Logical:
&&(AND),||(OR),!(NOT)- Short-circuit evaluation is implemented to optimize performance by skipping unnecessary right-hand side evaluations.
- Comparison:
<,<=,>,>=,==(Equality),!=(Inequality)
The compiler utilizes CMake for its build ecosystem.
Ensure you have CMake and a compatible C++ compiler installed on your system.
- Prepare the build directory:
cmake -S . -B build - Compile the binary:
cmake --build build
Run all discovered tests from the build directory configuration:
ctest --test-dir build
Run the compiled executable and pass your .bl source file as an argument:
- Standard Execution:
.\build\blan.exe examples/example.bl - Debug Execution:
.\build\blan.exe examples/example.bl --debug
Website is WIP, keep an eye on that. If you liked the project, consider starring the repo and follow me for more such chutiyapa.