Add empty_scalar()
This commit is contained in:
parent
f8065b79c7
commit
5c25f78c7f
1 changed files with 11 additions and 5 deletions
|
@ -43,6 +43,12 @@ pub enum Event {
|
||||||
MappingEnd
|
MappingEnd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Event {
|
||||||
|
fn empty_scalar() -> Event {
|
||||||
|
Event::Scalar(String::new())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Parser<T> {
|
pub struct Parser<T> {
|
||||||
scanner: Scanner<T>,
|
scanner: Scanner<T>,
|
||||||
|
@ -265,7 +271,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
|TokenType::StreamEndToken => {
|
|TokenType::StreamEndToken => {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
// empty scalar
|
// empty scalar
|
||||||
Ok(Event::Scalar(String::new()))
|
Ok(Event::empty_scalar())
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
self.parse_node(true, false)
|
self.parse_node(true, false)
|
||||||
|
@ -324,7 +330,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
=> {
|
=> {
|
||||||
self.state = State::BlockMappingValue;
|
self.state = State::BlockMappingValue;
|
||||||
// empty scalar
|
// empty scalar
|
||||||
Ok(Event::Scalar(String::new()))
|
Ok(Event::empty_scalar())
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.push_state(State::BlockMappingValue);
|
self.push_state(State::BlockMappingValue);
|
||||||
|
@ -354,7 +360,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
=> {
|
=> {
|
||||||
self.state = State::BlockMappingValue;
|
self.state = State::BlockMappingValue;
|
||||||
// empty scalar
|
// empty scalar
|
||||||
Ok(Event::Scalar(String::new()))
|
Ok(Event::empty_scalar())
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.push_state(State::BlockMappingKey);
|
self.push_state(State::BlockMappingKey);
|
||||||
|
@ -365,7 +371,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
_ => {
|
_ => {
|
||||||
self.state = State::BlockMappingKey;
|
self.state = State::BlockMappingKey;
|
||||||
// empty scalar
|
// empty scalar
|
||||||
Ok(Event::Scalar(String::new()))
|
Ok(Event::empty_scalar())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -432,7 +438,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::BlockEntryToken | TokenType::BlockEndToken => {
|
TokenType::BlockEntryToken | TokenType::BlockEndToken => {
|
||||||
self.state = State::BlockSequenceEntry;
|
self.state = State::BlockSequenceEntry;
|
||||||
Ok(Event::Scalar(String::new()))
|
Ok(Event::empty_scalar())
|
||||||
},
|
},
|
||||||
_ => {
|
_ => {
|
||||||
self.push_state(State::BlockSequenceEntry);
|
self.push_state(State::BlockSequenceEntry);
|
||||||
|
|
Loading…
Reference in a new issue