From 9b1f6a1dc11b55b161e8d6c2d7cd32d393d28815 Mon Sep 17 00:00:00 2001 From: Schrottkatze Date: Mon, 21 Oct 2024 15:15:40 +0200 Subject: [PATCH] pawarser: Implement `CompletedMarker::precede` --- crates/pawarser/src/parser/marker.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/pawarser/src/parser/marker.rs b/crates/pawarser/src/parser/marker.rs index 2d3fc5a..d03e358 100644 --- a/crates/pawarser/src/parser/marker.rs +++ b/crates/pawarser/src/parser/marker.rs @@ -69,6 +69,17 @@ pub struct CompletedMarker { impl CompletedMarker { pub fn precede(self, p: &mut Parser, name: &str) -> Marker { - todo!() + let new_pos = p.start(name); + + match &mut p.events[self.pos] { + Event::Start { forward_parent, .. } => { + // point forward parent of the node this marker completed to the new node + // will later be used to make the new node a parent of the current node. + *forward_parent = Some(new_pos.pos - self.pos) + } + _ => unreachable!(), + } + + new_pos } }