oak_prolog/kind/
mod.rs

1use oak_core::SyntaxKind;
2use serde::Serialize;
3
4#[derive(Copy, Clone, Debug, PartialEq, Eq, Serialize)]
5pub enum PrologSyntaxKind {
6    // Whitespace and comments
7    Whitespace,
8    Newline,
9    Comment,
10
11    // Literals
12    Atom,
13    Integer,
14    Float,
15    String,
16    Variable,
17
18    // Operators
19    Unify,         // =
20    NotUnify,      // \=
21    Equal,         // ==
22    NotEqual,      // \==
23    ArithEqual,    // =:=
24    ArithNotEqual, // =\=
25    Less,          // <
26    Greater,       // >
27    LessEqual,     // =<
28    GreaterEqual,  // >=
29    Is,            // is
30    Plus,          // +
31    Minus,         // -
32    Multiply,      // *
33    Divide,        // /
34    IntDivide,     // //
35    Modulo,        // mod
36    Power,         // **
37    BitwiseAnd,    // /\
38    BitwiseOr,     // \/
39    BitwiseXor,    // xor
40    BitwiseNot,    // \
41    LeftShift,     // <<
42    RightShift,    // >>
43
44    // Punctuation
45    LeftParen,     // (
46    RightParen,    // )
47    LeftBracket,   // [
48    RightBracket,  // ]
49    LeftBrace,     // {
50    RightBrace,    // }
51    Comma,         // ,
52    Dot,           // .
53    Pipe,          // |
54    Semicolon,     // ;
55    Cut,           // !
56    Question,      // ?
57    Colon,         // :
58    ColonMinus,    // :-
59    QuestionMinus, // ?-
60
61    // Special constructs
62    Functor,
63    Clause,
64    Rule,
65    Fact,
66    Query,
67    Directive,
68    List,
69    Structure,
70
71    // Special
72    Root,
73    Error,
74    Eof,
75}
76
77impl SyntaxKind for PrologSyntaxKind {
78    fn is_trivia(&self) -> bool {
79        matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
80    }
81
82    fn is_comment(&self) -> bool {
83        matches!(self, Self::Comment)
84    }
85
86    fn is_whitespace(&self) -> bool {
87        matches!(self, Self::Whitespace | Self::Newline)
88    }
89
90    fn is_token_type(&self) -> bool {
91        !matches!(
92            self,
93            Self::Root | Self::Clause | Self::Rule | Self::Fact | Self::Query | Self::Directive | Self::List | Self::Structure
94        )
95    }
96
97    fn is_element_type(&self) -> bool {
98        matches!(
99            self,
100            Self::Root | Self::Clause | Self::Rule | Self::Fact | Self::Query | Self::Directive | Self::List | Self::Structure
101        )
102    }
103}