1use oak_core::{ElementType, Token, TokenType, UniversalElementRole, UniversalTokenRole};
2use serde::Serialize;
3
4pub type ObjectiveCToken = Token<ObjectiveCSyntaxKind>;
5
6#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Serialize, serde::Deserialize)]
7pub enum ObjectiveCSyntaxKind {
8 Root,
10 InterfaceDeclaration,
11 ImplementationDeclaration,
12 MethodDeclaration,
13 PropertyDeclaration,
14 ProtocolDeclaration,
15 CategoryDeclaration,
16 ClassExtension,
17
18 InterfaceKeyword,
20 ImplementationKeyword,
21 EndKeyword,
22 PropertyKeyword,
23 SynthesizeKeyword,
24 DynamicKeyword,
25 ProtocolKeyword,
26 CategoryKeyword,
27 ImportKeyword,
28 IncludeKeyword,
29 IfKeyword,
30 ElseKeyword,
31 ForKeyword,
32 WhileKeyword,
33 DoKeyword,
34 SwitchKeyword,
35 CaseKeyword,
36 DefaultKeyword,
37 BreakKeyword,
38 ContinueKeyword,
39 ReturnKeyword,
40 VoidKeyword,
41 IntKeyword,
42 FloatKeyword,
43 DoubleKeyword,
44 CharKeyword,
45 BoolKeyword,
46 IdKeyword,
47 SelfKeyword,
48 SuperKeyword,
49 NilKeyword,
50 YesKeyword,
51 NoKeyword,
52
53 LeftParen,
55 RightParen,
56 LeftBrace,
57 RightBrace,
58 LeftBracket,
59 RightBracket,
60 Semicolon,
61 Comma,
62 Dot,
63 Colon,
64 Plus,
65 Minus,
66 Star,
67 Slash,
68 Percent,
69 Equal,
70 EqualEqual,
71 NotEqual,
72 Less,
73 Greater,
74 LessEqual,
75 GreaterEqual,
76 And,
77 Or,
78 Not,
79 Question,
80 At,
81
82 Identifier,
84 IntegerLiteral,
85 FloatLiteral,
86 String,
87 Character,
88
89 Whitespace,
91 Newline,
92 CommentToken,
93 Error,
94 Eof,
95}
96
97impl TokenType for ObjectiveCSyntaxKind {
98 const END_OF_STREAM: Self = Self::Eof;
99 type Role = UniversalTokenRole;
100
101 fn role(&self) -> Self::Role {
102 match self {
103 Self::Whitespace | Self::Newline => UniversalTokenRole::Whitespace,
104 Self::CommentToken => UniversalTokenRole::Comment,
105 Self::Eof => UniversalTokenRole::Eof,
106 _ => UniversalTokenRole::None,
107 }
108 }
109}
110
111impl ElementType for ObjectiveCSyntaxKind {
112 type Role = UniversalElementRole;
113
114 fn role(&self) -> Self::Role {
115 match self {
116 Self::Error => UniversalElementRole::Error,
117 _ => UniversalElementRole::None,
118 }
119 }
120}