Add a special case exit matcher for end of file.

This commit is contained in:
Tom Alexander
2023-03-25 14:45:35 -04:00
parent fc9d131740
commit d2923bfc0f
2 changed files with 19 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
use std::rc::Rc;
use nom::combinator::eof;
use nom::IResult;
use super::error::CustomError;
@@ -57,6 +58,12 @@ impl<'r, 's> ContextTree<'r, 's> {
&'r self,
i: &'s str,
) -> IResult<&'s str, &'s str, CustomError<&'s str>> {
// Special check for EOF. We don't just make this a document-level exit matcher since the IgnoreParent ChainBehavior could cause early exit matchers to not run.
let at_end_of_file = eof(i);
if at_end_of_file.is_ok() {
return at_end_of_file;
}
for current_node in self.iter() {
let context_element = current_node.get_data();
match context_element {