Skip to content

Commit 62f54b9

Browse files
authored
Merge pull request #21 from Kink-Development-Group/dev
2 parents 5c95a23 + 37cd71c commit 62f54b9

92 files changed

Lines changed: 5717 additions & 3122 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/copilot-instructions.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# HypnoScript Copilot Instructions
2+
3+
## Architecture Overview
4+
5+
HypnoScript is a hypnotically-themed programming language with a pure Rust implementation (Rust 2024 edition). The compilation pipeline flows:
6+
7+
```
8+
Source (.hyp) → Lexer → Tokens → Parser → AST → TypeChecker → Interpreter/Compiler
9+
```
10+
11+
**Workspace crates (dependency order):**
12+
13+
| Crate | Purpose | Key Exports |
14+
| -------------------------- | --------------------------- | ------------------------------------------------------------------------ |
15+
| `hypnoscript-core` | Type system foundation | `HypnoType`, `HypnoBaseType`, `SymbolTable` |
16+
| `hypnoscript-lexer-parser` | Tokenization & AST | `Lexer`, `Parser`, `AstNode`, `Token` |
17+
| `hypnoscript-runtime` | 180+ builtins (20+ modules) | `MathBuiltins`, `StringBuiltins`, `ArrayBuiltins`, etc. |
18+
| `hypnoscript-compiler` | All backends | `Interpreter`, `TypeChecker`, `WasmCodeGenerator`, `NativeCodeGenerator` |
19+
| `hypnoscript-cli` | CLI + package manager | Commands: `exec`, `lex`, `parse`, `check`, `compile-wasm` |
20+
21+
## Essential Commands
22+
23+
```bash
24+
# Development cycle
25+
cargo build --all # Debug build
26+
cargo run -p hypnoscript-cli -- exec file.hyp # Run .hyp file
27+
cargo run -p hypnoscript-cli -- exec file.hyp --debug # Interactive debugger
28+
29+
# Testing (185+ tests, run on Windows/Linux/macOS in CI)
30+
cargo test --all # All tests
31+
cargo test --package hypnoscript-compiler -- --nocapture # Single crate with output
32+
cargo test --package hypnoscript-runtime test_math # Specific test
33+
34+
# Pre-commit quality checks (enforced by CI)
35+
cargo fmt --all -- --check
36+
cargo clippy --all-targets --all-features -- -D warnings
37+
38+
# Release build (LTO enabled, stripped)
39+
cargo build --all --release
40+
```
41+
42+
## Language Syntax Quick Reference
43+
44+
HypnoScript uses hypnotic-themed keywords. See [token.rs](hypnoscript-lexer-parser/src/token.rs) for complete list.
45+
46+
| HypnoScript | Equivalent | Example |
47+
| ---------------------------- | ---------- | ---------------------------------------------------------------- |
48+
| `Focus { } Relax` | program | `Focus { observe "hi"; } Relax` |
49+
| `induce`/`freeze` | let/const | `induce x: number = 42;` |
50+
| `suggestion` | function | `suggestion add(a: number, b: number): number { awaken a + b; }` |
51+
| `session` | class | `session Counter { expose count: number = 0; }` |
52+
| `observe`/`whisper` | print | `observe "Hello";` (with newline) |
53+
| `awaken` | return | `awaken result;` |
54+
| `entrain`/`when`/`otherwise` | match | `entrain x { when 0 => "zero" otherwise => "other" }` |
55+
| `yourEyesAreGettingHeavy` | >= | `if (x yourEyesAreGettingHeavy 10) deepFocus { }` |
56+
| `lucidFallback` | ?? | `maybeNull lucidFallback 100` |
57+
58+
## Adding New Builtin Functions
59+
60+
1. **Create module** in `hypnoscript-runtime/src/` (e.g., `my_builtins.rs`)
61+
2. **Implement trait** `BuiltinModule` from [builtin_trait.rs](hypnoscript-runtime/src/builtin_trait.rs):
62+
```rust
63+
impl BuiltinModule for MyBuiltins {
64+
fn module_name() -> &'static str { "My" }
65+
fn description() -> &'static str { "My builtin functions" }
66+
fn function_names() -> &'static [&'static str] { &["MyFunc1", "MyFunc2"] }
67+
}
68+
```
69+
3. **Export** in `hypnoscript-runtime/src/lib.rs`
70+
4. **Register** in [interpreter.rs](hypnoscript-compiler/src/interpreter.rs) - add match arms in `call_builtin_function()`
71+
5. **Add tests** as inline `#[cfg(test)] mod tests { }` at file end
72+
73+
## Code Conventions
74+
75+
- **Error handling**: Use `thiserror` with `#[derive(Error)]`. User-facing errors support i18n via `LocalizedMessage` (EN, DE, FR, ES)
76+
- **AST nodes**: All constructs map to variants in `AstNode` enum ([ast.rs](hypnoscript-lexer-parser/src/ast.rs))
77+
- **Tests**: Inline modules at file end with `#[cfg(test)]`. Test `.hyp` files in `hypnoscript-tests/`
78+
- **Workspace deps**: Shared dependencies defined in root `Cargo.toml` under `[workspace.dependencies]`
79+
80+
## Package Manager (trance.json)
81+
82+
HypnoScript projects use themed manifest keys:
83+
84+
- `ritualName` → package name, `mantra` → version
85+
- `anchors`/`deepAnchors` → dependencies/devDependencies
86+
- `suggestions` → npm-style scripts
87+
88+
See [package.rs](hypnoscript-cli/src/package.rs) for schema.
89+
90+
## Key Files Reference
91+
92+
| File | Purpose |
93+
| ------------------------------------------------------------ | -------------------------------------------- |
94+
| [interpreter.rs](hypnoscript-compiler/src/interpreter.rs) | Main runtime (3400+ lines), builtin dispatch |
95+
| [ast.rs](hypnoscript-lexer-parser/src/ast.rs) | All 30+ AST node variants |
96+
| [token.rs](hypnoscript-lexer-parser/src/token.rs) | Token types & hypnotic keyword mappings |
97+
| [types.rs](hypnoscript-core/src/types.rs) | `HypnoType` enum, type inference |
98+
| [builtin_trait.rs](hypnoscript-runtime/src/builtin_trait.rs) | `BuiltinModule` trait for extending runtime |

.github/labeler.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Labeler-Konfiguration für HypnoScript
1+
# Labeler configuration for HypnoScript
22
# See https://github.com/actions/labeler for configuration format.
33

44
'area:core':

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
- name: Checkout
3636
uses: actions/checkout@v4
3737
with:
38-
fetch-depth: 0 # Für VitePress lastUpdated-Feature
38+
fetch-depth: 0 # For VitePress lastUpdated feature
3939

4040
- name: Setup Rust
4141
uses: actions-rust-lang/setup-rust-toolchain@v1

.github/workflows/rust-build-and-release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,11 @@ jobs:
189189
190190
## Installation
191191
192-
### Automatisches Setup (Linux/macOS)
192+
### Automatic setup (Linux/macOS)
193193
```bash
194194
curl -fsSL https://kink-development-group.github.io/hyp-runtime/install.sh | bash
195195
```
196-
Das Skript erkennt System & Architektur, verifiziert Checksums und aktualisiert vorhandene Installationen.
196+
The script detects system & architecture, verifies checksums, and updates existing installations.
197197
198198
### Linux/macOS
199199
```bash

CHANGELOG.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,60 @@
22

33
All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/).
44

5+
## [1.2.0] - 2026-01-22
6+
7+
### Added
8+
9+
- **Complete Debugging Infrastructure** with interactive step-through execution:
10+
- New `hypnoscript-compiler/src/debug.rs` module with `DebugState`, `StepMode`, `CallFrame`, `WatchExpression`, and `PauseReason` types
11+
- Breakpoint management (set, remove, clear, list)
12+
- Step modes: Step Into, Step Over, Step Out, Continue
13+
- Call stack tracking with function name, line number, and local variables
14+
- Watch expressions for monitoring values during debugging
15+
- Source code display with breakpoint markers
16+
17+
- **Debug REPL** (`hypnoscript-cli/src/debug_repl.rs`) for interactive debugging sessions:
18+
- Commands: `break`, `delete`, `continue`, `step`, `next`, `out`, `print`, `locals`, `stack`, `watch`, `list`, `where`, `help`, `quit`
19+
- Expression evaluation in current scope
20+
- Variable inspection (locals, globals, all variables)
21+
- Configurable via `DebugConfig` with initial breakpoints and watches
22+
23+
- **Debug Builtins** (`hypnoscript-runtime/src/debug_builtins.rs`):
24+
- `inspect(value)` - Returns value with type information
25+
- `typeOf(value)` - Returns the type name
26+
- `stackTrace()` - Returns formatted call stack
27+
- `dump(value)` - Prints detailed value representation
28+
- `assertEqual()`, `assertNotEqual()`, `assertTruthy()`, `assertFalsy()`, `assertNull()`, `assertNotNull()` - Assertions with messages
29+
- `time(label)`, `timeEnd(label)`, `measureTime(fn)` - Performance timing
30+
- `log()`, `warn()`, `error()`, `trace()` - Debug output levels
31+
- `breakpoint()` - Programmatic breakpoint
32+
33+
- **Extended CLI Debug Options** for the `exec` command:
34+
- `--debug` / `-d` - Enable interactive debug mode
35+
- `--breakpoints <LINES>` - Set initial breakpoints (comma-separated line numbers)
36+
- `--watch <EXPRS>` - Set initial watch expressions (comma-separated)
37+
- `--trace-file <PATH>` - Output trace information to file
38+
39+
- **Interpreter Debug Integration**:
40+
- `enable_debug_mode()` / `disable_debug_mode()` methods
41+
- `set_breakpoint()`, `remove_breakpoint()`, `has_breakpoint()`, `clear_breakpoints()`
42+
- `set_step_mode()`, `step_mode()` for stepping control
43+
- `add_watch()`, `remove_watch()` for watch expressions
44+
- `debug_locals()`, `debug_globals()`, `debug_all_variables()` for variable inspection
45+
- `debug_call_stack()`, `debug_source_context()` for execution context
46+
47+
### Changed
48+
49+
- Extended `Interpreter` struct with optional `debug_state` field
50+
- Updated CLI `exec` command to support debug mode with REPL integration
51+
52+
### Tests
53+
54+
- Added 9 new debug mode tests in `interpreter.rs`
55+
- Added comprehensive unit tests for `DebugState`, `DebugCommand`, `CallFrame`
56+
- Added unit tests for `DebugBuiltins` (assertions, timing, inspection)
57+
- Added unit tests for `DebugSession` and `DebugConfig`
58+
559
## [1.0.0] - 2025-11-15
660

761
### Added
@@ -30,3 +84,4 @@ All notable changes to this project will be documented in this file. The format
3084
- Successfully completed `cargo deny check` with cleaned-up license and advisory checks.
3185

3286
[1.0.0]: https://github.com/Kink-Development-Group/hyp-runtime/releases/tag/1.0.0
87+
[1.2.0]: https://github.com/Kink-Development-Group/hyp-runtime/releases/tag/1.2.0

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ members = [
99
]
1010

1111
[workspace.package]
12-
version = "1.0.0"
12+
version = "1.2.0"
1313
edition = "2024"
1414
authors = ["Kink Development Group"]
1515
license = "MIT"
@@ -18,11 +18,11 @@ repository = "https://github.com/Kink-Development-Group/hyp-runtime"
1818
[workspace.dependencies]
1919
# Core dependencies shared across workspace
2020
anyhow = "1.0"
21-
thiserror = "1.0"
22-
serde = { version = "1.0", features = ["derive"] }
23-
serde_json = "1.0"
24-
reqwest = { version = "0.11", default-features = false, features = ["json", "blocking", "rustls-tls"] }
25-
csv = "1.3"
21+
thiserror = "2.0.18"
22+
serde = { version = "1.0.228", features = ["derive"] }
23+
serde_json = "1.0.149"
24+
reqwest = { version = "0.13.1", default-features = false, features = ["json", "blocking", "query", "rustls"] }
25+
csv = "1.4.0"
2626

2727
[profile.release]
2828
opt-level = 3

0 commit comments

Comments
 (0)