|
| 1 | +# WokeLang Example Programs |
| 2 | + |
| 3 | +This directory contains example programs demonstrating WokeLang's features. |
| 4 | + |
| 5 | +## Running Examples |
| 6 | + |
| 7 | +### Using the Interpreter (Tree-Walking) |
| 8 | +```bash |
| 9 | +woke run examples/01_hello.woke |
| 10 | +``` |
| 11 | + |
| 12 | +### Using the VM (Bytecode) |
| 13 | +```bash |
| 14 | +woke run-vm examples/01_hello.woke |
| 15 | +``` |
| 16 | + |
| 17 | +### Type Checking |
| 18 | +```bash |
| 19 | +woke typecheck examples/01_hello.woke |
| 20 | +``` |
| 21 | + |
| 22 | +### Linting |
| 23 | +```bash |
| 24 | +woke lint examples/01_hello.woke |
| 25 | +``` |
| 26 | + |
| 27 | +## Examples |
| 28 | + |
| 29 | +### 01_hello.woke ✓ Interpreter ✓ VM |
| 30 | +The simplest possible WokeLang program. Returns the answer to everything. |
| 31 | + |
| 32 | +### 02_arithmetic.woke ✓ Interpreter ✓ VM |
| 33 | +Basic arithmetic operations: addition, subtraction, multiplication, division, modulo. |
| 34 | + |
| 35 | +### 03_conditionals.woke ✓ Interpreter ✓ VM |
| 36 | +Conditional execution with `when/otherwise` (if/else) statements. |
| 37 | + |
| 38 | +### 04_loops.woke ✓ Interpreter ⚠ VM (partial) |
| 39 | +Repetition with `repeat...times` loops. Includes a factorial implementation. |
| 40 | +*Note: VM loop implementation in progress* |
| 41 | + |
| 42 | +### 05_functions.woke ✓ Interpreter ⚠ VM (not yet) |
| 43 | +Function definitions, parameters, return types, and function calls. |
| 44 | +*Note: VM function calls not yet implemented* |
| 45 | + |
| 46 | +### 06_variables.woke ✓ Interpreter ✓ VM |
| 47 | +Variable declaration with `remember` and reassignment. |
| 48 | + |
| 49 | +### 07_arrays.woke ✓ Interpreter ⚠ VM (not yet) |
| 50 | +Array creation, indexing, and manipulation. |
| 51 | +*Note: VM array indexing not yet implemented* |
| 52 | + |
| 53 | +### 08_consent.woke ✓ Interpreter ✓ VM |
| 54 | +Consent gates with `only if okay` for permission-protected operations. |
| 55 | + |
| 56 | +## Language Features |
| 57 | + |
| 58 | +### Human-Centered Syntax |
| 59 | +- `to function_name()` - Define a function |
| 60 | +- `remember x = value` - Declare a variable |
| 61 | +- `give back value` - Return from a function |
| 62 | +- `when condition { ... } otherwise { ... }` - Conditional |
| 63 | +- `repeat n times { ... }` - Loop |
| 64 | +- `only if okay "permission" { ... }` - Consent gate |
| 65 | + |
| 66 | +### Types |
| 67 | +- `Int` - Integer numbers |
| 68 | +- `Float` - Floating-point numbers |
| 69 | +- `String` - Text strings |
| 70 | +- `Bool` - Boolean values (true/false) |
| 71 | +- `Array` - Collections |
| 72 | +- `Result<T, E>` - Success/error values (Okay/Oops) |
| 73 | + |
| 74 | +### Unique Features |
| 75 | +- **Consent-Driven**: `only if okay` gates for capability-based security |
| 76 | +- **Gratitude Blocks**: `thanks to { ... }` for acknowledgments |
| 77 | +- **Emote Annotations**: `@emote` for emotional context |
| 78 | +- **Units of Measure**: `measured in meters` for dimensional types |
| 79 | + |
| 80 | +## Contributing |
| 81 | + |
| 82 | +Feel free to add more examples! Follow these guidelines: |
| 83 | +- Number examples sequentially |
| 84 | +- Include comments explaining the code |
| 85 | +- Keep examples focused on a single feature |
| 86 | +- Test examples before committing |
| 87 | + |
| 88 | +## License |
| 89 | + |
| 90 | +PMPL-1.0-or-later |
0 commit comments