gglang
v1.0.2
Published
GGLang — A gaming-themed toy programming language built with TypeScript
Maintainers
Readme
██████╗ ██████╗ ██╗ █████╗ ███╗ ██╗ ██████╗
██╔════╝ ██╔════╝ ██║ ██╔══██╗████╗ ██║██╔════╝
██║ ███╗██║ ███╗██║ ███████║██╔██╗ ██║██║ ███╗
██║ ██║██║ ██║██║ ██╔══██║██║╚██╗██║██║ ██║
╚██████╔╝╚██████╔╝███████╗██║ ██║██║ ╚████║╚██████╔╝
╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝🎮 GGLang — The Gaming-Themed Programming Language
GG stands for Good Game. Write code like you're playing one.
🕹️ What is GGLang?
GGLang is a toy programming language where every keyword is a gaming term. Variables are equipped, functions are skills, loops are grinds, and errors are glitches. It's built entirely in TypeScript and is designed to make learning about interpreters and compilers fun.
Instead of writing boring old if / else, you embark on a quest — and if things go south, you retreat. Instead of a while loop, you grind until you're done. Your programs don't just start — they spawn.
✨ Features
| Feature | Description |
|---|---|
| 🎮 Gaming keywords | Every keyword maps to a gaming concept |
| 🧮 Full expressions | Arithmetic, comparison, logical, and assignment operators |
| 🔁 Control flow | quest / side_quest / retreat (if/else if/else) |
| 🔄 Loops | grind (while) with rage_quit (break) and respawn (continue) |
| ⚔️ Functions | skill (function) with loot (return) and recursion support |
| 🛡️ Error handling | boss_fight / revive / glitch (try/catch/throw) |
| 📢 I/O | broadcast (print) and interact (input) |
| 📝 Comments | Single-line // and multi-line /* */ |
| 🏗️ Built with TypeScript | Clean, hackable, and easy to extend |
🚀 Quick Start
Installation
# Clone the repository
git clone <repo-url>
cd toy-programming-language
# Install dependencies
npm install
# Build the project
npm run buildHello, World!
Create a file called hello.gg:
spawn {
broadcast("Hello, World!");
broadcast("Welcome to GGLang! 🎮");
}Run it:
npm start -- hello.ggTry the REPL
npm start📖 A Taste of GGLang
spawn {
// Equip your variables like items in your inventory
equip playerName = interact("Enter your name, adventurer: ");
equip health = 100;
artifact maxHealth = 100; // Artifacts are constants — permanent relics
// Define a skill (function)
skill battleCry(name) {
broadcast("⚔️ " + name + " charges into battle!");
}
// Embark on a quest (if/else)
quest (health == maxHealth) {
battleCry(playerName);
} retreat {
broadcast("You need to heal first!");
}
// Grind through enemies (while loop)
equip enemiesDefeated = 0;
grind (enemiesDefeated < 5) {
broadcast("Enemy #" + (enemiesDefeated + 1) + " defeated!");
enemiesDefeated += 1;
}
broadcast("GG, " + playerName + "! 🏆");
}📚 Documentation
For the complete language reference, syntax guide, and example programs, see the Full Documentation.
📂 Example Programs
| File | Description |
|---|---|
| hello.gg | Hello World — your first spawn |
| fibonacci.gg | Recursive Fibonacci sequence |
| fizzbuzz.gg | Classic FizzBuzz challenge |
| adventure.gg | Mini text adventure game |
🗺️ Keyword Cheat Sheet
| Concept | GGLang | You'd normally write… |
|---|---|---|
| Start program | spawn { } | main() |
| Variable | equip x = 5; | let x = 5; |
| Constant | artifact PI = 3.14; | const PI = 3.14; |
| Print | broadcast("hi"); | console.log("hi"); |
| If / Else if / Else | quest / side_quest / retreat | if / else if / else |
| While loop | grind (cond) { } | while (cond) { } |
| Break / Continue | rage_quit / respawn | break / continue |
| Function / Return | skill fn() { loot val; } | function fn() { return val; } |
| True / False / Null | victory / defeat / phantom | true / false / null |
| Try / Catch | boss_fight { } revive(e) { } | try { } catch(e) { } |
| Throw error | glitch "msg"; | throw "msg"; |
| Input | interact("prompt") | readline("prompt") |
📄 License
This project is licensed under the MIT License — do whatever you want with it. GG! 🎮
