From f2b5946008ea286133ba283321758310c8971560 Mon Sep 17 00:00:00 2001 From: Ethiraric Date: Tue, 26 Dec 2023 18:27:47 +0100 Subject: [PATCH] Add comments to `TokenType` and `Scanner`. --- parser/src/scanner.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/parser/src/scanner.rs b/parser/src/scanner.rs index 9de8771..07c76b5 100644 --- a/parser/src/scanner.rs +++ b/parser/src/scanner.rs @@ -147,15 +147,26 @@ pub enum TokenType { FlowMappingStart, /// End of an inline mapping. FlowMappingEnd, + /// An entry in a block sequence (c.f.: [`TokenType::BlockSequenceStart`]). BlockEntry, + /// An entry in a flow sequence (c.f.: [`TokenType::FlowSequenceStart`]). FlowEntry, + /// A key in a mapping. Key, + /// A value in a mapping. Value, + /// A reference to an anchor. Alias(String), /// A YAML anchor (`&`/`*`). Anchor(String), - /// handle, suffix - Tag(String, String), + /// A YAML tag (starting with bangs `!`). + Tag( + /// The handle of the tag. + String, + /// The suffix of the tag. + String, + ), + /// A regular YAML scalar. Scalar(TScalarStyle, String), } @@ -209,10 +220,15 @@ struct Indent { #[derive(Debug)] #[allow(clippy::struct_excessive_bools)] pub struct Scanner { + /// The reader, providing with characters. rdr: T, + /// The position of the cursor within the reader. mark: Marker, + /// Buffer for tokens to be read. tokens: VecDeque, + /// Buffer for the next characters to consume. buffer: VecDeque, + /// The last error that happened. error: Option, /// Whether we have already emitted the `StreamStart` token.