hindilang
v1.0.4
Published
A Hindi-inspired scripting language
Downloads
14
Maintainers
Readme
hindilang: A Hindi-Inspired Programming Language 🚀
🔗 Full Blog: Building my own Programming Language
hindilang is a Hindi-inspired scripting language that transpiles to JavaScript, built as an academic exercise to understand compilers and programming languages.
Features 🌟
✅ Print Statements – Display output using CHAPO. ✅ Variables & Assignment – Declare variables with MANLO. ✅ User Input – Take input using PUCHO. ✅ Arithmetic Expressions – Perform calculations with +, -, *, /. ✅ Conditional Statements – Use AGAR (if) with {} blocks. ✅ Loops – Use JABTAK (while) for iterations. ✅ Comments – Use # for comments.
A Quick Taste of hindilang
Here are some examples
- Variables and Printing
MANLO x = 5;
CHAPO x;
// Output
// 5- Taking User Input
PUCHO y;
CHAPO y;
// (If user enters 10)
// Output is 10- Conditional Statements (if)
MANLO x = 5;
AGAR (x > 3) {
CHAPO "X bada hai!";
}
// Output
// X bada hai- Loops (while)
MANLO x = 5;
JABTAK (x < 10) {
CHAPO x;
MANLO x = x + 1;
}
// Output
// 5
// 6
// 7
// 8
// 9
// 10- Comments
# Yeh ek comment hai
//(Comments are ignored during execution)How to Install & Run
- Install Globally Hindilang must be installed globally to work as a CLI tool:
npm install -g hindilang- Run your Script
hindic myscript.hindiNote: Ensure that your npm global bin directory is in your system's PATH if hindic is not recognized.
Troubleshooting: "hindic not recognized" Problem
If after installing you see an error like:
'hindic' is not recognized as an internal or external commandfollow these steps:
Check your global npm bin directory: Run the following command to find where npm installs global executables:
npm prefix -gTypically, on Windows, this will be something like:
C:\Users\<YourUsername>\AppData\Roaming\npmAdd the directory to your PATH (if it's missing):
- Temporary fix (only for the current terminal session):
$env:Path += ";C:\Users\<YourUsername>\AppData\Roaming\npm" - Permanent fix (persists across restarts):
In PowerShell, run:
[Environment]::SetEnvironmentVariable("Path", $env:Path + ";C:\Users\<YourUsername>\AppData\Roaming\npm", "User")
Restart your terminal after making changes !
How It Works 🔧
Code Flow 🚀
📌 package.json – Defines the project and dependencies. 📌 bin/hindic – Reads .hindi files, compiles, and executes them. 📌 Lexer – Converts source code into tokens. 📌 Emitter – Stores and writes transpiled JavaScript. 📌 Parser – Matches tokens to grammar and generates JavaScript output.
Parser Characteristics
✔️ Top-Down Parsing – Starts from the highest-level structure (program) and drills down into finer details like expressions and numbers. ✔️ Recursive Descent – The parser calls itself recursively to process different statements and expressions. ✔️ LL(1) Parsing – Uses one token lookahead to determine the next action without backtracking.
Beyond Transpiling
🛣️ Use LLVM to generate optimized machine code. 🛣️ Emit x86 assembly and compile using an assembler (nasm). 🛣️ Convert code to WebAssembly (WASM) for execution in browsers.
Other Info 🤝
- Inspired by TeenyTinyCompiler
- Feel free to open issues or submit PRs.
- Future plans: A Playground for it to see it run in the browser.
🚀 Made with ❤️ by Arjit Sharma
