use rowan::SmolStr;
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Element {
#[allow(dead_code)]
Node(TomlNode),
Token(TomlToken),
}
impl PartialEq<TomlNode> for Element {
fn eq(&self, other: &TomlNode) -> bool {
match self {
Element::Node(n) => n == other,
Element::Token(_) => false,
}
}
}
impl PartialEq<TomlToken> for Element {
fn eq(&self, other: &TomlToken) -> bool {
match self {
Element::Token(tkn) => tkn == other,
Element::Node(_) => false,
}
}
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TomlNode {
pub(crate) kind: TomlKind,
pub(crate) text: SmolStr,
}
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct TomlToken {
pub(crate) kind: TomlKind,
pub(crate) text: SmolStr,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[repr(u16)]
pub enum TomlKind {
CommentText = 0,
Integer,
Bool,
Ident,
SingleQuote,
DoubleQuote,
TripleQuote,
Plus,
Minus,
Equal,
Hash,
Dot,
Comma,
Colon,
OpenCurly,
CloseCurly,
OpenBrace,
CloseBrace,
Whitespace,
EoF,
Table,
Heading,
ArrayHeading,
SegIdent,
InlineTable,
KeyValue,
Key,
Value,
Array,
ArrayItem,
Date,
Float,
Str,
Comment,
Root,
}