oak_purescript/kind/
mod.rs

1use oak_core::SyntaxKind;
2use serde::Serialize;
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize)]
5pub enum PurescriptSyntaxKind {
6    // Whitespace and comments
7    Whitespace,
8    Newline,
9    Comment,
10
11    // Keywords
12    Ado,
13    Case,
14    Class,
15    Data,
16    Derive,
17    Do,
18    Else,
19    False,
20    Forall,
21    Foreign,
22    If,
23    Import,
24    In,
25    Infix,
26    Infixl,
27    Infixr,
28    Instance,
29    Let,
30    Module,
31    Newtype,
32    Of,
33    Then,
34    True,
35    Type,
36    Where,
37
38    // Operators
39    Arrow,          // ->
40    FatArrow,       // =>
41    Backslash,      // \
42    Pipe,           // |
43    Equal,          // =
44    ColonColon,     // ::
45    Dot,            // .
46    DotDot,         // ..
47    Plus,           // +
48    Minus,          // -
49    Star,           // *
50    Slash,          // /
51    Percent,        // %
52    Caret,          // ^
53    EqualEqual,     // ==
54    NotEqual,       // /=
55    Less,           // <
56    Greater,        // >
57    LessEqual,      // <=
58    GreaterEqual,   // >=
59    And,            // &&
60    Or,             // ||
61    Append,         // <>
62    Compose,        // <<<
63    ComposeFlipped, // >>>
64    Apply,          // <$>
65    ApplyFlipped,   // <*>
66    Bind,           // >>=
67    BindFlipped,    // =<<
68
69    // Punctuation
70    LeftParen,    // (
71    RightParen,   // )
72    LeftBrace,    // {
73    RightBrace,   // }
74    LeftBracket,  // [
75    RightBracket, // ]
76    Comma,        // ,
77    Semicolon,    // ;
78    Colon,        // :
79    Question,     // ?
80    Exclamation,  // !
81    At,           // @
82    Underscore,   // _
83    Backtick,     // `
84
85    // Literals
86    IntLiteral,
87    NumberLiteral,
88    StringLiteral,
89    CharLiteral,
90    BooleanLiteral,
91
92    // Identifiers
93    Identifier,
94    UpperIdentifier,
95    Operator,
96    QualifiedIdentifier,
97
98    // Special
99    Root,
100    Error,
101    Eof,
102}
103
104impl SyntaxKind for PurescriptSyntaxKind {
105    fn is_trivia(&self) -> bool {
106        matches!(self, Self::Whitespace | Self::Newline | Self::Comment)
107    }
108
109    fn is_comment(&self) -> bool {
110        matches!(self, Self::Comment)
111    }
112
113    fn is_whitespace(&self) -> bool {
114        matches!(self, Self::Whitespace | Self::Newline)
115    }
116
117    fn is_token_type(&self) -> bool {
118        !matches!(self, Self::Root)
119    }
120
121    fn is_element_type(&self) -> bool {
122        matches!(self, Self::Root)
123    }
124}