Skip to main content

oak_purescript/kind/
mod.rs

1use oak_core::{ElementType, TokenType, UniversalElementRole, UniversalTokenRole};
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    SourceFile,
101    Error,
102    Eof,
103}
104
105impl TokenType for PurescriptSyntaxKind {
106    const END_OF_STREAM: Self = Self::Eof;
107    type Role = UniversalTokenRole;
108
109    fn role(&self) -> Self::Role {
110        match self {
111            Self::Whitespace | Self::Newline => UniversalTokenRole::Whitespace,
112            Self::Comment => UniversalTokenRole::Comment,
113            Self::Eof => UniversalTokenRole::Eof,
114            _ => UniversalTokenRole::None,
115        }
116    }
117}
118
119impl ElementType for PurescriptSyntaxKind {
120    type Role = UniversalElementRole;
121
122    fn role(&self) -> Self::Role {
123        match self {
124            Self::Root | Self::SourceFile => UniversalElementRole::Root,
125            Self::Error => UniversalElementRole::Error,
126            _ => UniversalElementRole::None,
127        }
128    }
129}