From 6308bbe98f37fecaf17e98374bd7ab4a8e706661 Mon Sep 17 00:00:00 2001 From: Ethiraric Date: Thu, 28 Dec 2023 01:12:38 +0100 Subject: [PATCH] Fix empty documents tests. --- saphyr/src/parser.rs | 10 +++++----- saphyr/tests/yaml-test-suite.rs | 3 --- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/saphyr/src/parser.rs b/saphyr/src/parser.rs index f55e4e3..a6f80a4 100644 --- a/saphyr/src/parser.rs +++ b/saphyr/src/parser.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; #[derive(Clone, Copy, PartialEq, Debug, Eq)] enum State { + /// We await the start of the stream. StreamStart, ImplicitDocumentStart, DocumentStart, @@ -265,6 +266,7 @@ impl> Parser { .expect("fetch_token needs to be preceded by peek_token") } + /// Skip the next token from the scanner. fn skip(&mut self) { self.token = None; //self.peek_token(); @@ -407,7 +409,7 @@ impl> Parser { } fn state_machine(&mut self) -> ParseResult { - // let next_tok = self.peek_token()?; + // let next_tok = self.peek_token().cloned()?; // println!("cur_state {:?}, next tok: {:?}", self.state, next_tok); match self.state { State::StreamStart => self.stream_start(), @@ -458,10 +460,8 @@ impl> Parser { } fn document_start(&mut self, implicit: bool) -> ParseResult { - if !implicit { - while let TokenType::DocumentEnd = self.peek_token()?.1 { - self.skip(); - } + while let TokenType::DocumentEnd = self.peek_token()?.1 { + self.skip(); } match *self.peek_token()? { diff --git a/saphyr/tests/yaml-test-suite.rs b/saphyr/tests/yaml-test-suite.rs index 0396fb4..1778e6f 100644 --- a/saphyr/tests/yaml-test-suite.rs +++ b/saphyr/tests/yaml-test-suite.rs @@ -297,9 +297,6 @@ fn expected_events(expected_tree: &str) -> Vec { #[rustfmt::skip] static EXPECTED_FAILURES: &[&str] = &[ - // Document with no nodes and document end - "HWV9", - "QT73", // Unusual characters in anchors/aliases "8XYN", // emoji!! "W5VH", // :@*!$":