use super::Mark;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(super) enum TokenType {
StreamStart,
StreamEnd,
VersionDirective,
TagDirective,
DocumentStart,
DocumentEnd,
BlockSequenceStart,
BlockMappingStart,
BlockEnd,
FlowSequenceStart,
FlowSequenceEnd,
FlowMappingStart,
FlowMappingEnd,
BlockEntry,
FlowEntry,
Key,
Value,
Alias,
Anchor,
Tag,
Scalar,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub(super) enum ScalarStyle {
#[default]
Plain,
Single,
Double,
Literal,
Folded,
}
#[derive(Debug, Clone)]
pub(super) struct Token {
pub(super) typ: TokenType,
pub(super) start_mark: Mark,
pub(super) end_mark: Mark,
pub(super) value: Vec<u8>,
pub(super) suffix: Vec<u8>,
pub(super) prefix: Vec<u8>,
pub(super) style: ScalarStyle,
pub(super) major: i8,
pub(super) minor: i8,
}
impl Token {
pub(super) fn new(typ: TokenType, start_mark: Mark, end_mark: Mark) -> Self {
Self {
typ,
start_mark,
end_mark,
value: Vec::new(),
suffix: Vec::new(),
prefix: Vec::new(),
style: ScalarStyle::Plain,
major: 0,
minor: 0,
}
}
}
#[derive(Debug, Clone, Default)]
pub(super) struct Comment {
pub(super) scan_mark: Mark,
pub(super) token_mark: Mark,
pub(super) start_mark: Mark,
pub(super) end_mark: Mark,
pub(super) head: Vec<u8>,
pub(super) line: Vec<u8>,
pub(super) foot: Vec<u8>,
}
#[derive(Debug, Clone, Copy, Default)]
pub(super) struct SimpleKey {
pub(super) possible: bool,
pub(super) required: bool,
pub(super) token_number: usize,
pub(super) mark: Mark,
}