1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use rowan::Language;
/// A lossless syntax node or token category.
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[repr(u16)]
pub enum SyntaxKind {
/// The complete document node.
Root,
/// A key-value statement node.
KeyValue,
/// A dotted key node.
Key,
/// A scalar or container value node.
Value,
/// A table header node.
Table,
/// An array-of-tables header node.
ArrayTable,
/// Horizontal whitespace token.
Whitespace,
/// A source newline token.
Newline,
/// A comment token.
Comment,
/// An unquoted token used for bare keys and non-string values.
Bare,
/// A basic or multiline-basic string token.
BasicString,
/// A literal or multiline-literal string token.
LiteralString,
/// The equals-sign token.
Equals,
/// The dotted-key separator token.
Dot,
/// The container item separator token.
Comma,
/// A left square-bracket token.
LeftBracket,
/// A right square-bracket token.
RightBracket,
/// A left brace token.
LeftBrace,
/// A right brace token.
RightBrace,
/// An array value node.
Array,
/// An inline-table value node.
InlineTable,
/// A UTF-8 byte-order mark token at the start of the document.
Bom,
/// Invalid or otherwise unclassified source bytes.
Invalid,
}
impl From<SyntaxKind> for rowan::SyntaxKind {
fn from(kind: SyntaxKind) -> Self {
Self(kind as u16)
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub(crate) enum TomlLanguage {}
impl Language for TomlLanguage {
type Kind = SyntaxKind;
fn kind_from_raw(raw: rowan::SyntaxKind) -> Self::Kind {
match raw.0 {
0 => SyntaxKind::Root,
1 => SyntaxKind::KeyValue,
2 => SyntaxKind::Key,
3 => SyntaxKind::Value,
4 => SyntaxKind::Table,
5 => SyntaxKind::ArrayTable,
6 => SyntaxKind::Whitespace,
7 => SyntaxKind::Newline,
8 => SyntaxKind::Comment,
9 => SyntaxKind::Bare,
10 => SyntaxKind::BasicString,
11 => SyntaxKind::LiteralString,
12 => SyntaxKind::Equals,
13 => SyntaxKind::Dot,
14 => SyntaxKind::Comma,
15 => SyntaxKind::LeftBracket,
16 => SyntaxKind::RightBracket,
17 => SyntaxKind::LeftBrace,
18 => SyntaxKind::RightBrace,
19 => SyntaxKind::Array,
20 => SyntaxKind::InlineTable,
21 => SyntaxKind::Bom,
_ => SyntaxKind::Invalid,
}
}
fn kind_to_raw(kind: Self::Kind) -> rowan::SyntaxKind {
kind.into()
}
}