Skip to content

Commit a357d8a

Browse files
committed
refactor: Remove NavKind wrapper, use Nav directly in fingerprinting
1 parent 66bce05 commit a357d8a

2 files changed

Lines changed: 3 additions & 41 deletions

File tree

  • crates

‎crates/plotnik-bytecode/src/bytecode/nav.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//! Navigation determines how the VM moves through the tree-sitter AST.
44
55
/// Navigation command for VM execution.
6-
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
6+
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Debug, Default)]
77
pub enum Nav {
88
/// Epsilon transition: pure control flow, no cursor movement or node check.
99
/// Used for branching, quantifier loops, and effect-only transitions.

‎crates/plotnik-compiler/src/compile/verify.rs‎

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use super::compiler::CompileCtx;
2323
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
2424
pub enum SemanticOp {
2525
/// Navigation (non-epsilon only, full detail preserved).
26-
Nav(NavKind),
26+
Nav(Nav),
2727

2828
/// Named node match with optional type name.
2929
MatchNamed(Option<String>),
@@ -58,44 +58,6 @@ pub enum SemanticOp {
5858
CycleMarker(usize),
5959
}
6060

61-
/// Navigation kind for fingerprinting.
62-
///
63-
/// Preserves full detail including Skip/Exact variants since these are semantically
64-
/// significant (determined by anchors).
65-
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
66-
pub enum NavKind {
67-
Stay,
68-
StayExact,
69-
Next,
70-
NextSkip,
71-
NextExact,
72-
Down,
73-
DownSkip,
74-
DownExact,
75-
Up(u8),
76-
UpSkipTrivia(u8),
77-
UpExact(u8),
78-
}
79-
80-
impl From<Nav> for NavKind {
81-
fn from(nav: Nav) -> Self {
82-
match nav {
83-
Nav::Epsilon => unreachable!("Epsilon should be filtered"),
84-
Nav::Stay => Self::Stay,
85-
Nav::StayExact => Self::StayExact,
86-
Nav::Next => Self::Next,
87-
Nav::NextSkip => Self::NextSkip,
88-
Nav::NextExact => Self::NextExact,
89-
Nav::Down => Self::Down,
90-
Nav::DownSkip => Self::DownSkip,
91-
Nav::DownExact => Self::DownExact,
92-
Nav::Up(n) => Self::Up(n),
93-
Nav::UpSkipTrivia(n) => Self::UpSkipTrivia(n),
94-
Nav::UpExact(n) => Self::UpExact(n),
95-
}
96-
}
97-
}
98-
9961
/// A semantic path: sequence of operations along one execution path.
10062
pub type Path = Vec<SemanticOp>;
10163

@@ -115,7 +77,7 @@ fn collect_ops_from_match(instr: &MatchIR, ctx: &CompileCtx) -> Vec<SemanticOp>
11577

11678
// Epsilons are pure control flow - they don't navigate or check node types
11779
if instr.nav != Nav::Epsilon {
118-
ops.push(SemanticOp::Nav(instr.nav.into()));
80+
ops.push(SemanticOp::Nav(instr.nav));
11981

12082
// Only non-epsilons perform actual node type checks
12183
match &instr.node_type {

0 commit comments

Comments
 (0)