Vybe Documentation
Vybe Main page
Architecture Overview
Vybe follows a modular architecture where each component is isolated in its own crate, facilitating testing and reuse.
🏗️ Component Breakdown
1. Vybe Parser (Vybe_parser)
The brain of the operation. It uses the pest crate to implement a Parsing Expression Grammar (PEG).
- Grammar: Defined in
grammar.pest. - AST: Converts raw tokens into a strongly-typed Abstract Syntax Tree.
- Responsibility: Validation of syntax and preparing code for execution.
2. Vybe Runtime (Vybe_runtime)
A tree-walking interpreter that executes the AST directly.
- Environment: Manages variable scoping and object instances.
- Builtins: Implements the rich library of VB functions (Math, Date, String).
- Dispatcher: Connects script calls to native Rust function implementations.
3. Vybe Forms (Vybe_forms)
A cross-platform UI model that defines how forms and controls look and behave.
- Control Model: Defines properties (BackColor, Caption, etc.) for all supported controls.
- Events: Manages the binding between UI actions (Click, Change) and script handlers.
- Serialization: Handles saving/loading forms as JSON.
4. Vybe Editor (Vybe_editor)
The Visual Design Environment.
- The Designer: A GUI (built with iced/dioxus) where users drag controls.
- Project Mgt: Integrates the parser, forms, and runtime into a cohesive workspace.
🔄 Execution Flow
- Parse:
VBParserreads the.vbsource and generates anast::Program. - Setup: The
Interpreterinitializes the environment with builtin functions. - Execute: The interpreter walks the AST node by node, updating state in the
Environment. - Events: When a user interacts with a form, the UI captures the event and tells the interpreter to run the corresponding
Sub.
graph TD
Source[.vb File] --> Parser[Vybe_parser]
Parser --> AST[AST Tree]
AST --> Interpreter[Vybe_runtime]
Interpreter --> Builtins[Builtin Functions]
Interpreter --> UI[Vybe_forms]
UI --> Editor[Vybe_editor]