Potterscript
The Wizarding World Programming Language written in Rust
Install / Use
/learn @fmiras/PotterscriptREADME
🧙 PotterScript: The Wizarding World Programming Language
Parody Programming Language based in Harry Potter (Wizarding World). Experience the magical world of coding like never before! It's a really useful to project to learn Rust and how programming languages are done.
✨ Introduction
Ever wished you could speak the magical language of wizards and witches? PotterScript is your enchanted gateway to code with the charm and mystery of the Wizarding World.
This project is a remarkable endeavor to understand the magical connection between human logic and machine interpretation. It's a journey filled with trials, failures, and the sweet taste of success that only comes from the relentless pursuit of something extraordinary.
Powered by Rust and its incredible features like godlike error handling and orgasmic memory safety, PotterScript provides a solid toolkit for creating an enchanting programming experience.
🚀 Get Started
Ready to embark on this magical journey? Here you have a few options:
- Web Playground is an interactive playground where you can write, parse and run PotterScript code within the browser. This is possible because PotterScript parser and runtime were adapted and compiled to a WebAssembly library.
- Ron is a REPL program, basically a terminal-based live console for running PotterScript code.
- You can directly use the parser and runtime on your Rust code and do stuff, you can check the example project that takes an
input.potterfile, parses and evals the code.
🧙♂️ Features
Spell Functions
In PotterScript there are no such things as functions or args, but there are spells and targets. To cast a spell you have to use the wand character ~ followed by the spell name and the target expression.
You can only cast a spell on one target, and the spell will do something with the target. For example, the ~Revelio {target} spell will print the target expression (variable or raw value) to the console.
~Revelio "Hello World!"
Spells can also of course mutate the target, like ~Engorgio {target} that will increment the target value by one.
index = 0
~Engorgio index
~Revelio index # prints "1"
List of spells:
~Aguamenti(no target): Returns "💦"~AvadaKedabra(no target): Process exit (Rust'spanic!())~Engorgio {number|string}: Increments target value by one if number or transforms target string to uppercase~Incendio {string}: Append "🔥" to target value string~Inmobolus {ms}: Sleeps formsmilliseconds. If running on the browser it will usesetTimeoutand if running on the terminal it will usestd::thread::sleep~Lumos(no target): Flags the runtime to start printing values with white background and black text. It doesn't work in WASM (yet) because it's not possible to change the console colors.~Nox(no target): Flags the runtime to stop printing values with white background and black text~Obliviate {variable}: Deletes the variable from the runtime memory~OculusReparo(no target): Returns "👓"~Periculum(no target): Prints "🔥🔥🔥🔥🔥🔥🔥🔥🔥" to the console~Reducio {number|string}: Decrements target value by one if number or transforms target string to lowercase~PetrificusTotalus {variable}: Freezes the variable value, so it can't be mutated anymore (make it const-like)~Revelio {target}: Prints the target expression to the console~Serpensortia(no target): Returns "🐍"~WingardiumLeviosa {string}: Appends new line ("\n") to target string
Sorting Hat
Generate HogwartsHouse values (is a type like String or Integer), using the Sorting Hat, just like:
house = 🎩✨ # or SortingHat
if house = Griffindor {
~Periculum
}
Quidditch Loops
Model your loops after a Quidditch match and use a 'Snitch' condition to end them.
index = 0
quidditch {
snake = ~Serpensortia
~WingardiumLeviosa snake
~WingardiumLeviosa snake
snake = snake + " some string"
~Revelio snake
~Incendio snake
~Revelio snake
~Engorgio index
if index == 4 {
snitch # Break loop
}
}
Outputs:
🐍
some string
🐍
some string🔥
🐍
some string
🐍
some string🔥
🐍
some string
🐍
some string🔥
🐍
some string
🐍
TODO
Language
- [x] Spell Casts
- [x] Binary Operations
- [x] Variables
- [x] If Statements
- [x] Quidditch Loops
- [x] Sorting Hat
- [x] Comments
- [ ] Spell definitions
Packages
- [x] Parser
- [x] Atoms
- [x] Expressions
- [x] Statements
- [x] Program
- [x] Example
- [x] Runtime
- [ ] REPL
- [x] Runtime
- [ ] JIT compiler
- [x] WASM
- [x] Parser
- [x] Runtime
- [ ] Playground
- [x] Parser
- [x] Runtime
- [ ] Compiler
- [ ] Binary (LLVM)
- [ ] WASM
🌟 Contribute
PotterScript is open for contributions! Cast your magical spells and bring your creativity to life.
Disclaimer: This project is not affiliated with Warner Bros. Entertainment Inc. or J.K. Rowling in any way.
Related Skills
himalaya
347.9kCLI to manage emails via IMAP/SMTP. Use `himalaya` to list, read, write, reply, forward, search, and organize emails from the terminal. Supports multiple accounts and message composition with MML (MIME Meta Language).
node-connect
347.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
taskflow
347.9kname: taskflow description: Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layer
frontend-design
108.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
