A world-building language for young storytellers
Project description
ForWhile
A world-building programming language designed to teach Object-Oriented Programming (OOP) and core simulation concepts to young storytellers through a plain-English, narrative-driven syntax.
๐ Quick Links
- Language Specification: docs/LANGUAGE_SPEC.md โ Reference grammar and design decisions.
- Educator's Guide: docs/EDUCATORS_GUIDE.md โ CS concept mapping and 10 classroom exercises.
- Contributor Guidelines: CONTRIBUTING.md โ Set up local environment and coverage goals.
- License: LICENSE โ MIT License.
๐ Philosophy
Every feature in ForWhile is designed to serve a world-building and simulation philosophy:
- Teaches Real Programming Concepts: Maps directly to classes, objects, traits/properties, composition, methods, constructor methods, loops, and conditions.
- Easy to Understand: Reads like plain English narration.
- No Developer Jargon: Avoids being "Python with English words" by replacing technical keywords (like
def,class,return) with narrative concepts (likecreature,action,play scene). - Reinforces World-building: Code reads like a fantasy story or simulation setup.
โ๏ธ Syntax Comparison
Here is how ForWhile maps common programming paradigms to storytelling:
| Programming Concept | Traditional Language (e.g., Python) | ForWhile Narrative Syntax |
|---|---|---|
| Class / Blueprint | class Dragon: |
creature Dragon |
| Instantiation | Ember = Dragon("Ember") |
bring Ember to life as Dragon with ("Ember") |
| State Mutation | Ember.health = 100 |
give Ember the trait health to 100 |
| Composition (Mixin) | attach Fire to Ember |
attach Fire to Ember |
| Method / Action | def breathe(self): |
action breathe |
| Method Call | Ember.breathe() |
Ember does breathe |
| Constructor | def __init__(self): |
when born |
| Conditional Block | if condition: ... else: |
when condition: ... otherwise: |
| Objects Graph / Edge | alice.friend = bob |
alice knows bob as friend |
| Plural References | [x for x in env if type(x) == Dragon] |
the world's Dragon creatures |
| Event Callback | observer.on('die', callback) |
whenever anyone dies |
| Time-Step Loop | for _ in range(10): |
the world ticks 10 times |
| Functions / Calls | def greet(n): / greet("Bob") |
scene greet with (n) / play scene greet with ("Bob") |
| Getter / Computed | @property \n def power(self): |
power is health times 2 |
๐ ๏ธ Installation
ForWhile requires Python 3.8+. Install it from your local package folder:
# Clone the repository
git clone https://github.com/ghanashyam03/ForWhile.git
cd ForWhile
# Install the package in editable development mode
pip install -e .
๐ Usage & CLI Commands
Once installed, the forwhile command is available directly in your terminal. It supports four subcommands:
1. Start the REPL (forwhile start)
Launch the interactive storytelling environment.
forwhile start
Type help inside the REPL to see a visual cheat sheet of commands.
2. Run a Story File (forwhile run <file.fw>)
Bring a .fw story script to life and see the narration.
forwhile run examples/11_story_structure.fw
3. Check a Story File (forwhile check <file.fw>)
Verify a story file for syntax errors or invalid vocabulary without running it.
forwhile check examples/13_trait_kinds.fw
4. Version Check (forwhile --version)
Print the current version of the ForWhile engine.
forwhile --version
๐ Project Structure
ForWhile/
โโโ forwhile/ # Core Source Code
โ โโโ errors.py # Custom child-friendly errors
โ โโโ interpreter.py # Main AST evaluation, CLI, and REPL
โ โโโ lexer.py # PLY Lexer (tokenization)
โ โโโ parser.py # PLY Parser (Abstract Syntax Tree builder)
โโโ tests/ # Comprehensive Test Suites
โ โโโ test_basic.py
โ โโโ test_cli.py
โ โโโ test_coverage_boost.py
โ โโโ test_examples.py
โ โโโ ...
โโโ examples/ # Sample Story Scripts
โ โโโ 01_hello.fw
โ โโโ 11_story_structure.fw
โ โโโ 15_ecosystem.fw # Fox/Rabbit/Grass ecosystem simulation
โโโ docs/ # Documentation
โ โโโ LANGUAGE_SPEC.md
โ โโโ EDUCATORS_GUIDE.md
โโโ editors/vscode/ # VS Code Extension Support
โ โโโ package.json # Extension configuration
โ โโโ syntaxes/ # Syntax highlighting definition
โโโ setup.py # legacy setuptools installation
โโโ pyproject.toml # Modern package manifest
โโโ LICENSE # MIT License
๐งช Development & Testing
We maintain a strict code coverage requirement of $\ge 90%$ on forwhile/interpreter.py.
Install test dependencies and run the tests:
pip install pytest pytest-cov
python -m pytest --cov=forwhile --cov-report=term-missing
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file forwhile-1.0.1.tar.gz.
File metadata
- Download URL: forwhile-1.0.1.tar.gz
- Upload date:
- Size: 28.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a81e5f899047d842314672b8b0afd374474d562a13bcc289726d7c99017f168
|
|
| MD5 |
9e0847d52135d6cfd7abc7282df6e23a
|
|
| BLAKE2b-256 |
d3b4cfeee1510f698dfacfada666e9d6df5c7eb29619f0a2adecd8d478bc4451
|
File details
Details for the file forwhile-1.0.1-py3-none-any.whl.
File metadata
- Download URL: forwhile-1.0.1-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05ce028c58f7cb8838605c7c9c6353f1b8e06bb1d5bfd92cef25c78d9f1a9c93
|
|
| MD5 |
b2f2ce8abe49822e6f9128009ebd3a59
|
|
| BLAKE2b-256 |
9c5b906af911c7d63474b8320db7af171294dc3959f5c78be3e5dca6ac972f0b
|