Warning
Use for learning, experimentation, or playgrounds only. No updates or new features are planned
- Minimal TypeScript BhaiLang interpreter
- Lexer, parser, interpreter fully implemented in
core/ runner.tsexposesrunBhaiLang(sourceCode: string)for Node and web playground- Separate TypeScript configs for Node and web bundling (
tsconfig.jsonandtsconfig.web.json) - Designed for experimentation and learning; not intended for production
git clone https://github.com/journeycodesayush/ts-bhai.git
cd ts-bhai/package
npm installBuild step is not required. Use
runner.tsdirectly.
import { runBhaiLang } from "./core/runner";
const sourceCode = `
bhai ye hai a = "Hello";
bol bhai a;
`;
const result = runBhaiLang(sourceCode);
console.log("Output:", result.output); // ["Hello"]
console.log("Errors:", result.errors); // []- Import
runBhaiLangfromcore/runner.tsin your React/Vite project. - Use
tsconfig.web.jsonfor bundling. - Example:
import { runBhaiLang } from "../package/core/runner";
const result = runBhaiLang("bhai ye hai x = 42; bol bhai x;");
console.log(result.output); // ["42"]bhai ye hai a = 10;
bhai ye hai b = 20;
bol bhai a, b; # prints 10, 20
bhai ye hai name = "TS-Bhai";
bhai ye hai score = 100;
bol bhai "Name:", name, "Score:", score;
bhai ye hai score = 75;
agar bhai (score >= 90) {
bol bhai "Topper bhai!";
} nahi to bhai (score >= 60) {
bol bhai "Pass hogaya bhai!";
} warna bhai {
bol bhai "Thoda padh le bhai.";
}
bhai ye hai i = 0;
jab tak bhai (i < 5) {
bol bhai i;
i = i + 1;
}
package/
├── core/
│ ├── lexer/
│ ├── parser/
│ ├── interpreter/
│ └── runner.ts
├── tsconfig.json # Node-only config
├── tsconfig.web.json # Web/bundler config
├── package.json
└── README.md- Not actively maintained
- No npm build scripts
- No automated tests
- Desktop-only playground
- Single-file execution via runner only
- Modify logic inside
core/if needed - Test using Node
- Use
tsconfig.web.jsonwhen bundling for web - Keep changes modular and update runner accordingly
Follow Conventional Commits:
fix(package): handle runtime errors
docs(readme): update usage examplesThis repo is reference-only. You can fork it and experiment, but active development is not planned.
Steps if you want to tinker:
- Fork the repo
- Modify code inside
core/ - Test using Node or playground
- Submit a PR (optional)
MIT License
MIT License
Copyright (c) 2025 JourneyCodesAyush
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Made with ♥ by JourneyCodesAyush