Propagate tag to SequenceStart event.
This commit is contained in:
parent
ddd768e681
commit
b1be5686bf
3 changed files with 16 additions and 13 deletions
|
@ -55,6 +55,8 @@ pub enum Event {
|
|||
SequenceStart(
|
||||
/// The anchor ID of the start of the squence.
|
||||
usize,
|
||||
/// An optional tag
|
||||
Option<Tag>,
|
||||
),
|
||||
SequenceEnd,
|
||||
MappingStart(
|
||||
|
@ -347,7 +349,7 @@ impl<T: Iterator<Item = char>> Parser<T> {
|
|||
recv.on_event(first_ev, mark);
|
||||
Ok(())
|
||||
}
|
||||
Event::SequenceStart(_) => {
|
||||
Event::SequenceStart(..) => {
|
||||
recv.on_event(first_ev, mark);
|
||||
self.load_sequence(recv)
|
||||
}
|
||||
|
@ -615,7 +617,7 @@ impl<T: Iterator<Item = char>> Parser<T> {
|
|||
match *self.peek_token()? {
|
||||
Token(mark, TokenType::BlockEntry) if indentless_sequence => {
|
||||
self.state = State::IndentlessSequenceEntry;
|
||||
Ok((Event::SequenceStart(anchor_id), mark))
|
||||
Ok((Event::SequenceStart(anchor_id, tag), mark))
|
||||
}
|
||||
Token(_, TokenType::Scalar(..)) => {
|
||||
self.pop_state();
|
||||
|
@ -627,7 +629,7 @@ impl<T: Iterator<Item = char>> Parser<T> {
|
|||
}
|
||||
Token(mark, TokenType::FlowSequenceStart) => {
|
||||
self.state = State::FlowSequenceFirstEntry;
|
||||
Ok((Event::SequenceStart(anchor_id), mark))
|
||||
Ok((Event::SequenceStart(anchor_id, tag), mark))
|
||||
}
|
||||
Token(mark, TokenType::FlowMappingStart) => {
|
||||
self.state = State::FlowMappingFirstKey;
|
||||
|
@ -635,7 +637,7 @@ impl<T: Iterator<Item = char>> Parser<T> {
|
|||
}
|
||||
Token(mark, TokenType::BlockSequenceStart) if block => {
|
||||
self.state = State::BlockSequenceFirstEntry;
|
||||
Ok((Event::SequenceStart(anchor_id), mark))
|
||||
Ok((Event::SequenceStart(anchor_id, tag), mark))
|
||||
}
|
||||
Token(mark, TokenType::BlockMappingStart) if block => {
|
||||
self.state = State::BlockMappingFirstKey;
|
||||
|
|
|
@ -91,7 +91,7 @@ impl MarkedEventReceiver for YamlLoader {
|
|||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
Event::SequenceStart(aid) => {
|
||||
Event::SequenceStart(aid, _) => {
|
||||
self.doc_stack.push((Yaml::Array(Vec::new()), aid));
|
||||
}
|
||||
Event::SequenceEnd => {
|
||||
|
@ -110,7 +110,11 @@ impl MarkedEventReceiver for YamlLoader {
|
|||
Event::Scalar(v, style, aid, tag) => {
|
||||
let node = if style != TScalarStyle::Plain {
|
||||
Yaml::String(v)
|
||||
} else if let Some(Tag { ref handle, ref suffix }) = tag {
|
||||
} else if let Some(Tag {
|
||||
ref handle,
|
||||
ref suffix,
|
||||
}) = tag
|
||||
{
|
||||
// XXX tag:yaml.org,2002:
|
||||
if handle == "!!" {
|
||||
match suffix.as_ref() {
|
||||
|
|
|
@ -4,7 +4,7 @@ use libtest_mimic::{run_tests, Arguments, Outcome, Test};
|
|||
|
||||
use yaml_rust::{
|
||||
parser::{Event, EventReceiver, Parser, Tag},
|
||||
scanner::{TScalarStyle},
|
||||
scanner::TScalarStyle,
|
||||
yaml, ScanError, Yaml, YamlLoader,
|
||||
};
|
||||
|
||||
|
@ -145,7 +145,9 @@ impl EventReceiver for EventReporter {
|
|||
Event::DocumentStart => "+DOC".into(),
|
||||
Event::DocumentEnd => "-DOC".into(),
|
||||
|
||||
Event::SequenceStart(idx) => format!("+SEQ{}", format_index(idx)),
|
||||
Event::SequenceStart(idx, tag) => {
|
||||
format!("+SEQ{}{}", format_index(idx), format_tag(&tag))
|
||||
}
|
||||
Event::SequenceEnd => "-SEQ".into(),
|
||||
|
||||
Event::MappingStart(idx, tag) => {
|
||||
|
@ -301,12 +303,7 @@ fn expected_events(expected_tree: &str) -> Vec<String> {
|
|||
static EXPECTED_FAILURES: &[&str] = &[
|
||||
// These seem to be API limited (not enough information on the event stream level)
|
||||
// No tag available for SEQ and MAP
|
||||
"35KP",
|
||||
"57H4",
|
||||
"6JWB",
|
||||
"C4HZ",
|
||||
"EHF6",
|
||||
"J7PZ",
|
||||
// Cannot resolve tag namespaces
|
||||
"5TYM",
|
||||
"6CK3",
|
||||
|
|
Loading…
Reference in a new issue