This repository was archived by the owner on Jun 18, 2025. It is now read-only.
forked from intitni/CopilotForXcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObjectiveCSyntax.swift
More file actions
132 lines (130 loc) · 4.31 KB
/
ObjectiveCSyntax.swift
File metadata and controls
132 lines (130 loc) · 4.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
import Foundation
/// https://github.com/merico-dev/tree-sitter-objc/test/corpus/imports.txt
/// https://github.com/merico-dev/tree-sitter-objc/test/corpus/expressions.txt
/// https://github.com/merico-dev/tree-sitter-objc/test/corpus/declarations.txt
/// https://github.com/merico-dev/tree-sitter-objc/node-types.json
enum ObjectiveCNodeType: String {
/// The top most item
case translationUnit = "translation_unit"
/// `#include`
case preprocInclude = "preproc_include"
/// `#import "bar.h"`
case preprocImport = "preproc_import"
/// `@import foo.bar`
case moduleImport = "module_import"
/// ```objc
/// @interface ClassName(Category)<Protocol1, Protocol2>: SuperClass {
/// type1 iv1;
/// type2 iv2;
/// }
/// @property (readwrite, copy) float value;
/// + (tr)k1:(t1)a1 : (t2)a2 k2: a3;
/// @end
/// ```
///
/// will parse into:
/// ```
/// (translation_unit
/// (class_interface
/// name: (identifier)
/// superclass: (identifier))) < SuperClass
/// protocols: (protocol_reference_list < Protocols
/// (identifier)
/// (identifier))))
/// (field_declaration < iv1
/// type: (type_identifier)
/// declarator: (field_identifier))
/// (field_declaration < iv2
/// type: (type_identifier)
/// declarator: (field_identifier))))
/// (property_declaration ...) < property value
/// (method_declaration ...) < method
/// ```
///
case classInterface = "class_interface"
/// `@implementation`
case classImplementation = "class_implementation"
/// Similar to class interface.
case categoryInterface = "category_interface"
/// Similar to class implementation.
case categoryImplementation = "category_implementation"
/// Similar to class interface.
case protocolDeclaration = "protocol_declaration"
/// `@protocol <P1, P2>`
case protocolDeclarationList = "protocol_declaration_list"
/// ```objc
/// @class C1, C2;
/// ```
///
/// will parse into:
/// ```
/// (translation_unit
/// (class_declaration_list
/// (identifier)
/// (identifier)))
/// ```
case classDeclarationList = "class_declaration_list"
/// ```
/// + (tr)k1: (t1)a1 : (t2)a2 k2: a3;
/// ```
///
/// will parse into:
/// ```
/// (property_declaration
/// (readwrite)
/// (copy)
/// type: (type_identifier) < type
/// name: (identifier)))) < name
/// ```
case propertyDeclaration = "property_declaration"
/// ```objc
/// + (tr)k1: (t1)a1 : (t2)a2 k2: a3;
/// ```
///
/// will parse into:
/// ```
/// (method_declaration
/// scope: (class_scope)
/// return_type: (type_descriptor
/// type: (type_identifier))
/// selector: (keyword_selector
/// (keyword_declarator
/// keyword: (identifier)
/// type: (type_descriptor
/// type: (type_identifier))
/// name: (identifier))
/// (keyword_declarator
/// type: (type_descriptor
/// type: (type_identifier))
/// name: (identifier))
/// (keyword_declarator
/// keyword: (identifier)
/// name: (identifier))))))
/// ```
case methodDeclaration = "method_declaration"
/// `- (rt)sel {}`
case methodDefinition = "method_definition"
/// function definitions
case functionDefinition = "function_definition"
/// Names of symbols
case identifier = "identifier"
/// Type identifiers
case typeIdentifier = "type_identifier"
/// Compound statements, such as `{ ... }`
case compoundStatement = "compound_statement"
/// Typedef.
case typeDefinition = "type_definition"
/// `struct {}`.
case structSpecifier = "struct_specifier"
/// `enum {}`.
case enumSpecifier = "enum_specifier"
/// `NS_ENUM {}` and `NS_OPTIONS {}`.
case nsEnumSpecifier = "ns_enum_specifier"
/// fields inside a type definition.
case fieldDeclarationList = "field_declaration_list"
}
extension ObjectiveCNodeType {
init?(rawValue: String?) {
self.init(rawValue: rawValue ?? "")
}
}