oak_dot/kind/
mod.rs

1use oak_core::{SyntaxKind, Token};
2
3pub type DotToken = Token<DotSyntaxKind>;
4
5/// DOT 语法种类(Graphviz
6#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, serde::Serialize)]
7pub enum DotSyntaxKind {
8    // 基本 kind
9    Identifier,
10    String,
11    Number,
12    Whitespace,
13    Newline,
14
15    // DOT 关键字
16    Graph,
17    Digraph,
18    Subgraph,
19    Node,
20    Edge,
21    Strict,
22
23    // 操作符
24    Arrow,     // ->
25    Line,      // --
26    Equal,     // =
27    Semicolon, // ;
28    Comma,     // ,
29
30    // 分隔符
31    LeftBrace,    // {
32    RightBrace,   // }
33    LeftBracket,  // [
34    RightBracket, // ]
35    LeftParen,    // (
36    RightParen,   // )
37
38    // 注释
39    Comment,
40
41    // 特殊
42    Error,
43    Eof,
44}
45
46impl SyntaxKind for DotSyntaxKind {
47    fn is_trivia(&self) -> bool {
48        matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
49    }
50
51    fn is_comment(&self) -> bool {
52        matches!(self, Self::Comment)
53    }
54
55    fn is_whitespace(&self) -> bool {
56        matches!(self, Self::Whitespace | Self::Newline)
57    }
58
59    fn is_token_type(&self) -> bool {
60        !matches!(self, Self::Error | Self::Eof)
61    }
62
63    fn is_element_type(&self) -> bool {
64        matches!(self, Self::Error | Self::Eof)
65    }
66}