From 79ba9b798a96ee5693332c4d3697c4a1d590301d Mon Sep 17 00:00:00 2001 From: Sergei Zharinov Date: Sun, 4 Jan 2026 23:46:21 -0300 Subject: [PATCH] refactor: improve trace and dump format for Call instructions --- crates/plotnik-lib/src/bytecode/dump.rs | 8 +- crates/plotnik-lib/src/bytecode/format.rs | 30 ++++- ..._codegen_tests__alternations_captured.snap | 4 +- ...n_tests__alternations_captured_tagged.snap | 4 +- ...gen_tests__alternations_in_quantifier.snap | 6 +- ...__codegen_tests__alternations_labeled.snap | 4 +- ...ts__alternations_no_internal_captures.snap | 2 +- ...en_tests__alternations_null_injection.snap | 4 +- ...ternations_tagged_with_definition_ref.snap | 6 +- ...codegen_tests__alternations_unlabeled.snap | 4 +- ...degen_tests__anchors_between_siblings.snap | 2 +- ...t__codegen_tests__anchors_first_child.snap | 2 +- ...it__codegen_tests__anchors_last_child.snap | 2 +- ...mit__codegen_tests__anchors_no_anchor.snap | 2 +- ...codegen_tests__anchors_with_anonymous.snap | 2 +- ...__emit__codegen_tests__captures_basic.snap | 2 +- ...codegen_tests__captures_deeply_nested.snap | 2 +- ...mit__codegen_tests__captures_multiple.snap | 2 +- ...__codegen_tests__captures_nested_flat.snap | 2 +- ...sts__captures_optional_wrapper_struct.snap | 4 +- ..._codegen_tests__captures_struct_scope.snap | 2 +- ...egen_tests__captures_with_type_custom.snap | 2 +- ...egen_tests__captures_with_type_string.snap | 2 +- ...odegen_tests__captures_wrapper_struct.snap | 4 +- ...tests__comprehensive_multi_definition.snap | 10 +- ...__codegen_tests__definitions_multiple.snap | 4 +- ...gen_tests__definitions_nested_capture.snap | 6 +- ..._codegen_tests__definitions_reference.snap | 6 +- ...it__codegen_tests__definitions_single.snap | 2 +- ...it__codegen_tests__fields_alternation.snap | 6 +- ..._emit__codegen_tests__fields_multiple.snap | 2 +- ...__emit__codegen_tests__fields_negated.snap | 2 +- ...b__emit__codegen_tests__fields_single.snap | 2 +- ..._emit__codegen_tests__nodes_anonymous.snap | 2 +- ...lib__emit__codegen_tests__nodes_error.snap | 2 +- ...b__emit__codegen_tests__nodes_missing.snap | 2 +- ...lib__emit__codegen_tests__nodes_named.snap | 2 +- ...it__codegen_tests__nodes_wildcard_any.snap | 2 +- ...__codegen_tests__nodes_wildcard_named.snap | 2 +- ...__codegen_tests__optional_first_child.snap | 4 +- ...odegen_tests__optional_null_injection.snap | 4 +- ..._tests__quantifiers_first_child_array.snap | 4 +- ...__codegen_tests__quantifiers_optional.snap | 4 +- ...tests__quantifiers_optional_nongreedy.snap | 4 +- ...emit__codegen_tests__quantifiers_plus.snap | 4 +- ...gen_tests__quantifiers_plus_nongreedy.snap | 4 +- ..._tests__quantifiers_repeat_navigation.snap | 4 +- ...s__quantifiers_sequence_in_called_def.snap | 10 +- ...emit__codegen_tests__quantifiers_star.snap | 4 +- ...gen_tests__quantifiers_star_nongreedy.snap | 4 +- ...degen_tests__quantifiers_struct_array.snap | 4 +- ...emit__codegen_tests__recursion_simple.snap | 6 +- ...sts__recursion_with_structured_result.snap | 10 +- ..._emit__codegen_tests__sequences_basic.snap | 2 +- ...odegen_tests__sequences_in_quantifier.snap | 4 +- ...emit__codegen_tests__sequences_nested.snap | 2 +- ...odegen_tests__sequences_with_captures.snap | 2 +- crates/plotnik-lib/src/engine/trace.rs | 71 ++++++----- docs/binary-format/07-dump-format.md | 20 +-- docs/binary-format/08-trace-format.md | 117 +++++++++++------- docs/tree-navigation.md | 2 +- 61 files changed, 255 insertions(+), 191 deletions(-) diff --git a/crates/plotnik-lib/src/bytecode/dump.rs b/crates/plotnik-lib/src/bytecode/dump.rs index 50ee3185..94e5450f 100644 --- a/crates/plotnik-lib/src/bytecode/dump.rs +++ b/crates/plotnik-lib/src/bytecode/dump.rs @@ -542,7 +542,13 @@ fn format_call( .unwrap_or_else(|| format!("@{:0w$}", call.target.0, w = step_width)); // Definition name in call is blue let content = format!("{field_part}({}{}{})", c.blue, target_name, c.reset); - let successors = format!("{} ⯇", format_step(call.next, ctx, step_width)); + // Format as "target : return" with numeric IDs + let successors = format!( + "{:0w$} : {:0w$}", + call.target.get(), + call.next.get(), + w = step_width + ); let base = format!("{prefix}{content}"); builder.pad_successors(base, &successors) diff --git a/crates/plotnik-lib/src/bytecode/format.rs b/crates/plotnik-lib/src/bytecode/format.rs index 8f41647a..fc025f7e 100644 --- a/crates/plotnik-lib/src/bytecode/format.rs +++ b/crates/plotnik-lib/src/bytecode/format.rs @@ -86,7 +86,7 @@ impl Symbol { /// | --------------- | ------- | ----------------------------------- | /// | Stay | (blank) | No movement, 5 spaces | /// | Stay (epsilon) | ε | Only when no type/field constraints | -/// | StayExact | !!! | Stay at position, exact match only | +/// | StayExact | ! | Stay at position, exact match only | /// | Down | ▽ | First child, skip any | /// | DownSkip | !▽ | First child, skip trivia | /// | DownExact | !!▽ | First child, exact | @@ -99,7 +99,7 @@ impl Symbol { pub fn nav_symbol(nav: Nav) -> Symbol { match nav { Nav::Stay => Symbol::EMPTY, - Nav::StayExact => Symbol::new(" ", "!!!", " "), + Nav::StayExact => Symbol::new(" ", "!", " "), Nav::Down => Symbol::new(" ", "▽", " "), Nav::DownSkip => Symbol::new(" !", "▽", " "), Nav::DownExact => Symbol::new("!!", "▽", " "), @@ -278,12 +278,34 @@ impl LineBuilder { /// Ensures at least 2 spaces between content and successors. pub fn pad_successors(&self, base: String, successors: &str) -> String { let padding = cols::TOTAL_WIDTH - .saturating_sub(base.chars().count()) + .saturating_sub(display_width(&base)) .max(2); format!("{base}{:padding$}{successors}", "") } } +/// Calculate display width of a string, ignoring ANSI escape sequences. +/// +/// ANSI sequences have the form `\x1b[...m` and render as zero-width. +fn display_width(s: &str) -> usize { + let mut width = 0; + let mut in_escape = false; + + for c in s.chars() { + if in_escape { + if c == 'm' { + in_escape = false; + } + } else if c == '\x1b' { + in_escape = true; + } else { + width += 1; + } + } + + width +} + // ============================================================================= // Effect Formatting // ============================================================================= @@ -316,7 +338,7 @@ mod tests { fn test_symbol_format() { assert_eq!(Symbol::EMPTY.format(), " "); assert_eq!(Symbol::EPSILON.format(), " ε "); - assert_eq!(nav_symbol(Nav::StayExact).format(), " !!! "); + assert_eq!(nav_symbol(Nav::StayExact).format(), " ! "); assert_eq!(nav_symbol(Nav::Down).format(), " ▽ "); assert_eq!(nav_symbol(Nav::DownSkip).format(), " !▽ "); assert_eq!(nav_symbol(Nav::DownExact).format(), "!!▽ "); diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_captured.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_captured.snap index 6a5d681c..82f9c0fd 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_captured.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_captured.snap @@ -35,5 +35,5 @@ Test: 04 ε 09, 11 06 ▶ 07 ε [EndObj] 06 - 09 !!! (identifier) [Node Set(M0)] 07 - 11 !!! (number) [Node Set(M0)] 07 + 09 ! (identifier) [Node Set(M0)] 07 + 11 ! (number) [Node Set(M0)] 07 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_captured_tagged.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_captured_tagged.snap index b4a2313e..51a1ed8e 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_captured_tagged.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_captured_tagged.snap @@ -47,8 +47,8 @@ Test: 06 ▶ 07 ε [EndObj] 06 09 ε [EndEnum Set(M4)] 07 - 11 !!! (identifier) [Node Set(M0)] 09 + 11 ! (identifier) [Node Set(M0)] 09 13 ε [Enum(M2)] 11 15 ε [EndEnum Set(M4)] 07 - 17 !!! (number) [Node Set(M1)] 15 + 17 ! (number) [Node Set(M1)] 15 19 ε [Enum(M3)] 17 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_in_quantifier.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_in_quantifier.snap index 3bbc448a..289f08d0 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_in_quantifier.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_in_quantifier.snap @@ -48,7 +48,7 @@ Test = 01 :: T6 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (object) 05 + 04 ! (object) 05 05 ε [Arr] 07 07 ε 42, 19 09 ε [EndArr Set(M5)] 11 @@ -59,10 +59,10 @@ Test: 17 ε [EndObj] 16 19 ε [EndArr Set(M5)] 17 21 ε [EndEnum Set(M4)] 12 - 23 !!! (pair) [Node Set(M0)] 21 + 23 ! (pair) [Node Set(M0)] 21 25 ε [Enum(M2)] 23 27 ε [EndEnum Set(M4)] 12 - 29 !!! (shorthand_property_identifier) [Node Set(M1)] 27 + 29 ! (shorthand_property_identifier) [Node Set(M1)] 27 31 ε [Enum(M3)] 29 33 ε 25, 31 35 ε [Obj] 33 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_labeled.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_labeled.snap index eadc7d37..401e3d7f 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_labeled.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_labeled.snap @@ -45,8 +45,8 @@ Test: 02 ε 09, 15 04 ▶ 05 ε [EndEnum] 04 - 07 !!! (identifier) [Node Set(M0)] 05 + 07 ! (identifier) [Node Set(M0)] 05 09 ε [Enum(M2)] 07 11 ε [EndEnum] 04 - 13 !!! (number) [Node Set(M1)] 11 + 13 ! (number) [Node Set(M1)] 11 15 ε [Enum(M3)] 13 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_no_internal_captures.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_no_internal_captures.snap index 60bedc69..daa67209 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_no_internal_captures.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_no_internal_captures.snap @@ -33,7 +33,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (program) 05 + 04 ! (program) 05 05 ε 10, 12 07 ▶ 08 ε [EndObj] 07 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_null_injection.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_null_injection.snap index 1da1ecff..ef9668a8 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_null_injection.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_null_injection.snap @@ -42,7 +42,7 @@ Test: 04 ε 11, 15 06 ▶ 07 ε [EndObj] 06 - 09 !!! (identifier) [Node Set(M0)] 07 + 09 ! (identifier) [Node Set(M0)] 07 11 ε [Null Set(M1)] 09 - 13 !!! (number) [Node Set(M1)] 07 + 13 ! (number) [Node Set(M1)] 07 15 ε [Null Set(M0)] 13 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_tagged_with_definition_ref.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_tagged_with_definition_ref.snap index 59d7ee12..55c5cf17 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_tagged_with_definition_ref.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_tagged_with_definition_ref.snap @@ -47,7 +47,7 @@ Test = 09 :: T4 Inner: 01 ε 02 02 ε [Obj] 04 - 04 !!! (identifier) [Node Set(M0)] 06 + 04 ! (identifier) [Node Set(M0)] 06 06 ε [EndObj] 08 08 ▶ @@ -58,8 +58,8 @@ Test: 14 ▶ 15 ε [EndObj] 14 17 ε [EndEnum Set(M4)] 15 - 19 !!! (Inner) 17 ⯇ + 19 ! (Inner) 01 : 17 20 ε [Enum(M2)] 19 22 ε [EndEnum Set(M4)] 15 - 24 !!! (number) [Node Set(M1)] 22 + 24 ! (number) [Node Set(M1)] 22 26 ε [Enum(M3)] 24 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_unlabeled.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_unlabeled.snap index 3aea3a52..daf30eb2 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_unlabeled.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__alternations_unlabeled.snap @@ -42,7 +42,7 @@ Test: 04 ε 11, 15 06 ▶ 07 ε [EndObj] 06 - 09 !!! (identifier) [Node Set(M0)] 07 + 09 ! (identifier) [Node Set(M0)] 07 11 ε [Null Set(M1)] 09 - 13 !!! (string) [Node Set(M1)] 07 + 13 ! (string) [Node Set(M1)] 07 15 ε [Null Set(M0)] 13 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_between_siblings.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_between_siblings.snap index 9d27fbe3..ba6885db 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_between_siblings.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_between_siblings.snap @@ -29,7 +29,7 @@ Test = 1 :: T0 Test: 1 ε 2 - 2 !!! (parent) 3 + 2 ! (parent) 3 3 ▽ (a) 4 4 !▷ (b) 5 5 △ 6 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_first_child.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_first_child.snap index e6d98fc1..ad0a8b2c 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_first_child.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_first_child.snap @@ -28,7 +28,7 @@ Test = 1 :: T0 Test: 1 ε 2 - 2 !!! (parent) 3 + 2 ! (parent) 3 3 !▽ (first) 4 4 △ 5 5 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_last_child.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_last_child.snap index 71b1a2f1..a26f2ee8 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_last_child.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_last_child.snap @@ -28,7 +28,7 @@ Test = 1 :: T0 Test: 1 ε 2 - 2 !!! (parent) 3 + 2 ! (parent) 3 3 ▽ (last) 4 4 !△ 5 5 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_no_anchor.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_no_anchor.snap index 521ada88..d073a25a 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_no_anchor.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_no_anchor.snap @@ -29,7 +29,7 @@ Test = 1 :: T0 Test: 1 ε 2 - 2 !!! (parent) 3 + 2 ! (parent) 3 3 ▽ (a) 4 4 ▷ (b) 5 5 △ 6 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_with_anonymous.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_with_anonymous.snap index b984bca7..29f996b7 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_with_anonymous.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__anchors_with_anonymous.snap @@ -29,7 +29,7 @@ Test = 1 :: T0 Test: 1 ε 2 - 2 !!! (parent) 3 + 2 ! (parent) 3 3 ▽ (+) 4 4 !!▷ (next) 5 5 △ 6 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_basic.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_basic.snap index bed0d294..51b89780 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_basic.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_basic.snap @@ -31,6 +31,6 @@ Test = 1 :: T1 Test: 1 ε 2 2 ε [Obj] 4 - 4 !!! (identifier) [Node Set(M0)] 6 + 4 ! (identifier) [Node Set(M0)] 6 6 ε [EndObj] 8 8 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_deeply_nested.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_deeply_nested.snap index 61ec13b9..ca65b2e3 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_deeply_nested.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_deeply_nested.snap @@ -45,7 +45,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (a) [Node Set(M0)] 06 + 04 ! (a) [Node Set(M0)] 06 06 ▽ (b) [Node Set(M1)] 08 08 ▽ (c) [Node Set(M2)] 10 10 ▽ (d) [Node Set(M3)] 12 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_multiple.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_multiple.snap index afe8f322..2d390282 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_multiple.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_multiple.snap @@ -39,7 +39,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (binary_expression) 05 + 04 ! (binary_expression) 05 05 ▽ (identifier) [Node Set(M0)] 07 07 ▷ (number) [Node Set(M1)] 09 09 △ 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_nested_flat.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_nested_flat.snap index 6c77a135..60d9a060 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_nested_flat.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_nested_flat.snap @@ -39,7 +39,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (a) [Node Set(M0)] 06 + 04 ! (a) [Node Set(M0)] 06 06 ▽ (b) [Node Set(M1)] 08 08 ▽ (c) [Node Set(M2)] 10 10 △ 11 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_optional_wrapper_struct.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_optional_wrapper_struct.snap index 15625c48..2bf10c39 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_optional_wrapper_struct.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_optional_wrapper_struct.snap @@ -47,10 +47,10 @@ Test: 09 ε [EndObj] 08 11 ε [EndObj Set(M2)] 09 13 ε [EndObj Set(M1)] 11 - 15 !!! (identifier) [Node Set(M0)] 13 + 15 ! (identifier) [Node Set(M0)] 13 17 ε [Obj] 15 19 ε [Null Set(M1)] 11 21 ▷ 24 22 ε 21, 19 24 ε 17, 22 - 26 !!! 24 + 26 ! 24 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_struct_scope.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_struct_scope.snap index 61bc22e2..643a1b6e 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_struct_scope.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_struct_scope.snap @@ -40,7 +40,7 @@ Test: 01 ε 02 02 ε [Obj] 04 04 ε [Obj] 06 - 06 !!! (a) [Node Set(M0)] 08 + 06 ! (a) [Node Set(M0)] 08 08 ▷ (b) [Node Set(M1)] 10 10 ε [EndObj Set(M2)] 12 12 ε [EndObj] 14 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_with_type_custom.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_with_type_custom.snap index da6fb6da..3f3180cd 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_with_type_custom.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_with_type_custom.snap @@ -34,6 +34,6 @@ Test = 1 :: T2 Test: 1 ε 2 2 ε [Obj] 4 - 4 !!! (identifier) [Node Set(M0)] 6 + 4 ! (identifier) [Node Set(M0)] 6 6 ε [EndObj] 8 8 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_with_type_string.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_with_type_string.snap index c2b9499d..33118201 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_with_type_string.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_with_type_string.snap @@ -31,6 +31,6 @@ Test = 1 :: T1 Test: 1 ε 2 2 ε [Obj] 4 - 4 !!! (identifier) [Text Set(M0)] 6 + 4 ! (identifier) [Text Set(M0)] 6 6 ε [EndObj] 8 8 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_wrapper_struct.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_wrapper_struct.snap index 5bbcf4f0..af280b4f 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_wrapper_struct.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__captures_wrapper_struct.snap @@ -54,13 +54,13 @@ Test: 15 ε [EndArr Set(M3)] 13 17 ε [EndObj Set(M2)] 08 19 ▷ (number) [Node Set(M1)] 17 - 21 !!! (identifier) [Node Set(M0)] 19 + 21 ! (identifier) [Node Set(M0)] 19 23 ε [Obj] 21 25 ε [Obj] 23 27 ▷ 30 28 ε 27, 15 30 ε 25, 28 - 32 !!! 30 + 32 ! 30 33 ▷ 36 34 ε 33, 15 36 ε 25, 34 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__comprehensive_multi_definition.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__comprehensive_multi_definition.snap index 08213208..cfde64e0 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__comprehensive_multi_definition.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__comprehensive_multi_definition.snap @@ -67,7 +67,7 @@ Ident = 01 :: T02 Ident: 01 ε 02 02 ε [Obj] 04 - 04 !!! (identifier) [Text Set(M0)] 06 + 04 ! (identifier) [Text Set(M0)] 06 06 ε [EndObj] 08 08 ▶ @@ -78,17 +78,17 @@ Expression: Assignment: 12 ε 13 13 ε [Obj] 15 - 15 !!! (assignment_expression) 16 + 15 ! (assignment_expression) 16 16 ▽ left: (identifier) [Node Set(M6)] 18 - 18 ▷ right: (Expression) 19 ⯇ + 18 ▷ right: (Expression) 09 : 19 19 ε [Set(M5)] 21 21 △ 22 22 ε [EndObj] 24 24 ▶ 25 ▶ 26 ε [EndEnum] 25 - 28 !!! (number) [Node Set(M1)] 26 + 28 ! (number) [Node Set(M1)] 26 30 ε [Enum(M3)] 28 32 ε [EndEnum] 25 - 34 !!! (identifier) [Node Set(M2)] 32 + 34 ! (identifier) [Node Set(M2)] 32 36 ε [Enum(M4)] 34 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_multiple.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_multiple.snap index acfe98bc..9c54def7 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_multiple.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_multiple.snap @@ -39,13 +39,13 @@ Foo = 01 :: T1 Foo: 01 ε 02 02 ε [Obj] 04 - 04 !!! (identifier) [Node Set(M0)] 06 + 04 ! (identifier) [Node Set(M0)] 06 06 ε [EndObj] 08 08 ▶ Bar: 09 ε 10 10 ε [Obj] 12 - 12 !!! (string) [Node Set(M1)] 14 + 12 ! (string) [Node Set(M1)] 14 14 ε [EndObj] 16 16 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_nested_capture.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_nested_capture.snap index e199cecb..b2e77d44 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_nested_capture.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_nested_capture.snap @@ -45,7 +45,7 @@ Outer = 11 :: T4 Inner: 01 ε 02 02 ε [Obj] 04 - 04 !!! (call) 05 + 04 ! (call) 05 05 ▽ (identifier) [Node Set(M0)] 07 07 △ 08 08 ε [EndObj] 10 @@ -54,7 +54,7 @@ Inner: Outer: 11 ε 12 12 ε [Obj] 14 - 14 !!! (parent) 15 + 14 ! (parent) 15 15 ε [Arr] 17 17 ε 41, 29 19 ε [EndArr Set(M3)] 21 @@ -65,7 +65,7 @@ Outer: 27 ε [EndObj] 26 29 ε [EndArr Set(M3)] 27 31 ε [Set(M2)] 22 - 33 !!! (Inner) 31 ⯇ + 33 ! (Inner) 01 : 31 34 ε [Obj] 33 36 ▷ 39 37 ε 36, 29 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_reference.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_reference.snap index f4e6b252..d10ee140 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_reference.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_reference.snap @@ -49,14 +49,14 @@ Expression: Root: 06 ε 07 07 ε [Obj] 09 - 09 !!! (function_declaration) 10 + 09 ! (function_declaration) 10 10 ▽ name: (identifier) [Node Set(M2)] 12 12 △ 13 13 ε [EndObj] 15 15 ▶ 16 ▶ 17 ε [EndObj] 16 - 19 !!! (identifier) [Node Set(M0)] 17 + 19 ! (identifier) [Node Set(M0)] 17 21 ε [Null Set(M1)] 19 - 23 !!! (number) [Node Set(M1)] 17 + 23 ! (number) [Node Set(M1)] 17 25 ε [Null Set(M0)] 23 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_single.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_single.snap index b9aa992b..c5a2083d 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_single.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__definitions_single.snap @@ -31,6 +31,6 @@ Foo = 1 :: T1 Foo: 1 ε 2 2 ε [Obj] 4 - 4 !!! (identifier) [Node Set(M0)] 6 + 4 ! (identifier) [Node Set(M0)] 6 6 ε [EndObj] 8 8 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_alternation.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_alternation.snap index 1cb871c8..ccf9db27 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_alternation.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_alternation.snap @@ -41,13 +41,13 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (call_expression) 05 + 04 ! (call_expression) 05 05 ▽ function: _ 06 06 ε 13, 17 08 ▶ 09 ε [EndObj] 08 - 11 !!! (identifier) [Node Set(M0)] 19 + 11 ! (identifier) [Node Set(M0)] 19 13 ε [Null Set(M1)] 11 - 15 !!! (number) [Node Set(M1)] 19 + 15 ! (number) [Node Set(M1)] 19 17 ε [Null Set(M0)] 15 19 △ 09 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_multiple.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_multiple.snap index 52187130..87a21917 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_multiple.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_multiple.snap @@ -39,7 +39,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (binary_expression) 05 + 04 ! (binary_expression) 05 05 ▽ left: _ [Node Set(M0)] 07 07 ▷ right: _ [Node Set(M1)] 09 09 △ 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_negated.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_negated.snap index 3d3959fa..037fe2d2 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_negated.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_negated.snap @@ -33,7 +33,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! -type_parameters (function_declaration) 06 + 04 ! -type_parameters (function_declaration) 06 06 ▽ name: (identifier) [Node Set(M0)] 08 08 △ 09 09 ε [EndObj] 11 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_single.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_single.snap index 5da09dbb..f6d37586 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_single.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__fields_single.snap @@ -32,7 +32,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (function_declaration) 05 + 04 ! (function_declaration) 05 05 ▽ name: (identifier) [Node Set(M0)] 07 07 △ 08 08 ε [EndObj] 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_anonymous.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_anonymous.snap index d38c9541..64ef55cc 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_anonymous.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_anonymous.snap @@ -32,7 +32,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (binary_expression) 05 + 04 ! (binary_expression) 05 05 ▽ (+) [Node Set(M0)] 07 07 △ 08 08 ε [EndObj] 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_error.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_error.snap index 5f7551b3..6ab2ae7c 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_error.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_error.snap @@ -31,6 +31,6 @@ Test = 1 :: T1 Test: 1 ε 2 2 ε [Obj] 4 - 4 !!! (ERROR) [Node Set(M0)] 6 + 4 ! (ERROR) [Node Set(M0)] 6 6 ε [EndObj] 8 8 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_missing.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_missing.snap index 28d85e67..4367053c 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_missing.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_missing.snap @@ -31,6 +31,6 @@ Test = 1 :: T1 Test: 1 ε 2 2 ε [Obj] 4 - 4 !!! (MISSING) [Node Set(M0)] 6 + 4 ! (MISSING) [Node Set(M0)] 6 6 ε [EndObj] 8 8 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_named.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_named.snap index ebe2a889..0168fe8b 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_named.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_named.snap @@ -31,6 +31,6 @@ Test = 1 :: T1 Test: 1 ε 2 2 ε [Obj] 4 - 4 !!! (identifier) [Node Set(M0)] 6 + 4 ! (identifier) [Node Set(M0)] 6 6 ε [EndObj] 8 8 ▶ diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_wildcard_any.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_wildcard_any.snap index dc526594..580a5c3d 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_wildcard_any.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_wildcard_any.snap @@ -31,7 +31,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (pair) 05 + 04 ! (pair) 05 05 ▽ key: _ [Node Set(M0)] 07 07 △ 08 08 ε [EndObj] 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_wildcard_named.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_wildcard_named.snap index ce0db88e..b5057728 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_wildcard_named.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__nodes_wildcard_named.snap @@ -31,7 +31,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (pair) 05 + 04 ! (pair) 05 05 ▽ key: _ [Node Set(M0)] 07 07 △ 08 08 ε [EndObj] 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__optional_first_child.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__optional_first_child.snap index 8026b80b..704efcb6 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__optional_first_child.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__optional_first_child.snap @@ -40,14 +40,14 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (program) 05 + 04 ! (program) 05 05 ε 23, 14 07 ▶ 08 ε [EndObj] 07 10 ▽ (number) [Node Set(M1)] 24 12 ▷ (number) [Node Set(M1)] 24 14 ε [Null Set(M0)] 10 - 16 !!! (identifier) [Node Set(M0)] 12 + 16 ! (identifier) [Node Set(M0)] 12 18 ▷ 21 19 ε 18, 14 21 ε 16, 19 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__optional_null_injection.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__optional_null_injection.snap index e578dd1a..0835daba 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__optional_null_injection.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__optional_null_injection.snap @@ -33,9 +33,9 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (function_declaration) 05 + 04 ! (function_declaration) 05 05 ε 20, 13 - 07 !!! (decorator) [Node Set(M0)] 09 + 07 ! (decorator) [Node Set(M0)] 09 09 △ 11 10 ▶ 11 ε [EndObj] 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_first_child_array.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_first_child_array.snap index 4913917b..40e9d7cc 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_first_child_array.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_first_child_array.snap @@ -40,10 +40,10 @@ Test = 01 :: T2 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (array) 05 + 04 ! (array) 05 05 ε [Arr] 07 07 ε 29, 22 - 09 !!! (identifier) [Node Push] 11 + 09 ! (identifier) [Node Push] 11 11 ε 35, 20 13 ▶ 14 ε [EndObj] 13 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_optional.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_optional.snap index e578dd1a..0835daba 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_optional.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_optional.snap @@ -33,9 +33,9 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (function_declaration) 05 + 04 ! (function_declaration) 05 05 ε 20, 13 - 07 !!! (decorator) [Node Set(M0)] 09 + 07 ! (decorator) [Node Set(M0)] 09 09 △ 11 10 ▶ 11 ε [EndObj] 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_optional_nongreedy.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_optional_nongreedy.snap index 3c29e256..58a21955 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_optional_nongreedy.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_optional_nongreedy.snap @@ -33,9 +33,9 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (function_declaration) 05 + 04 ! (function_declaration) 05 05 ε 13, 20 - 07 !!! (decorator) [Node Set(M0)] 09 + 07 ! (decorator) [Node Set(M0)] 09 09 △ 11 10 ▶ 11 ε [EndObj] 10 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_plus.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_plus.snap index db8d7b20..dfa9f412 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_plus.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_plus.snap @@ -33,8 +33,8 @@ Test: 01 ε 02 02 ε [Obj] 04 04 ε [Arr] 06 - 06 !!! 17 - 07 !!! (identifier) [Node Push] 09 + 06 ! 17 + 07 ! (identifier) [Node Push] 09 09 ε 24, 14 11 ▶ 12 ε [EndObj] 11 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_plus_nongreedy.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_plus_nongreedy.snap index 6f10bac5..0447cb3c 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_plus_nongreedy.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_plus_nongreedy.snap @@ -33,8 +33,8 @@ Test: 01 ε 02 02 ε [Obj] 04 04 ε [Arr] 06 - 06 !!! 17 - 07 !!! (identifier) [Node Push] 09 + 06 ! 17 + 07 ! (identifier) [Node Push] 09 09 ε 14, 24 11 ▶ 12 ε [EndObj] 11 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_repeat_navigation.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_repeat_navigation.snap index 08f9c14a..25c83a57 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_repeat_navigation.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_repeat_navigation.snap @@ -33,12 +33,12 @@ Test = 01 :: T2 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (function_declaration) 05 + 04 ! (function_declaration) 05 05 ε [Arr] 07 07 ε 26, 19 09 ε [EndArr Set(M0)] 11 11 △ 17 - 12 !!! (decorator) [Node Push] 14 + 12 ! (decorator) [Node Push] 14 14 ε 32, 09 16 ▶ 17 ε [EndObj] 16 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_sequence_in_called_def.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_sequence_in_called_def.snap index a03f9285..0a272fde 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_sequence_in_called_def.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_sequence_in_called_def.snap @@ -48,7 +48,7 @@ Test = 16 :: T4 Item: 01 ε 02 02 ε [Obj] 04 - 04 !!! (identifier) [Node Set(M0)] 06 + 04 ! (identifier) [Node Set(M0)] 06 06 ε [EndObj] 08 08 ▶ @@ -61,8 +61,8 @@ Collect: Test: 16 ε 17 17 ε [Obj] 19 - 19 !!! (parent) 20 - 20 ▽ (Collect) 21 ⯇ + 19 ! (parent) 20 + 20 ▽ (Collect) 09 : 21 21 △ 22 22 ε [EndObj] 24 24 ▶ @@ -72,12 +72,12 @@ Test: 30 ε [EndObj] 29 32 ε [EndArr Set(M3)] 30 34 ε [Set(M2)] 25 - 36 !!! (Item) 34 ⯇ + 36 ! (Item) 01 : 34 37 ε [Obj] 36 39 ▷ 42 40 ε 39, 32 42 ε 37, 40 - 44 !!! 42 + 44 ! 42 45 ▷ 48 46 ε 45, 32 48 ε 37, 46 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_star.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_star.snap index 16035d13..80347c9e 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_star.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_star.snap @@ -34,7 +34,7 @@ Test: 02 ε [Obj] 04 04 ε [Arr] 06 06 ε 22, 15 - 08 !!! (identifier) [Node Push] 10 + 08 ! (identifier) [Node Push] 10 10 ε 28, 15 12 ▶ 13 ε [EndObj] 12 @@ -42,7 +42,7 @@ Test: 17 ▷ 20 18 ε 17, 15 20 ε 08, 18 - 22 !!! 20 + 22 ! 20 23 ▷ 26 24 ε 23, 15 26 ε 08, 24 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_star_nongreedy.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_star_nongreedy.snap index da0fdddc..d7e90363 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_star_nongreedy.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_star_nongreedy.snap @@ -34,7 +34,7 @@ Test: 02 ε [Obj] 04 04 ε [Arr] 06 06 ε 15, 22 - 08 !!! (identifier) [Node Push] 10 + 08 ! (identifier) [Node Push] 10 10 ε 15, 28 12 ▶ 13 ε [EndObj] 12 @@ -42,7 +42,7 @@ Test: 17 ▷ 20 18 ε 15, 17 20 ε 18, 08 - 22 !!! 20 + 22 ! 20 23 ▷ 26 24 ε 15, 23 26 ε 24, 08 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_struct_array.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_struct_array.snap index adefc3b2..6ba02eeb 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_struct_array.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__quantifiers_struct_array.snap @@ -43,7 +43,7 @@ Test = 01 :: T3 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (array) 05 + 04 ! (array) 05 05 ε [Arr] 07 07 ε 32, 19 09 ε [EndArr Set(M2)] 11 @@ -54,7 +54,7 @@ Test: 17 ε [EndObj] 16 19 ε [EndArr Set(M2)] 17 21 ▷ (number) [Node Set(M1)] 12 - 23 !!! (identifier) [Node Set(M0)] 21 + 23 ! (identifier) [Node Set(M0)] 21 25 ε [Obj] 23 27 ▷ 30 28 ε 27, 19 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__recursion_simple.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__recursion_simple.snap index 3133c420..db3f46da 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__recursion_simple.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__recursion_simple.snap @@ -57,10 +57,10 @@ Expr: 06 △ 14 07 ▶ 08 ε [EndEnum] 07 - 10 !!! (number) [Text Set(M0)] 08 + 10 ! (number) [Text Set(M0)] 08 12 ε [Enum(M3)] 10 14 ε [EndEnum] 07 - 16 ▷ arguments: (Expr) 04 ⯇ + 16 ▷ arguments: (Expr) 01 : 04 17 ▽ function: (identifier) [Node Set(M1)] 16 - 19 !!! (call_expression) 17 + 19 ! (call_expression) 17 20 ε [Enum(M4)] 19 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__recursion_with_structured_result.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__recursion_with_structured_result.snap index 3b2f2197..52ca2c6a 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__recursion_with_structured_result.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__recursion_with_structured_result.snap @@ -66,8 +66,8 @@ Expr: Test: 04 ε 05 05 ε [Obj] 07 - 07 !!! (program) 08 - 08 ▽ (Expr) 09 ⯇ + 07 ! (program) 08 + 08 ▽ (Expr) 01 : 09 09 ε [Set(M5)] 11 11 △ 12 12 ε [EndObj] 14 @@ -76,10 +76,10 @@ Test: 17 △ 25 18 ▶ 19 ε [EndEnum] 18 - 21 !!! (number) [Text Set(M0)] 19 + 21 ! (number) [Text Set(M0)] 19 23 ε [Enum(M3)] 21 25 ε [EndEnum] 18 - 27 ▷ arguments: (Expr) 15 ⯇ + 27 ▷ arguments: (Expr) 01 : 15 28 ▽ function: (identifier) [Node Set(M1)] 27 - 30 !!! (call_expression) 28 + 30 ! (call_expression) 28 31 ε [Enum(M4)] 30 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_basic.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_basic.snap index 1cc34458..9cde6663 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_basic.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_basic.snap @@ -29,7 +29,7 @@ Test = 1 :: T0 Test: 1 ε 2 - 2 !!! (parent) 3 + 2 ! (parent) 3 3 ▽ (a) 4 4 ▷ (b) 5 5 △ 6 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_in_quantifier.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_in_quantifier.snap index 3d797e54..ade060de 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_in_quantifier.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_in_quantifier.snap @@ -34,7 +34,7 @@ Test = 01 :: T2 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (parent) 05 + 04 ! (parent) 05 05 ε [Arr] 07 07 ε 27, 19 09 ε [EndArr Set(M0)] 11 @@ -44,7 +44,7 @@ Test: 16 ▶ 17 ε [EndObj] 16 19 ε [EndArr Set(M0)] 17 - 21 !!! (a) 12 + 21 ! (a) 12 22 ▷ 25 23 ε 22, 19 25 ε 21, 23 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_nested.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_nested.snap index 9cd04328..7b49711d 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_nested.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_nested.snap @@ -31,7 +31,7 @@ Test = 1 :: T0 Test: 1 ε 2 - 2 !!! (parent) 3 + 2 ! (parent) 3 3 ▽ (a) 4 4 ▷ (b) 5 5 ▷ (c) 6 diff --git a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_with_captures.snap b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_with_captures.snap index 8ff88f3a..0063b63f 100644 --- a/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_with_captures.snap +++ b/crates/plotnik-lib/src/emit/snapshots/plotnik_lib__emit__codegen_tests__sequences_with_captures.snap @@ -37,7 +37,7 @@ Test = 01 :: T1 Test: 01 ε 02 02 ε [Obj] 04 - 04 !!! (parent) 05 + 04 ! (parent) 05 05 ▽ (a) [Node Set(M0)] 07 07 ▷ (b) [Node Set(M1)] 09 09 △ 10 diff --git a/crates/plotnik-lib/src/engine/trace.rs b/crates/plotnik-lib/src/engine/trace.rs index 9faf46a8..b3579db9 100644 --- a/crates/plotnik-lib/src/engine/trace.rs +++ b/crates/plotnik-lib/src/engine/trace.rs @@ -24,8 +24,8 @@ use std::num::NonZeroU16; use arborium_tree_sitter::Node; use crate::bytecode::{ - cols, format_effect, nav_symbol, trace, truncate_text, width_for_count, EffectOpcode, - InstructionView, LineBuilder, MatchView, Module, Nav, Symbol, + cols, format_effect, trace, truncate_text, width_for_count, EffectOpcode, InstructionView, + LineBuilder, MatchView, Module, Nav, Symbol, }; use crate::Colors; @@ -177,6 +177,8 @@ pub struct PrintTracer<'s> { checkpoint_ips: Vec, /// Stack of definition names (for return display). definition_stack: Vec, + /// Pending return instruction IP (for consolidated return line). + pending_return_ip: Option, /// Step width for formatting. step_width: usize, /// Color palette. @@ -229,6 +231,7 @@ impl<'s> PrintTracer<'s> { entrypoint_by_ip, checkpoint_ips: Vec::new(), definition_stack: Vec::new(), + pending_return_ip: None, step_width, colors, } @@ -385,28 +388,42 @@ impl<'s> PrintTracer<'s> { let prefix = format!("{:step_area$}{} ", "", symbol.format()); self.lines.push(format!("{prefix}{content}")); } + + /// Format definition name in parentheses (blue). + fn format_def_name(&self, name: &str) -> String { + let c = self.colors; + format!("({}{}{})", c.blue, name, c.reset) + } + + /// Format definition label with colon (blue). + fn format_def_label(&self, name: &str) -> String { + let c = self.colors; + format!("{}{}{}:", c.blue, name, c.reset) + } } impl Tracer for PrintTracer<'_> { fn trace_instruction(&mut self, ip: u16, instr: &InstructionView<'_>) { - let colors = &self.colors; match instr { InstructionView::Match(m) => { - let symbol = format_match_symbol(m); + // Show ε for epsilon transitions, empty otherwise (nav shown in sublines) + let symbol = if m.is_epsilon() { + Symbol::EPSILON + } else { + Symbol::EMPTY + }; let content = self.format_match_content(m); let successors = format_match_successors(m); self.add_instruction(ip, symbol, &content, &successors); } InstructionView::Call(c) => { let name = self.entrypoint_name(c.target.get()); - let symbol = nav_symbol(c.nav); - // Definition name in blue - let content = format!("({}{}{})", colors.blue, name, colors.reset); - let successors = format!("{:02} ⯇", c.next.get()); - self.add_instruction(ip, symbol, &content, &successors); + let content = self.format_def_name(name); + let successors = format!("{:02} : {:02}", c.target.get(), c.next.get()); + self.add_instruction(ip, Symbol::EMPTY, &content, &successors); } InstructionView::Return(_) => { - self.add_instruction(ip, Symbol::EMPTY, "", "▶"); + self.pending_return_ip = Some(ip); } } } @@ -515,18 +532,27 @@ impl Tracer for PrintTracer<'_> { } fn trace_call(&mut self, target_ip: u16) { - let c = &self.colors; let name = self.entrypoint_name(target_ip).to_string(); - // Definition name is blue - self.add_subline(trace::CALL, &format!("{}{}{}", c.blue, name, c.reset)); + self.add_subline(trace::CALL, &self.format_def_name(&name)); + self.lines.push(self.format_def_label(&name)); self.definition_stack.push(name); } fn trace_return(&mut self) { - let c = &self.colors; + let ip = self + .pending_return_ip + .take() + .expect("trace_return without trace_instruction"); let name = self.definition_stack.pop().unwrap_or_default(); - // Definition name is blue - self.add_subline(trace::RETURN, &format!("{}{}{}", c.blue, name, c.reset)); + let content = self.format_def_name(&name); + // Show ◼ when returning from top-level (stack now empty) + let is_top_level = self.definition_stack.is_empty(); + let successor = if is_top_level { "◼" } else { "" }; + self.add_instruction(ip, trace::RETURN, &content, successor); + // Print caller's label after return (if not top-level) + if let Some(caller) = self.definition_stack.last() { + self.lines.push(self.format_def_label(caller)); + } } fn trace_checkpoint_created(&mut self, ip: u16) { @@ -548,23 +574,12 @@ impl Tracer for PrintTracer<'_> { } fn trace_enter_entrypoint(&mut self, target_ip: u16) { - let c = &self.colors; let name = self.entrypoint_name(target_ip).to_string(); - // Definition name in blue - self.lines.push(format!("{}{}{}:", c.blue, name, c.reset)); + self.lines.push(self.format_def_label(&name)); self.definition_stack.push(name); } } -/// Format match symbol for instruction line. -fn format_match_symbol(m: &MatchView<'_>) -> Symbol { - if m.is_epsilon() { - Symbol::EPSILON - } else { - nav_symbol(m.nav) - } -} - /// Format match successors for instruction line. fn format_match_successors(m: &MatchView<'_>) -> String { if m.is_terminal() { diff --git a/docs/binary-format/07-dump-format.md b/docs/binary-format/07-dump-format.md index 7c681066..0123a20a 100644 --- a/docs/binary-format/07-dump-format.md +++ b/docs/binary-format/07-dump-format.md @@ -100,7 +100,7 @@ Assignment: 13 ε [Obj] 15 15 (assignment_expression) 16 16 ▽ left: (identifier) [Node Set(M6)] 18 - 18 ▷ right: (Expression) 19 ⯇ + 18 ▷ right: (Expression) 09 : 19 19 ε [Set(M5)] 21 21 △ 22 22 ε [EndObj] 24 @@ -170,14 +170,14 @@ Examples: - `!▽ ` — down, skip trivia - `!!▷ ` — next, exact -| Instruction | Format | -| ---------------- | --------------------------------------------- | -| Match (terminal) | `step nav [pre] (type) [post] ◼` | -| Match | `step nav [pre] field: (type) [post] succ` | -| Match (branch) | `step nav [pre] (type) [post] s1, s2` | -| Epsilon | `step ε [effects] succ` | -| Call | `step nav field: (Name) return ⯇` | -| Return | `step ▶` | +| Instruction | Format | +| ---------------- | ------------------------------------------------ | +| Match (terminal) | `step nav [pre] (type) [post] ◼` | +| Match | `step nav [pre] field: (type) [post] succ` | +| Match (branch) | `step nav [pre] (type) [post] s1, s2` | +| Epsilon | `step ε [effects] succ` | +| Call | `step nav field: (Name) target : ret` | +| Return | `step ▶` | Successors aligned in right column. Omit empty `[pre]`, `[post]`, `(type)`, `field:`. @@ -189,7 +189,7 @@ Effects in `[pre]` execute before match attempt; effects in `[post]` execute aft | --------------- | ------- | ----------------------------------- | | Stay | (blank) | No movement, 5 spaces | | Stay (epsilon) | ε | Only when no type/field constraints | -| StayExact | !!! | No movement, exact match only | +| StayExact | ! | No movement, exact match only | | Down | ▽ | First child, skip any | | DownSkip | !▽ | First child, skip trivia | | DownExact | !!▽ | First child, exact | diff --git a/docs/binary-format/08-trace-format.md b/docs/binary-format/08-trace-format.md index c06edff8..6bfe8e6f 100644 --- a/docs/binary-format/08-trace-format.md +++ b/docs/binary-format/08-trace-format.md @@ -42,12 +42,16 @@ Same as dump format: ### Instruction Line -Each instruction appears exactly as in the `dump` output: +Each instruction shows a simplified view compared to `dump`: ``` - 10 ▽ left: (identifier) [Node Set(M6)] 12 + 12 (program) 13 + 13 (B) 01 : 14 + 08 ◀ (B) ``` +**Match instructions** show empty symbol column (nav appears in sublines). **Call instructions** show `(Name)` with `target : return` successors. **Return instructions** show `◀` with `(Name)`. + ### Sub-Lines Below each instruction, sub-lines show what happened during execution. Each sub-line uses the same column layout with the step number area blank: @@ -63,9 +67,39 @@ Below each instruction, sub-lines show what happened during execution. Each sub- | ` ⬥ ` | Effect: data capture or structure | | ` ⬦ ` | Effect: suppressed (inside @\_) | | ` ▶ ` | Call: entering definition | -| ` ◀ ` | Return: back from definition | -Navigation sub-lines show the node kind we arrived at. Match sub-lines follow, showing success (`●`) or failure (`○`) for type/field checks. +Navigation symbols (`▽`, `▷`, `△`) appear only in sub-lines, not on instruction lines. Match sub-lines show success (`●`) or failure (`○`) for type/field checks. + +### Return Line + +Return is an instruction-level line showing the definition being returned from: + +``` + 08 ◀ (B) + 17 ◀ (A) ◼ +``` + +The `◀` symbol appears in the symbol column with the definition name in parentheses. Top-level returns (empty call stack) show `◼` as successor; mid-stack returns have no successor. + +### Definition Labels + +Definition labels (`Name:`) appear at: +- Entry to a definition (initial or via call) +- After returning from a call (showing the caller's name) + +``` +A: + 09 ε 10 + ... + 13 (B) 01 : 14 + ▶ (B) +B: + 01 ε 02 + ... + 08 ◀ (B) +A: + 14 15 +``` ### Backtrack Line @@ -121,7 +155,7 @@ Assignment: 13 ε [Obj] 15 15 (assignment_expression) 16 16 ▽ left: (identifier) [Node Set(M6)] 18 - 18 ▷ right: (Expression) 19 ⯇ + 18 ▷ right: (Expression) 09 : 19 19 ε [Set(M5)] 21 21 △ 22 22 ε [EndObj] 24 @@ -157,17 +191,16 @@ Assignment: 08 ε 09 09 (assignment_expression) 10 ● assignment_expression x = y - 10 ▽ left: (identifier) [Node Set(M6)] 12 + 10 left: (identifier) [Node Set(M6)] 12 ▽ identifier ● left: ● identifier x ⬥ Node ⬥ Set "target" - 12 ▷ right: (Expression) 13 ⯇ + 12 (Expression) 05 : 13 ▷ identifier ● right: - ▶ Expression - + ▶ (Expression) Expression: 05 ε 06 06 ε 22, 28 @@ -184,16 +217,13 @@ Expression: ⬥ Set "name" 24 ε [EndEnum] 17 ⬥ EndEnum - 17 ▶ - ◀ Expression - + 17 ◀ (Expression) Assignment: 13 ε [Set(M5)] 15 ⬥ Set "value" - 15 △ 16 + 15 16 △ assignment_expression - 16 ▶ - ◀ Assignment + 16 ◀ (Assignment) ◼ ``` ### Execution Summary @@ -232,17 +262,16 @@ Assignment: 08 ε 09 09 (assignment_expression) 10 ● assignment_expression x = 1 - 10 ▽ left: (identifier) [Node Set(M6)] 12 + 10 left: (identifier) [Node Set(M6)] 12 ▽ identifier ● left: ● identifier x ⬥ Node ⬥ Set "target" - 12 ▷ right: (Expression) 13 ⯇ + 12 (Expression) 05 : 13 ▷ number ● right: - ▶ Expression - + ▶ (Expression) Expression: 05 ε 06 06 ε 22, 28 @@ -254,16 +283,13 @@ Expression: ⬥ Set "value" 18 ε [EndEnum] 17 ⬥ EndEnum - 17 ▶ - ◀ Expression - + 17 ◀ (Expression) Assignment: 13 ε [Set(M5)] 15 ⬥ Set "value" - 15 △ 16 + 15 16 △ assignment_expression - 16 ▶ - ◀ Assignment + 16 ◀ (Assignment) ◼ ``` First branch (Literal) matches immediately—checkpoint at 28 is never used. @@ -318,7 +344,7 @@ Ident: ● identifier foo ⬥ Text ⬥ Set "name" - 04 ▶ + 04 ◀ (Ident) ◼ ``` The `Text` effect extracts the node's source text as a string (from `@name :: string`). @@ -360,19 +386,19 @@ ReturnVal: 01 ε 02 02 (statement_block) 03 ● statement_block { x; return 1; } - 03 ▽ (return_statement) [Node Set(M0)] 04 + 03 (return_statement) [Node Set(M0)] 04 ▽ expression_statement ○ expression_statement x; ▷ return_statement ● return_statement return 1; ⬥ Node ⬥ Set "ret" - 04 △ 05 + 04 05 △ statement_block - 05 ◼ + 05 ◀ (ReturnVal) ◼ ``` -The `▽` lands on `(expression_statement)`, type mismatch, skip `▷` to next sibling, find `(return_statement)`. +The navigation lands on `(expression_statement)`, type mismatch, skip `▷` to next sibling, find `(return_statement)`. --- @@ -430,7 +456,7 @@ Pair: ⬥ Obj 04 (pair) 05 ● pair "x": 1 - 05 ▽ key: (string) [SuppressBegin] 06 + 05 key: (string) [SuppressBegin] 06 ▽ string ● key: ● string "x" @@ -439,17 +465,17 @@ Pair: ⬦ Node ⬦ Set "key" ⬥ SuppressEnd - 08 ▷ value: (number) [Node Set(M0)] 10 + 08 value: (number) [Node Set(M0)] 10 ▷ number ● value: ● number 1 ⬥ Node ⬥ Set "value" - 10 △ 12 + 10 12 △ pair 12 ε [EndObj] 14 ⬥ EndObj - 14 ◼ + 14 ◀ (Pair) ◼ ``` The `@_` capture on `key:` wraps its inner effects with `SuppressBegin`/`SuppressEnd`. Effects between them (`Node`, `Set "key"`) appear as `⬦` (suppressed). The `@value` capture emits normally with `⬥`. @@ -465,11 +491,10 @@ Assignment: 08 ε 09 09 (assignment_expression) 10 ● assignment_expression - 10 ▽ left: (identifier) [Node Set(M6)] 12 + 10 left: (identifier) [Node Set(M6)] 12 ● identifier - 12 ▷ right: (Expression) 13 ⯇ - ▶ Expression - + 12 (Expression) 05 : 13 + ▶ (Expression) Expression: 05 ε 06 06 ε 22, 28 @@ -481,22 +506,19 @@ Expression: 26 (identifier) [Node Set(M2)] 24 ● identifier 24 ε [EndEnum] 17 - 17 ▶ - ◀ Expression - + 17 ◀ (Expression) Assignment: 13 ε [Set(M5)] 15 - 15 △ 16 + 15 16 ● assignment_expression - 16 ▶ - ◀ Assignment + 16 ◀ (Assignment) ◼ ``` Default shows: - Match results (`●`, `○`) with kind only, no text - Backtrack (`❮❮❮`) -- Call/return (`▶`, `◀`) +- Call (`▶`) and return (`◀`) Hidden: @@ -525,8 +547,7 @@ Hidden: | ` ⬥ ` | `⬥ SuppressEnd` | `⬥ SuppressEnd` | | ` ⬦ ` | `⬦ Effect` | `⬦ Node` (suppressed) | | ` ⬦ ` | `⬦ SuppressBegin` | `⬦ SuppressBegin` (nested) | -| ` ▶ ` | `▶ Name` | `▶ Expression` | -| ` ◀ ` | `◀ Name` | `◀ Expression` | +| ` ▶ ` | `▶ (Name)` | `▶ (Expression)` | ### Backtrack (Instruction-Level) @@ -542,7 +563,7 @@ Step number `NN` is the checkpoint we're restoring to. Appears as an instruction | --------------- | ------- | ------------------------------- | | Stay | (space) | No movement | | Stay (epsilon) | ε | No movement, no constraints | -| StayExact | !!! | Stay at position, exact only | +| StayExact | ! | Stay at position, exact only | | Down | ▽ | First child, skip any | | DownSkip | !▽ | First child, skip trivia | | DownExact | !!▽ | First child, exact | diff --git a/docs/tree-navigation.md b/docs/tree-navigation.md index 3788a46e..a0c37801 100644 --- a/docs/tree-navigation.md +++ b/docs/tree-navigation.md @@ -47,7 +47,7 @@ The `Node` API's `next_sibling()` is O(siblings)—unacceptable for repeated bac | Nav | Dump Symbol | Movement | | ----------------- | ----------- | ----------------------------- | | `Stay` | (space) | No movement | -| `StayExact` | `!!!` | No movement, exact match only | +| `StayExact` | `!` | No movement, exact match only | | `Down` | `↓*` | First child, skip any | | `DownSkip` | `↓~` | First child, skip trivia only | | `DownExact` | `↓.` | First child, exact |