Fixes towards implicit document end.

This commit is contained in:
Ethiraric 2024-01-19 18:33:09 +01:00
parent 7a3e3b05b4
commit 31dc4a1456
2 changed files with 11 additions and 4 deletions

View file

@ -271,9 +271,11 @@ impl<T: Iterator<Item = char>> Parser<T> {
self.token = None; self.token = None;
//self.peek_token(); //self.peek_token();
} }
/// Pops the top-most state and make it the current state.
fn pop_state(&mut self) { fn pop_state(&mut self) {
self.state = self.states.pop().unwrap(); self.state = self.states.pop().unwrap();
} }
/// Push a new state atop the state stack.
fn push_state(&mut self, state: State) { fn push_state(&mut self, state: State) {
self.states.push(state); self.states.push(state);
} }
@ -569,8 +571,17 @@ impl<T: Iterator<Item = char>> Parser<T> {
if explicit_end { if explicit_end {
self.state = State::ImplicitDocumentStart; self.state = State::ImplicitDocumentStart;
} else { } else {
if let Token(mark, TokenType::VersionDirective(..) | TokenType::TagDirective(..)) =
*self.peek_token()?
{
return Err(ScanError::new(
mark,
"missing explicit document end marker before directive",
));
}
self.state = State::DocumentStart; self.state = State::DocumentStart;
} }
Ok((Event::DocumentEnd, marker)) Ok((Event::DocumentEnd, marker))
} }

View file

@ -298,10 +298,6 @@ fn expected_events(expected_tree: &str) -> Vec<String> {
#[rustfmt::skip] #[rustfmt::skip]
static EXPECTED_FAILURES: &[&str] = &[ static EXPECTED_FAILURES: &[&str] = &[
// Directives (various) // Directives (various)
"9HCY", // Directive after content
"EB22", // Directive after content
"MUS6-01", // no document end marker?
"RHX7", // no document end marker
"SF5V", // duplicate directive "SF5V", // duplicate directive
"W4TN", // scalar confused as directive "W4TN", // scalar confused as directive
// Losing trailing newline // Losing trailing newline