Fix block scalars and document end interaction.
This commit is contained in:
parent
308b07bad2
commit
9b653e607b
2 changed files with 17 additions and 3 deletions
|
@ -612,6 +612,16 @@ impl<T: Iterator<Item = char>> Scanner<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Check whether the next characters correspond to an end of document.
|
||||||
|
///
|
||||||
|
/// [`Self::lookahead`] must have been called before calling this function.
|
||||||
|
fn next_is_document_end(&self) -> bool {
|
||||||
|
self.buffer[0] == '.'
|
||||||
|
&& self.buffer[1] == '.'
|
||||||
|
&& self.buffer[2] == '.'
|
||||||
|
&& is_blankz(self.buffer[3])
|
||||||
|
}
|
||||||
|
|
||||||
/// Insert a token at the given position.
|
/// Insert a token at the given position.
|
||||||
fn insert_token(&mut self, pos: usize, tok: Token) {
|
fn insert_token(&mut self, pos: usize, tok: Token) {
|
||||||
let old_len = self.tokens.len();
|
let old_len = self.tokens.len();
|
||||||
|
@ -1592,6 +1602,12 @@ impl<T: Iterator<Item = char>> Scanner<T> {
|
||||||
let start_mark = self.mark;
|
let start_mark = self.mark;
|
||||||
|
|
||||||
while self.mark.col == indent && !is_z(self.ch()) {
|
while self.mark.col == indent && !is_z(self.ch()) {
|
||||||
|
if indent == 0 {
|
||||||
|
self.lookahead(4);
|
||||||
|
if self.next_is_document_end() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
// We are at the beginning of a non-empty line.
|
// We are at the beginning of a non-empty line.
|
||||||
trailing_blank = is_blank(self.ch());
|
trailing_blank = is_blank(self.ch());
|
||||||
if !literal && !leading_break.is_empty() && !leading_blank && !trailing_blank {
|
if !literal && !leading_break.is_empty() && !leading_blank && !trailing_blank {
|
||||||
|
|
|
@ -220,7 +220,7 @@ fn events_differ(actual: Vec<String>, expected: &str) -> Option<String> {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
Some(format!(
|
Some(format!(
|
||||||
"line {} differs: expected `{}`, found `{}`",
|
"line {} differs: \n=> expected `{}`\n=> found `{}`",
|
||||||
idx, exp, act
|
idx, exp, act
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -297,8 +297,6 @@ fn expected_events(expected_tree: &str) -> Vec<String> {
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
static EXPECTED_FAILURES: &[&str] = &[
|
static EXPECTED_FAILURES: &[&str] = &[
|
||||||
// Directives (various)
|
|
||||||
"W4TN", // scalar confused as directive
|
|
||||||
// Losing trailing newline
|
// Losing trailing newline
|
||||||
"JEF9-02",
|
"JEF9-02",
|
||||||
"L24T-01",
|
"L24T-01",
|
||||||
|
|
Loading…
Reference in a new issue