Remove common suffix from TokenType enum
See https://github.com/Manishearth/rust-clippy/wiki#enum_variant_names
This commit is contained in:
parent
67644b5dd9
commit
956f7625d1
3 changed files with 272 additions and 272 deletions
|
@ -270,7 +270,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
|
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::StreamStartToken(_) => {
|
TokenType::StreamStart(_) => {
|
||||||
self.state = State::ImplicitDocumentStart;
|
self.state = State::ImplicitDocumentStart;
|
||||||
self.skip();
|
self.skip();
|
||||||
Ok(Event::StreamStart)
|
Ok(Event::StreamStart)
|
||||||
|
@ -285,7 +285,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
if !implicit {
|
if !implicit {
|
||||||
loop {
|
loop {
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::DocumentEndToken => {
|
TokenType::DocumentEnd => {
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
},
|
},
|
||||||
|
@ -295,14 +295,14 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::StreamEndToken => {
|
TokenType::StreamEnd => {
|
||||||
self.state = State::End;
|
self.state = State::End;
|
||||||
self.skip();
|
self.skip();
|
||||||
return Ok(Event::StreamEnd);
|
return Ok(Event::StreamEnd);
|
||||||
},
|
},
|
||||||
TokenType::VersionDirectiveToken(..)
|
TokenType::VersionDirective(..)
|
||||||
| TokenType::TagDirectiveToken(..)
|
| TokenType::TagDirective(..)
|
||||||
| TokenType::DocumentStartToken => {
|
| TokenType::DocumentStart => {
|
||||||
// explicit document
|
// explicit document
|
||||||
self._explict_document_start()
|
self._explict_document_start()
|
||||||
},
|
},
|
||||||
|
@ -323,14 +323,14 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
loop {
|
loop {
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::VersionDirectiveToken(_, _) => {
|
TokenType::VersionDirective(_, _) => {
|
||||||
// XXX parsing with warning according to spec
|
// XXX parsing with warning according to spec
|
||||||
//if major != 1 || minor > 2 {
|
//if major != 1 || minor > 2 {
|
||||||
// return Err(ScanError::new(tok.0,
|
// return Err(ScanError::new(tok.0,
|
||||||
// "found incompatible YAML document"));
|
// "found incompatible YAML document"));
|
||||||
//}
|
//}
|
||||||
},
|
},
|
||||||
TokenType::TagDirectiveToken(..) => {
|
TokenType::TagDirective(..) => {
|
||||||
// TODO add tag directive
|
// TODO add tag directive
|
||||||
},
|
},
|
||||||
_ => break
|
_ => break
|
||||||
|
@ -344,7 +344,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
fn _explict_document_start(&mut self) -> ParseResult {
|
fn _explict_document_start(&mut self) -> ParseResult {
|
||||||
try!(self.parser_process_directives());
|
try!(self.parser_process_directives());
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
if tok.1 != TokenType::DocumentStartToken {
|
if tok.1 != TokenType::DocumentStart {
|
||||||
return Err(ScanError::new(tok.0, "did not find expected <document start>"));
|
return Err(ScanError::new(tok.0, "did not find expected <document start>"));
|
||||||
}
|
}
|
||||||
self.push_state(State::DocumentEnd);
|
self.push_state(State::DocumentEnd);
|
||||||
|
@ -356,11 +356,11 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
fn document_content(&mut self) -> ParseResult {
|
fn document_content(&mut self) -> ParseResult {
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::VersionDirectiveToken(..)
|
TokenType::VersionDirective(..)
|
||||||
|TokenType::TagDirectiveToken(..)
|
|TokenType::TagDirective(..)
|
||||||
|TokenType::DocumentStartToken
|
|TokenType::DocumentStart
|
||||||
|TokenType::DocumentEndToken
|
|TokenType::DocumentEnd
|
||||||
|TokenType::StreamEndToken => {
|
|TokenType::StreamEnd => {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
// empty scalar
|
// empty scalar
|
||||||
Ok(Event::empty_scalar())
|
Ok(Event::empty_scalar())
|
||||||
|
@ -377,7 +377,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
let _start_mark = tok.0;
|
let _start_mark = tok.0;
|
||||||
|
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::DocumentEndToken => {
|
TokenType::DocumentEnd => {
|
||||||
self.skip();
|
self.skip();
|
||||||
_implicit = false;
|
_implicit = false;
|
||||||
}
|
}
|
||||||
|
@ -406,7 +406,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
let mut anchor_id = 0;
|
let mut anchor_id = 0;
|
||||||
let mut tag = None;
|
let mut tag = None;
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::AliasToken(name) => {
|
TokenType::Alias(name) => {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
self.skip();
|
self.skip();
|
||||||
match self.anchors.get(&name) {
|
match self.anchors.get(&name) {
|
||||||
|
@ -414,21 +414,21 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
Some(id) => return Ok(Event::Alias(*id))
|
Some(id) => return Ok(Event::Alias(*id))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TokenType::AnchorToken(name) => {
|
TokenType::Anchor(name) => {
|
||||||
anchor_id = try!(self.register_anchor(&name, &tok.0));
|
anchor_id = try!(self.register_anchor(&name, &tok.0));
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
if let TokenType::TagToken(_, _) = tok.1 {
|
if let TokenType::Tag(_, _) = tok.1 {
|
||||||
tag = Some(tok.1);
|
tag = Some(tok.1);
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
TokenType::TagToken(..) => {
|
TokenType::Tag(..) => {
|
||||||
tag = Some(tok.1);
|
tag = Some(tok.1);
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
if let TokenType::AnchorToken(name) = tok.1 {
|
if let TokenType::Anchor(name) = tok.1 {
|
||||||
anchor_id = try!(self.register_anchor(&name, &tok.0));
|
anchor_id = try!(self.register_anchor(&name, &tok.0));
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
|
@ -437,28 +437,28 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::BlockEntryToken if indentless_sequence => {
|
TokenType::BlockEntry if indentless_sequence => {
|
||||||
self.state = State::IndentlessSequenceEntry;
|
self.state = State::IndentlessSequenceEntry;
|
||||||
Ok(Event::SequenceStart(anchor_id))
|
Ok(Event::SequenceStart(anchor_id))
|
||||||
},
|
},
|
||||||
TokenType::ScalarToken(style, v) => {
|
TokenType::Scalar(style, v) => {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
self.skip();
|
self.skip();
|
||||||
Ok(Event::Scalar(v, style, anchor_id, tag))
|
Ok(Event::Scalar(v, style, anchor_id, tag))
|
||||||
},
|
},
|
||||||
TokenType::FlowSequenceStartToken => {
|
TokenType::FlowSequenceStart => {
|
||||||
self.state = State::FlowSequenceFirstEntry;
|
self.state = State::FlowSequenceFirstEntry;
|
||||||
Ok(Event::SequenceStart(anchor_id))
|
Ok(Event::SequenceStart(anchor_id))
|
||||||
},
|
},
|
||||||
TokenType::FlowMappingStartToken => {
|
TokenType::FlowMappingStart => {
|
||||||
self.state = State::FlowMappingFirstKey;
|
self.state = State::FlowMappingFirstKey;
|
||||||
Ok(Event::MappingStart(anchor_id))
|
Ok(Event::MappingStart(anchor_id))
|
||||||
},
|
},
|
||||||
TokenType::BlockSequenceStartToken if block => {
|
TokenType::BlockSequenceStart if block => {
|
||||||
self.state = State::BlockSequenceFirstEntry;
|
self.state = State::BlockSequenceFirstEntry;
|
||||||
Ok(Event::SequenceStart(anchor_id))
|
Ok(Event::SequenceStart(anchor_id))
|
||||||
},
|
},
|
||||||
TokenType::BlockMappingStartToken if block => {
|
TokenType::BlockMappingStart if block => {
|
||||||
self.state = State::BlockMappingFirstKey;
|
self.state = State::BlockMappingFirstKey;
|
||||||
Ok(Event::MappingStart(anchor_id))
|
Ok(Event::MappingStart(anchor_id))
|
||||||
},
|
},
|
||||||
|
@ -472,7 +472,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn block_mapping_key(&mut self, first: bool) -> ParseResult {
|
fn block_mapping_key(&mut self, first: bool) -> ParseResult {
|
||||||
// skip BlockMappingStartToken
|
// skip BlockMappingStart
|
||||||
if first {
|
if first {
|
||||||
let _ = try!(self.peek());
|
let _ = try!(self.peek());
|
||||||
//self.marks.push(tok.0);
|
//self.marks.push(tok.0);
|
||||||
|
@ -480,13 +480,13 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::KeyToken => {
|
TokenType::Key => {
|
||||||
self.skip();
|
self.skip();
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::KeyToken
|
TokenType::Key
|
||||||
| TokenType::ValueToken
|
| TokenType::Value
|
||||||
| TokenType::BlockEndToken
|
| TokenType::BlockEnd
|
||||||
=> {
|
=> {
|
||||||
self.state = State::BlockMappingValue;
|
self.state = State::BlockMappingValue;
|
||||||
// empty scalar
|
// empty scalar
|
||||||
|
@ -499,11 +499,11 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// XXX(chenyh): libyaml failed to parse spec 1.2, ex8.18
|
// XXX(chenyh): libyaml failed to parse spec 1.2, ex8.18
|
||||||
TokenType::ValueToken => {
|
TokenType::Value => {
|
||||||
self.state = State::BlockMappingValue;
|
self.state = State::BlockMappingValue;
|
||||||
Ok(Event::empty_scalar())
|
Ok(Event::empty_scalar())
|
||||||
},
|
},
|
||||||
TokenType::BlockEndToken => {
|
TokenType::BlockEnd => {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
self.skip();
|
self.skip();
|
||||||
Ok(Event::MappingEnd)
|
Ok(Event::MappingEnd)
|
||||||
|
@ -517,11 +517,11 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
fn block_mapping_value(&mut self) -> ParseResult {
|
fn block_mapping_value(&mut self) -> ParseResult {
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::ValueToken => {
|
TokenType::Value => {
|
||||||
self.skip();
|
self.skip();
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::KeyToken | TokenType::ValueToken | TokenType::BlockEndToken
|
TokenType::Key | TokenType::Value | TokenType::BlockEnd
|
||||||
=> {
|
=> {
|
||||||
self.state = State::BlockMappingKey;
|
self.state = State::BlockMappingKey;
|
||||||
// empty scalar
|
// empty scalar
|
||||||
|
@ -548,9 +548,9 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
let mut tok = try!(self.peek());
|
let mut tok = try!(self.peek());
|
||||||
|
|
||||||
if tok.1 != TokenType::FlowMappingEndToken {
|
if tok.1 != TokenType::FlowMappingEnd {
|
||||||
if !first {
|
if !first {
|
||||||
if tok.1 == TokenType::FlowEntryToken {
|
if tok.1 == TokenType::FlowEntry {
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
} else {
|
} else {
|
||||||
|
@ -559,13 +559,13 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if tok.1 == TokenType::KeyToken {
|
if tok.1 == TokenType::Key {
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::ValueToken
|
TokenType::Value
|
||||||
| TokenType::FlowEntryToken
|
| TokenType::FlowEntry
|
||||||
| TokenType::FlowMappingEndToken => {
|
| TokenType::FlowMappingEnd => {
|
||||||
self.state = State::FlowMappingValue;
|
self.state = State::FlowMappingValue;
|
||||||
return Ok(Event::empty_scalar());
|
return Ok(Event::empty_scalar());
|
||||||
},
|
},
|
||||||
|
@ -575,10 +575,10 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// XXX libyaml fail ex 7.3, empty key
|
// XXX libyaml fail ex 7.3, empty key
|
||||||
} else if tok.1 == TokenType::ValueToken {
|
} else if tok.1 == TokenType::Value {
|
||||||
self.state = State::FlowMappingValue;
|
self.state = State::FlowMappingValue;
|
||||||
return Ok(Event::empty_scalar());
|
return Ok(Event::empty_scalar());
|
||||||
} else if tok.1 != TokenType::FlowMappingEndToken {
|
} else if tok.1 != TokenType::FlowMappingEnd {
|
||||||
self.push_state(State::FlowMappingEmptyValue);
|
self.push_state(State::FlowMappingEmptyValue);
|
||||||
return self.parse_node(false, false);
|
return self.parse_node(false, false);
|
||||||
}
|
}
|
||||||
|
@ -596,12 +596,12 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
return Ok(Event::empty_scalar());
|
return Ok(Event::empty_scalar());
|
||||||
}
|
}
|
||||||
|
|
||||||
if tok.1 == TokenType::ValueToken {
|
if tok.1 == TokenType::Value {
|
||||||
self.skip();
|
self.skip();
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::FlowEntryToken
|
TokenType::FlowEntry
|
||||||
| TokenType::FlowMappingEndToken => { },
|
| TokenType::FlowMappingEnd => { },
|
||||||
_ => {
|
_ => {
|
||||||
self.push_state(State::FlowMappingKey);
|
self.push_state(State::FlowMappingKey);
|
||||||
return self.parse_node(false, false);
|
return self.parse_node(false, false);
|
||||||
|
@ -614,7 +614,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flow_sequence_entry(&mut self, first: bool) -> ParseResult {
|
fn flow_sequence_entry(&mut self, first: bool) -> ParseResult {
|
||||||
// skip FlowMappingStartToken
|
// skip FlowMappingStart
|
||||||
if first {
|
if first {
|
||||||
let _ = try!(self.peek());
|
let _ = try!(self.peek());
|
||||||
//self.marks.push(tok.0);
|
//self.marks.push(tok.0);
|
||||||
|
@ -622,12 +622,12 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
let mut tok = try!(self.peek());
|
let mut tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::FlowSequenceEndToken => {
|
TokenType::FlowSequenceEnd => {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
self.skip();
|
self.skip();
|
||||||
return Ok(Event::SequenceEnd);
|
return Ok(Event::SequenceEnd);
|
||||||
},
|
},
|
||||||
TokenType::FlowEntryToken if !first => {
|
TokenType::FlowEntry if !first => {
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
},
|
},
|
||||||
|
@ -638,12 +638,12 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
_ => { /* next */ }
|
_ => { /* next */ }
|
||||||
}
|
}
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::FlowSequenceEndToken => {
|
TokenType::FlowSequenceEnd => {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
self.skip();
|
self.skip();
|
||||||
Ok(Event::SequenceEnd)
|
Ok(Event::SequenceEnd)
|
||||||
},
|
},
|
||||||
TokenType::KeyToken => {
|
TokenType::Key => {
|
||||||
self.state = State::FlowSequenceEntryMappingKey;
|
self.state = State::FlowSequenceEntryMappingKey;
|
||||||
self.skip();
|
self.skip();
|
||||||
Ok(Event::MappingStart(0))
|
Ok(Event::MappingStart(0))
|
||||||
|
@ -657,7 +657,7 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
|
|
||||||
fn indentless_sequence_entry(&mut self) -> ParseResult {
|
fn indentless_sequence_entry(&mut self) -> ParseResult {
|
||||||
let mut tok = try!(self.peek());
|
let mut tok = try!(self.peek());
|
||||||
if tok.1 != TokenType::BlockEntryToken {
|
if tok.1 != TokenType::BlockEntry {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
return Ok(Event::SequenceEnd);
|
return Ok(Event::SequenceEnd);
|
||||||
}
|
}
|
||||||
|
@ -665,10 +665,10 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::BlockEntryToken
|
TokenType::BlockEntry
|
||||||
| TokenType::KeyToken
|
| TokenType::Key
|
||||||
| TokenType::ValueToken
|
| TokenType::Value
|
||||||
| TokenType::BlockEndToken => {
|
| TokenType::BlockEnd => {
|
||||||
self.state = State::IndentlessSequenceEntry;
|
self.state = State::IndentlessSequenceEntry;
|
||||||
Ok(Event::empty_scalar())
|
Ok(Event::empty_scalar())
|
||||||
},
|
},
|
||||||
|
@ -688,17 +688,17 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
}
|
}
|
||||||
let mut tok = try!(self.peek());
|
let mut tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::BlockEndToken => {
|
TokenType::BlockEnd => {
|
||||||
self.pop_state();
|
self.pop_state();
|
||||||
self.skip();
|
self.skip();
|
||||||
Ok(Event::SequenceEnd)
|
Ok(Event::SequenceEnd)
|
||||||
},
|
},
|
||||||
TokenType::BlockEntryToken => {
|
TokenType::BlockEntry => {
|
||||||
self.skip();
|
self.skip();
|
||||||
tok = try!(self.peek());
|
tok = try!(self.peek());
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::BlockEntryToken
|
TokenType::BlockEntry
|
||||||
| TokenType::BlockEndToken => {
|
| TokenType::BlockEnd => {
|
||||||
self.state = State::BlockSequenceEntry;
|
self.state = State::BlockSequenceEntry;
|
||||||
Ok(Event::empty_scalar())
|
Ok(Event::empty_scalar())
|
||||||
},
|
},
|
||||||
|
@ -719,9 +719,9 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
|
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::ValueToken
|
TokenType::Value
|
||||||
| TokenType::FlowEntryToken
|
| TokenType::FlowEntry
|
||||||
| TokenType::FlowSequenceEndToken => {
|
| TokenType::FlowSequenceEnd => {
|
||||||
self.skip();
|
self.skip();
|
||||||
self.state = State::FlowSequenceEntryMappingValue;
|
self.state = State::FlowSequenceEntryMappingValue;
|
||||||
Ok(Event::empty_scalar())
|
Ok(Event::empty_scalar())
|
||||||
|
@ -737,13 +737,13 @@ impl<T: Iterator<Item=char>> Parser<T> {
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
|
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::ValueToken => {
|
TokenType::Value => {
|
||||||
self.skip();
|
self.skip();
|
||||||
let tok = try!(self.peek());
|
let tok = try!(self.peek());
|
||||||
self.state = State::FlowSequenceEntryMappingValue;
|
self.state = State::FlowSequenceEntryMappingValue;
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
TokenType::FlowEntryToken
|
TokenType::FlowEntry
|
||||||
| TokenType::FlowSequenceEndToken => {
|
| TokenType::FlowSequenceEnd => {
|
||||||
self.state = State::FlowSequenceEntryMappingEnd;
|
self.state = State::FlowSequenceEntryMappingEnd;
|
||||||
Ok(Event::empty_scalar())
|
Ok(Event::empty_scalar())
|
||||||
},
|
},
|
||||||
|
|
|
@ -71,30 +71,30 @@ impl fmt::Display for ScanError {
|
||||||
#[derive(Clone, PartialEq, Debug, Eq)]
|
#[derive(Clone, PartialEq, Debug, Eq)]
|
||||||
pub enum TokenType {
|
pub enum TokenType {
|
||||||
NoToken,
|
NoToken,
|
||||||
StreamStartToken(TEncoding),
|
StreamStart(TEncoding),
|
||||||
StreamEndToken,
|
StreamEnd,
|
||||||
/// major, minor
|
/// major, minor
|
||||||
VersionDirectiveToken(u32, u32),
|
VersionDirective(u32, u32),
|
||||||
/// handle, prefix
|
/// handle, prefix
|
||||||
TagDirectiveToken(String, String),
|
TagDirective(String, String),
|
||||||
DocumentStartToken,
|
DocumentStart,
|
||||||
DocumentEndToken,
|
DocumentEnd,
|
||||||
BlockSequenceStartToken,
|
BlockSequenceStart,
|
||||||
BlockMappingStartToken,
|
BlockMappingStart,
|
||||||
BlockEndToken,
|
BlockEnd,
|
||||||
FlowSequenceStartToken,
|
FlowSequenceStart,
|
||||||
FlowSequenceEndToken,
|
FlowSequenceEnd,
|
||||||
FlowMappingStartToken,
|
FlowMappingStart,
|
||||||
FlowMappingEndToken,
|
FlowMappingEnd,
|
||||||
BlockEntryToken,
|
BlockEntry,
|
||||||
FlowEntryToken,
|
FlowEntry,
|
||||||
KeyToken,
|
Key,
|
||||||
ValueToken,
|
Value,
|
||||||
AliasToken(String),
|
Alias(String),
|
||||||
AnchorToken(String),
|
Anchor(String),
|
||||||
/// handle, suffix
|
/// handle, suffix
|
||||||
TagToken(String, String),
|
Tag(String, String),
|
||||||
ScalarToken(TScalarStyle, String)
|
Scalar(TScalarStyle, String)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, PartialEq, Debug, Eq)]
|
#[derive(Clone, PartialEq, Debug, Eq)]
|
||||||
|
@ -348,7 +348,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
&& self.buffer[1] == '-'
|
&& self.buffer[1] == '-'
|
||||||
&& self.buffer[2] == '-'
|
&& self.buffer[2] == '-'
|
||||||
&& is_blankz(self.buffer[3]) {
|
&& is_blankz(self.buffer[3]) {
|
||||||
try!(self.fetch_document_indicator(TokenType::DocumentStartToken));
|
try!(self.fetch_document_indicator(TokenType::DocumentStart));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,17 +357,17 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
&& self.buffer[1] == '.'
|
&& self.buffer[1] == '.'
|
||||||
&& self.buffer[2] == '.'
|
&& self.buffer[2] == '.'
|
||||||
&& is_blankz(self.buffer[3]) {
|
&& is_blankz(self.buffer[3]) {
|
||||||
try!(self.fetch_document_indicator(TokenType::DocumentEndToken));
|
try!(self.fetch_document_indicator(TokenType::DocumentEnd));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let c = self.buffer[0];
|
let c = self.buffer[0];
|
||||||
let nc = self.buffer[1];
|
let nc = self.buffer[1];
|
||||||
match c {
|
match c {
|
||||||
'[' => self.fetch_flow_collection_start(TokenType::FlowSequenceStartToken),
|
'[' => self.fetch_flow_collection_start(TokenType::FlowSequenceStart),
|
||||||
'{' => self.fetch_flow_collection_start(TokenType::FlowMappingStartToken),
|
'{' => self.fetch_flow_collection_start(TokenType::FlowMappingStart),
|
||||||
']' => self.fetch_flow_collection_end(TokenType::FlowSequenceEndToken),
|
']' => self.fetch_flow_collection_end(TokenType::FlowSequenceEnd),
|
||||||
'}' => self.fetch_flow_collection_end(TokenType::FlowMappingEndToken),
|
'}' => self.fetch_flow_collection_end(TokenType::FlowMappingEnd),
|
||||||
',' => self.fetch_flow_entry(),
|
',' => self.fetch_flow_entry(),
|
||||||
'-' if is_blankz(nc) => self.fetch_block_entry(),
|
'-' if is_blankz(nc) => self.fetch_block_entry(),
|
||||||
'?' if self.flow_level > 0 || is_blankz(nc) => self.fetch_key(),
|
'?' if self.flow_level > 0 || is_blankz(nc) => self.fetch_key(),
|
||||||
|
@ -405,7 +405,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
self.tokens_parsed += 1;
|
self.tokens_parsed += 1;
|
||||||
|
|
||||||
match t.1 {
|
match t.1 {
|
||||||
TokenType::StreamEndToken => self.stream_end_produced = true,
|
TokenType::StreamEnd => self.stream_end_produced = true,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(Some(t))
|
Ok(Some(t))
|
||||||
|
@ -473,7 +473,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
self.indent = -1;
|
self.indent = -1;
|
||||||
self.stream_start_produced = true;
|
self.stream_start_produced = true;
|
||||||
self.allow_simple_key();
|
self.allow_simple_key();
|
||||||
self.tokens.push_back(Token(mark, TokenType::StreamStartToken(TEncoding::Utf8)));
|
self.tokens.push_back(Token(mark, TokenType::StreamStart(TEncoding::Utf8)));
|
||||||
self.simple_keys.push(SimpleKey::new(Marker::new(0,0,0)));
|
self.simple_keys.push(SimpleKey::new(Marker::new(0,0,0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
try!(self.remove_simple_key());
|
try!(self.remove_simple_key());
|
||||||
self.disallow_simple_key();
|
self.disallow_simple_key();
|
||||||
|
|
||||||
self.tokens.push_back(Token(self.mark, TokenType::StreamEndToken));
|
self.tokens.push_back(Token(self.mark, TokenType::StreamEnd));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +526,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
self.lookahead(1);
|
self.lookahead(1);
|
||||||
}
|
}
|
||||||
// XXX return an empty TagDirective token
|
// XXX return an empty TagDirective token
|
||||||
Token(start_mark, TokenType::TagDirectiveToken(String::new(), String::new()))
|
Token(start_mark, TokenType::TagDirective(String::new(), String::new()))
|
||||||
// return Err(ScanError::new(start_mark,
|
// return Err(ScanError::new(start_mark,
|
||||||
// "while scanning a directive, found unknown directive name"))
|
// "while scanning a directive, found unknown directive name"))
|
||||||
}
|
}
|
||||||
|
@ -578,7 +578,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
|
|
||||||
let minor = try!(self.scan_version_directive_number(mark));
|
let minor = try!(self.scan_version_directive_number(mark));
|
||||||
|
|
||||||
Ok(Token(*mark, TokenType::VersionDirectiveToken(major, minor)))
|
Ok(Token(*mark, TokenType::VersionDirective(major, minor)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scan_directive_name(&mut self) -> Result<String, ScanError> {
|
fn scan_directive_name(&mut self) -> Result<String, ScanError> {
|
||||||
|
@ -652,7 +652,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
Err(ScanError::new(*mark,
|
Err(ScanError::new(*mark,
|
||||||
"while scanning TAG, did not find expected whitespace or line break"))
|
"while scanning TAG, did not find expected whitespace or line break"))
|
||||||
} else {
|
} else {
|
||||||
Ok(Token(*mark, TokenType::TagDirectiveToken(handle, prefix)))
|
Ok(Token(*mark, TokenType::TagDirective(handle, prefix)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,7 +710,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
self.lookahead(1);
|
self.lookahead(1);
|
||||||
if is_blankz(self.ch()) {
|
if is_blankz(self.ch()) {
|
||||||
// XXX: ex 7.2, an empty scalar can follow a secondary tag
|
// XXX: ex 7.2, an empty scalar can follow a secondary tag
|
||||||
Ok(Token(start_mark, TokenType::TagToken(handle, suffix)))
|
Ok(Token(start_mark, TokenType::Tag(handle, suffix)))
|
||||||
} else {
|
} else {
|
||||||
Err(ScanError::new(start_mark,
|
Err(ScanError::new(start_mark,
|
||||||
"while scanning a tag, did not find expected whitespace or line break"))
|
"while scanning a tag, did not find expected whitespace or line break"))
|
||||||
|
@ -883,9 +883,9 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if alias {
|
if alias {
|
||||||
Ok(Token(start_mark, TokenType::AliasToken(string)))
|
Ok(Token(start_mark, TokenType::Alias(string)))
|
||||||
} else {
|
} else {
|
||||||
Ok(Token(start_mark, TokenType::AnchorToken(string)))
|
Ok(Token(start_mark, TokenType::Anchor(string)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -924,7 +924,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
let start_mark = self.mark;
|
let start_mark = self.mark;
|
||||||
self.skip();
|
self.skip();
|
||||||
|
|
||||||
self.tokens.push_back(Token(start_mark, TokenType::FlowEntryToken));
|
self.tokens.push_back(Token(start_mark, TokenType::FlowEntry));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -949,7 +949,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
|
|
||||||
let mark = self.mark;
|
let mark = self.mark;
|
||||||
// generate BLOCK-SEQUENCE-START if indented
|
// generate BLOCK-SEQUENCE-START if indented
|
||||||
self.roll_indent(mark.col, None, TokenType::BlockSequenceStartToken, mark);
|
self.roll_indent(mark.col, None, TokenType::BlockSequenceStart, mark);
|
||||||
} else {
|
} else {
|
||||||
// - * only allowed in block
|
// - * only allowed in block
|
||||||
unreachable!();
|
unreachable!();
|
||||||
|
@ -960,7 +960,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
let start_mark = self.mark;
|
let start_mark = self.mark;
|
||||||
self.skip();
|
self.skip();
|
||||||
|
|
||||||
self.tokens.push_back(Token(start_mark, TokenType::BlockEntryToken));
|
self.tokens.push_back(Token(start_mark, TokenType::BlockEntry));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,9 +1119,9 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if literal {
|
if literal {
|
||||||
Ok(Token(start_mark, TokenType::ScalarToken(TScalarStyle::Literal, string)))
|
Ok(Token(start_mark, TokenType::Scalar(TScalarStyle::Literal, string)))
|
||||||
} else {
|
} else {
|
||||||
Ok(Token(start_mark, TokenType::ScalarToken(TScalarStyle::Foled, string)))
|
Ok(Token(start_mark, TokenType::Scalar(TScalarStyle::Foled, string)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1353,9 +1353,9 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
self.skip();
|
self.skip();
|
||||||
|
|
||||||
if single {
|
if single {
|
||||||
Ok(Token(start_mark, TokenType::ScalarToken(TScalarStyle::SingleQuoted, string)))
|
Ok(Token(start_mark, TokenType::Scalar(TScalarStyle::SingleQuoted, string)))
|
||||||
} else {
|
} else {
|
||||||
Ok(Token(start_mark, TokenType::ScalarToken(TScalarStyle::DoubleQuoted, string)))
|
Ok(Token(start_mark, TokenType::Scalar(TScalarStyle::DoubleQuoted, string)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1477,7 +1477,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
self.allow_simple_key();
|
self.allow_simple_key();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Token(start_mark, TokenType::ScalarToken(TScalarStyle::Plain, string)))
|
Ok(Token(start_mark, TokenType::Scalar(TScalarStyle::Plain, string)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fetch_key(&mut self) -> ScanResult {
|
fn fetch_key(&mut self) -> ScanResult {
|
||||||
|
@ -1488,7 +1488,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
return Err(ScanError::new(self.mark, "mapping keys are not allowed in this context"));
|
return Err(ScanError::new(self.mark, "mapping keys are not allowed in this context"));
|
||||||
}
|
}
|
||||||
self.roll_indent(start_mark.col, None,
|
self.roll_indent(start_mark.col, None,
|
||||||
TokenType::BlockMappingStartToken, start_mark);
|
TokenType::BlockMappingStart, start_mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
try!(self.remove_simple_key());
|
try!(self.remove_simple_key());
|
||||||
|
@ -1500,7 +1500,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.skip();
|
self.skip();
|
||||||
self.tokens.push_back(Token(start_mark, TokenType::KeyToken));
|
self.tokens.push_back(Token(start_mark, TokenType::Key));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1509,13 +1509,13 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
let start_mark = self.mark;
|
let start_mark = self.mark;
|
||||||
if sk.possible {
|
if sk.possible {
|
||||||
// insert simple key
|
// insert simple key
|
||||||
let tok = Token(sk.mark, TokenType::KeyToken);
|
let tok = Token(sk.mark, TokenType::Key);
|
||||||
let tokens_parsed = self.tokens_parsed;
|
let tokens_parsed = self.tokens_parsed;
|
||||||
self.insert_token(sk.token_number - tokens_parsed, tok);
|
self.insert_token(sk.token_number - tokens_parsed, tok);
|
||||||
|
|
||||||
// Add the BLOCK-MAPPING-START token if needed.
|
// Add the BLOCK-MAPPING-START token if needed.
|
||||||
self.roll_indent(sk.mark.col, Some(sk.token_number),
|
self.roll_indent(sk.mark.col, Some(sk.token_number),
|
||||||
TokenType::BlockMappingStartToken, start_mark);
|
TokenType::BlockMappingStart, start_mark);
|
||||||
|
|
||||||
self.simple_keys.last_mut().unwrap().possible = false;
|
self.simple_keys.last_mut().unwrap().possible = false;
|
||||||
self.disallow_simple_key();
|
self.disallow_simple_key();
|
||||||
|
@ -1528,7 +1528,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
self.roll_indent(start_mark.col, None,
|
self.roll_indent(start_mark.col, None,
|
||||||
TokenType::BlockMappingStartToken, start_mark);
|
TokenType::BlockMappingStart, start_mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.flow_level == 0 {
|
if self.flow_level == 0 {
|
||||||
|
@ -1538,7 +1538,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.skip();
|
self.skip();
|
||||||
self.tokens.push_back(Token(start_mark, TokenType::ValueToken));
|
self.tokens.push_back(Token(start_mark, TokenType::Value));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -1565,7 +1565,7 @@ impl<T: Iterator<Item=char>> Scanner<T> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while self.indent > col {
|
while self.indent > col {
|
||||||
self.tokens.push_back(Token(self.mark, TokenType::BlockEndToken));
|
self.tokens.push_back(Token(self.mark, TokenType::BlockEnd));
|
||||||
self.indent = self.indents.pop().unwrap();
|
self.indent = self.indents.pop().unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1620,7 +1620,7 @@ macro_rules! next_scalar {
|
||||||
($p:ident, $tk:expr, $v:expr) => {{
|
($p:ident, $tk:expr, $v:expr) => {{
|
||||||
let tok = $p.next().unwrap();
|
let tok = $p.next().unwrap();
|
||||||
match tok.1 {
|
match tok.1 {
|
||||||
ScalarToken(style, ref v) => {
|
Scalar(style, ref v) => {
|
||||||
assert_eq!(style, $tk);
|
assert_eq!(style, $tk);
|
||||||
assert_eq!(v, $v);
|
assert_eq!(v, $v);
|
||||||
},
|
},
|
||||||
|
@ -1640,8 +1640,8 @@ macro_rules! end {
|
||||||
fn test_empty() {
|
fn test_empty() {
|
||||||
let s = "";
|
let s = "";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1649,9 +1649,9 @@ macro_rules! end {
|
||||||
fn test_scalar() {
|
fn test_scalar() {
|
||||||
let s = "a scalar";
|
let s = "a scalar";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, ScalarToken(TScalarStyle::Plain, _));
|
next!(p, Scalar(TScalarStyle::Plain, _));
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1663,11 +1663,11 @@ macro_rules! end {
|
||||||
...
|
...
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, DocumentStartToken);
|
next!(p, DocumentStart);
|
||||||
next!(p, ScalarToken(TScalarStyle::SingleQuoted, _));
|
next!(p, Scalar(TScalarStyle::SingleQuoted, _));
|
||||||
next!(p, DocumentEndToken);
|
next!(p, DocumentEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1682,13 +1682,13 @@ macro_rules! end {
|
||||||
'a scalar'
|
'a scalar'
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, ScalarToken(TScalarStyle::SingleQuoted, _));
|
next!(p, Scalar(TScalarStyle::SingleQuoted, _));
|
||||||
next!(p, DocumentStartToken);
|
next!(p, DocumentStart);
|
||||||
next!(p, ScalarToken(TScalarStyle::SingleQuoted, _));
|
next!(p, Scalar(TScalarStyle::SingleQuoted, _));
|
||||||
next!(p, DocumentStartToken);
|
next!(p, DocumentStart);
|
||||||
next!(p, ScalarToken(TScalarStyle::SingleQuoted, _));
|
next!(p, Scalar(TScalarStyle::SingleQuoted, _));
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1696,15 +1696,15 @@ macro_rules! end {
|
||||||
fn test_a_flow_sequence() {
|
fn test_a_flow_sequence() {
|
||||||
let s = "[item 1, item 2, item 3]";
|
let s = "[item 1, item 2, item 3]";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, FlowSequenceStartToken);
|
next!(p, FlowSequenceStart);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
||||||
next!(p, FlowEntryToken);
|
next!(p, FlowEntry);
|
||||||
next!(p, ScalarToken(TScalarStyle::Plain, _));
|
next!(p, Scalar(TScalarStyle::Plain, _));
|
||||||
next!(p, FlowEntryToken);
|
next!(p, FlowEntry);
|
||||||
next!(p, ScalarToken(TScalarStyle::Plain, _));
|
next!(p, Scalar(TScalarStyle::Plain, _));
|
||||||
next!(p, FlowSequenceEndToken);
|
next!(p, FlowSequenceEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1718,20 +1718,20 @@ macro_rules! end {
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, FlowMappingStartToken);
|
next!(p, FlowMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next!(p, ScalarToken(TScalarStyle::Plain, _));
|
next!(p, Scalar(TScalarStyle::Plain, _));
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, ScalarToken(TScalarStyle::Plain, _));
|
next!(p, Scalar(TScalarStyle::Plain, _));
|
||||||
next!(p, FlowEntryToken);
|
next!(p, FlowEntry);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "a complex key");
|
next_scalar!(p, TScalarStyle::Plain, "a complex key");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, ScalarToken(TScalarStyle::Plain, _));
|
next!(p, Scalar(TScalarStyle::Plain, _));
|
||||||
next!(p, FlowEntryToken);
|
next!(p, FlowEntry);
|
||||||
next!(p, FlowMappingEndToken);
|
next!(p, FlowMappingEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1749,32 +1749,32 @@ macro_rules! end {
|
||||||
key 2: value 2
|
key 2: value 2
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, BlockSequenceStartToken);
|
next!(p, BlockSequenceStart);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 2");
|
next_scalar!(p, TScalarStyle::Plain, "item 2");
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next!(p, BlockSequenceStartToken);
|
next!(p, BlockSequenceStart);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 3.1");
|
next_scalar!(p, TScalarStyle::Plain, "item 3.1");
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 3.2");
|
next_scalar!(p, TScalarStyle::Plain, "item 3.2");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next!(p, BlockMappingStartToken);
|
next!(p, BlockMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "key 1");
|
next_scalar!(p, TScalarStyle::Plain, "key 1");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "value 1");
|
next_scalar!(p, TScalarStyle::Plain, "value 1");
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "key 2");
|
next_scalar!(p, TScalarStyle::Plain, "key 2");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "value 2");
|
next_scalar!(p, TScalarStyle::Plain, "value 2");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1793,40 +1793,40 @@ a sequence:
|
||||||
- item 2
|
- item 2
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, BlockMappingStartToken);
|
next!(p, BlockMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, ValueToken); // libyaml comment seems to be wrong
|
next!(p, Value); // libyaml comment seems to be wrong
|
||||||
next!(p, BlockMappingStartToken);
|
next!(p, BlockMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, BlockSequenceStartToken);
|
next!(p, BlockSequenceStart);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next!(p, ScalarToken(_, _));
|
next!(p, Scalar(_, _));
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1840,17 +1840,17 @@ key:
|
||||||
- item 2
|
- item 2
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, BlockMappingStartToken);
|
next!(p, BlockMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "key");
|
next_scalar!(p, TScalarStyle::Plain, "key");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 2");
|
next_scalar!(p, TScalarStyle::Plain, "item 2");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1866,35 +1866,35 @@ key:
|
||||||
: complex value
|
: complex value
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, BlockSequenceStartToken);
|
next!(p, BlockSequenceStart);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next!(p, BlockSequenceStartToken);
|
next!(p, BlockSequenceStart);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 2");
|
next_scalar!(p, TScalarStyle::Plain, "item 2");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next!(p, BlockMappingStartToken);
|
next!(p, BlockMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "key 1");
|
next_scalar!(p, TScalarStyle::Plain, "key 1");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "value 1");
|
next_scalar!(p, TScalarStyle::Plain, "value 1");
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "key 2");
|
next_scalar!(p, TScalarStyle::Plain, "key 2");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "value 2");
|
next_scalar!(p, TScalarStyle::Plain, "value 2");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next!(p, BlockMappingStartToken);
|
next!(p, BlockMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "complex key");
|
next_scalar!(p, TScalarStyle::Plain, "complex key");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "complex value");
|
next_scalar!(p, TScalarStyle::Plain, "complex value");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1910,32 +1910,32 @@ key:
|
||||||
key 2: value 2
|
key 2: value 2
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, BlockMappingStartToken);
|
next!(p, BlockMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "a sequence");
|
next_scalar!(p, TScalarStyle::Plain, "a sequence");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, BlockSequenceStartToken);
|
next!(p, BlockSequenceStart);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
next_scalar!(p, TScalarStyle::Plain, "item 1");
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "item 2");
|
next_scalar!(p, TScalarStyle::Plain, "item 2");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "a mapping");
|
next_scalar!(p, TScalarStyle::Plain, "a mapping");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, BlockMappingStartToken);
|
next!(p, BlockMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "key 1");
|
next_scalar!(p, TScalarStyle::Plain, "key 1");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "value 1");
|
next_scalar!(p, TScalarStyle::Plain, "value 1");
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "key 2");
|
next_scalar!(p, TScalarStyle::Plain, "key 2");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "value 2");
|
next_scalar!(p, TScalarStyle::Plain, "value 2");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1949,17 +1949,17 @@ key:
|
||||||
}
|
}
|
||||||
";
|
";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, FlowMappingStartToken);
|
next!(p, FlowMappingStart);
|
||||||
next!(p, KeyToken);
|
next!(p, Key);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "foo");
|
next_scalar!(p, TScalarStyle::Plain, "foo");
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next!(p, FlowEntryToken);
|
next!(p, FlowEntry);
|
||||||
next!(p, ValueToken);
|
next!(p, Value);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "bar");
|
next_scalar!(p, TScalarStyle::Plain, "bar");
|
||||||
next!(p, FlowEntryToken);
|
next!(p, FlowEntry);
|
||||||
next!(p, FlowMappingEndToken);
|
next!(p, FlowMappingEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1967,15 +1967,15 @@ key:
|
||||||
fn test_scanner_cr() {
|
fn test_scanner_cr() {
|
||||||
let s = "---\r\n- tok1\r\n- tok2";
|
let s = "---\r\n- tok1\r\n- tok2";
|
||||||
let mut p = Scanner::new(s.chars());
|
let mut p = Scanner::new(s.chars());
|
||||||
next!(p, StreamStartToken(..));
|
next!(p, StreamStart(..));
|
||||||
next!(p, DocumentStartToken);
|
next!(p, DocumentStart);
|
||||||
next!(p, BlockSequenceStartToken);
|
next!(p, BlockSequenceStart);
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "tok1");
|
next_scalar!(p, TScalarStyle::Plain, "tok1");
|
||||||
next!(p, BlockEntryToken);
|
next!(p, BlockEntry);
|
||||||
next_scalar!(p, TScalarStyle::Plain, "tok2");
|
next_scalar!(p, TScalarStyle::Plain, "tok2");
|
||||||
next!(p, BlockEndToken);
|
next!(p, BlockEnd);
|
||||||
next!(p, StreamEndToken);
|
next!(p, StreamEnd);
|
||||||
end!(p);
|
end!(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl EventReceiver for YamlLoader {
|
||||||
Yaml::String(v.clone())
|
Yaml::String(v.clone())
|
||||||
} else {
|
} else {
|
||||||
match tag {
|
match tag {
|
||||||
&Some(TokenType::TagToken(ref handle, ref suffix)) => {
|
&Some(TokenType::Tag(ref handle, ref suffix)) => {
|
||||||
// XXX tag:yaml.org,2002:
|
// XXX tag:yaml.org,2002:
|
||||||
if handle == "!!" {
|
if handle == "!!" {
|
||||||
match suffix.as_ref() {
|
match suffix.as_ref() {
|
||||||
|
|
Loading…
Reference in a new issue