lib/scanner: document Scanner.value, allow bare ':' in flow context

as the flow context does not require a Value (':') token is followed by
whitespace of some kind
This commit is contained in:
Paul Stemmet 2021-08-01 08:24:36 +00:00 committed by Paul Stemmet
parent 349e62be0a
commit 90d2ac8a06

View file

@ -132,7 +132,10 @@ impl Scanner
[ANCHOR, ..] | [ALIAS, ..] => self.anchor(base, tokens),
[TAG, ..] => self.tag(base, tokens),
[SINGLE, ..] | [DOUBLE, ..] => self.flow_scalar(base, tokens),
[VALUE, ..] if isWhiteSpaceZ!(~base, 1) => self.value(base, tokens),
[VALUE, ..] if isWhiteSpaceZ!(~base, 1) || self.context.is_flow() =>
{
self.value(base, tokens)
},
[b @ FLOW_MAPPING_START, ..] | [b @ FLOW_SEQUENCE_START, ..] =>
{
self.flow_collection_start(base, tokens, *b == FLOW_MAPPING_START)
@ -425,6 +428,9 @@ impl Scanner
Ok(())
}
/// Fetch a value token (':') from .base, adding to
/// .tokens. Also handles unwinding any saved
/// keys and indentation increases, as needed
fn value<'de>(&mut self, base: &mut &'de str, tokens: &mut Tokens<'de>) -> Result<()>
{
// If we found a simple key