Implement iterator for context.

This commit is contained in:
Tom Alexander
2023-09-02 20:46:17 -04:00
parent 22e9bc991f
commit 0d728510d7
9 changed files with 102 additions and 39 deletions

View File

@@ -399,10 +399,9 @@ fn time_range_rest_end<'r, 's>(
input: OrgSource<'s>,
) -> Res<OrgSource<'s>, OrgSource<'s>> {
// We pop off the most recent context element to get a context tree with just the active/inactive_time_rest_end exit matcher (removing this function from the exit matcher chain) because the 2nd time in the range does not end when a "-TIME" pattern is found.
let parent_node = context.iter().next().expect("Two context elements are added to the tree when adding this exit matcher, so it should be impossible for this to return None.");
let parent_tree = ContextTree::branch_from(parent_node);
let parent_node = context.get_parent().expect("Two context elements are added to the tree when adding this exit matcher, so it should be impossible for this to return None.");
let exit_contents =
recognize(tuple((tag("-"), parser_with_context!(time)(&parent_tree))))(input);
recognize(tuple((tag("-"), parser_with_context!(time)(&parent_node))))(input);
exit_contents
}