Skip to content

FABLE: Forth Animated Beginners Learning Environment - An educational IDE for learning Forth through animated stack visualization

License

Notifications You must be signed in to change notification settings

CFFinch62/fable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FABLE Logo

FABLE

Forth Animated Beginners Learning Environment

Every stack tells a story

Python PyQt6 License

An educational IDE for learning the Forth programming language through animated stack visualization

Features β€’ Installation β€’ Quick Start β€’ Documentation β€’ Examples β€’ Contributing


πŸ“Έ Screenshot

FABLE IDE


🎯 What is FABLE?

FABLE is a modern, visual IDE designed specifically for learning Forthβ€”a stack-based, concatenative programming language. Unlike traditional Forth environments, FABLE makes the abstract concept of stack manipulation concrete and observable through real-time animated visualizations.

Whether you're a complete beginner to programming or an experienced developer curious about stack-based languages, FABLE provides an intuitive, engaging environment to explore Forth's unique paradigm.

Why FABLE?

  • 🎬 Animated Stack Visualization - Watch values flow through the data and return stacks with smooth, color-coded animations
  • πŸ“š Educational Focus - Built from the ground up for learning, with comprehensive examples and tutorials
  • 🎨 Modern Interface - Clean, professional 4-panel IDE with syntax highlighting and dark/light themes
  • πŸ”§ Interactive REPL - Immediate feedback loop for experimenting with Forth words
  • πŸ“¦ Library System - Save and reuse your word definitions across sessions
  • πŸŽ“ Step-Through Debugging - Execute code word-by-word to understand exactly what's happening

✨ Features

Core Features

  • Animated Stack Widget - Real-time visualization of data and return stacks with smooth animations for push, pop, swap, and other operations
  • Custom Forth Interpreter - Educational interpreter with 60+ primitive words and execution hooks for animation synchronization
  • 4-Panel IDE Layout
    • File Browser (left) - Navigate projects with bookmarks and persistence
    • Code Editor (center-top) - Syntax highlighting, line numbers, auto-indentation
    • Interactive REPL (center-bottom) - Test code immediately with command history
    • Stack Visualization (right) - Always-visible animated stack display
  • Step-Through Debugging - Execute code word-by-word to see exactly how the stack changes
  • Library System - Build reusable collections of Forth words with INCLUDE and SAVE-LIBRARY
  • Comprehensive Examples - 14+ focused example programs covering all major concepts
  • Dark & Light Themes - Multiple color schemes to suit your preference

Bundled Libraries

FABLE includes 5 starter libraries with 100+ additional Forth words:

  • math-extended.fth - Advanced math (factorial, GCD, prime checking, etc.)
  • stack-helpers.fth - Advanced stack manipulation (PICK, ROLL, DEPTH, etc.)
  • strings.fth - Text formatting and drawing utilities
  • algorithms.fth - Common algorithms (Collatz, palindrome checking, etc.)
  • graphics.fth - ASCII art generation (rectangles, pyramids, progress bars)

πŸš€ Installation

Prerequisites

  • Python 3.11 or higher
  • PyQt6 6.5.0 or higher

Install from Source

# Clone the repository
git clone https://github.com/CFFinch62/fable.git
cd fable

# Install dependencies
pip install -r requirements.txt

# Run FABLE
python3 fable.py

Dependencies

FABLE has minimal dependencies:

PyQt6>=6.5.0

πŸŽ“ Quick Start

Your First Commands

Launch FABLE and type in the REPL (bottom panel):

42 .                \ Push 42 to stack, then print it
1 2 + .             \ Push 1, push 2, add them, print result (3)
: SQUARE DUP * ;    \ Define a word to square a number
5 SQUARE .          \ Use SQUARE to print 25

Watch the stack visualization (right panel) animate as each operation executes!

Running Example Files

  1. Click the File Browser (left panel)
  2. Navigate to the examples/ folder
  3. Double-click simple-math.fs to open it
  4. Press F5 to run the entire file
  5. Watch the stack animate as the program executes!

Using Libraries

\ Load a library
S" math-extended.fth" INCLUDE

\ Use library words
5 FACTORIAL .       \ Prints: 120
-42 ABS .           \ Prints: 42
17 PRIME? .         \ Prints: -1 (true)

Keyboard Shortcuts

Shortcut Action
F5 Run entire file
F6 Run selected text
F7 Run current line
F10 Step through code (one word at a time)
Ctrl+B Toggle file browser
Ctrl+T Toggle REPL
Ctrl+N New file
Ctrl+O Open file
Ctrl+S Save file

πŸ“– Documentation


πŸ“š Examples

FABLE includes 14 focused example programs:

Basic Concepts

  • simple-math.fs - Basic arithmetic operations
  • stack-operations.fs - Stack manipulation (DUP, SWAP, OVER, etc.)
  • word-definition.fs - Creating custom words

Control Flow

  • if-then.fs - Simple conditional execution
  • if-else-then.fs - Branching logic
  • begin-until.fs - Loop until condition is true
  • while-repeat.fs - Loop while condition is true
  • do-loop.fs - Counted loops

Practical Programs

  • factorial.fs - Calculate factorials
  • fibonacci.fs - Generate Fibonacci sequence
  • gcd.fs - Greatest common divisor
  • prime-check.fs - Test if a number is prime
  • temp-convert.fs - Temperature conversion
  • number-guess.fs - Number guessing game
  • drawing-boxes.fs - ASCII art

Advanced

  • using-libraries.fth - Demonstrates the library system

πŸ—οΈ Architecture

FABLE is built with Python 3.11+ and PyQt6, featuring:

  • Custom Forth Interpreter - Educational implementation with execution hooks
  • Signal-Based Architecture - Clean separation between interpreter and UI
  • Animated Stack Widget - Custom QWidget with smooth animations
  • Syntax Highlighting - Custom lexer for Forth syntax
  • Settings Persistence - JSON-based configuration storage

Project Structure

fable/
β”œβ”€β”€ fable/
β”‚   β”œβ”€β”€ app.py                 # Main application window
β”‚   β”œβ”€β”€ interpreter/           # Forth interpreter
β”‚   β”‚   β”œβ”€β”€ interpreter.py     # Core interpreter
β”‚   β”‚   β”œβ”€β”€ dictionary.py      # Word dictionary
β”‚   β”‚   β”œβ”€β”€ primitives.py      # Built-in words
β”‚   β”‚   └── lexer.py           # Tokenizer
β”‚   β”œβ”€β”€ widgets/               # UI components
β”‚   β”‚   β”œβ”€β”€ editor.py          # Code editor
β”‚   β”‚   β”œβ”€β”€ repl.py            # Interactive REPL
β”‚   β”‚   β”œβ”€β”€ stack_widget.py    # Stack visualization
β”‚   β”‚   └── file_browser.py    # File navigation
β”‚   β”œβ”€β”€ utils/                 # Utilities
β”‚   └── resources/             # Icons and images
β”œβ”€β”€ libraries/                 # Bundled Forth libraries
β”œβ”€β”€ examples/                  # Example programs
β”œβ”€β”€ tutorial/                  # Learning materials
└── docs/                      # Documentation

🎨 Themes

FABLE includes multiple color themes:

  • Dark Themes: Monokai, Dracula, Nord, Gruvbox Dark, Solarized Dark
  • Light Themes: GitHub Light, Solarized Light, Gruvbox Light

Switch themes via View β†’ Theme menu.


🀝 Contributing

Contributions are welcome! Here are some ways you can help:

  • Report bugs - Open an issue with details and steps to reproduce
  • Suggest features - Share your ideas for improving FABLE
  • Add examples - Create new example programs or tutorials
  • Improve documentation - Help make the docs clearer and more comprehensive
  • Create libraries - Build useful Forth libraries for the community
  • Fix bugs - Submit pull requests for known issues

Development Setup

# Clone the repository
git clone https://github.com/CFFinch62/fable.git
cd fable

# Install dependencies
pip install -r requirements.txt

# Run in development mode
python3 fable.py

See FABLE_Development_Prompt.md for detailed development guidelines.


πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Chuck Finch / Fragillidae Software - Creator and primary developer
  • The Forth Community - For decades of innovation in stack-based programming
  • PyQt6 - For the excellent GUI framework
  • All Contributors - Thank you for your support!

πŸ“¬ Contact


🌟 Star History

If you find FABLE useful, please consider giving it a star! ⭐


Made with ❀️ for the Forth community

Every stack tells a story

About

FABLE: Forth Animated Beginners Learning Environment - An educational IDE for learning Forth through animated stack visualization

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published