]> luflow.net public git repositories - flow-web.git/blob - static/highlight/es/languages/objectivec.js
Initial commit.
[flow-web.git] / static / highlight / es / languages / objectivec.js
1 /*! `objectivec` grammar compiled for Highlight.js 11.11.1 */
2 var hljsGrammar = (function () {
3 'use strict';
4
5 /*
6 Language: Objective-C
7 Author: Valerii Hiora <valerii.hiora@gmail.com>
8 Contributors: Angel G. Olloqui <angelgarcia.mail@gmail.com>, Matt Diephouse <matt@diephouse.com>, Andrew Farmer <ahfarmer@gmail.com>, Minh Nguyễn <mxn@1ec5.org>
9 Website: https://developer.apple.com/documentation/objectivec
10 Category: common
11 */
12
13 function objectivec(hljs) {
14 const API_CLASS = {
15 className: 'built_in',
16 begin: '\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+'
17 };
18 const IDENTIFIER_RE = /[a-zA-Z@][a-zA-Z0-9_]*/;
19 const TYPES = [
20 "int",
21 "float",
22 "char",
23 "unsigned",
24 "signed",
25 "short",
26 "long",
27 "double",
28 "wchar_t",
29 "unichar",
30 "void",
31 "bool",
32 "BOOL",
33 "id|0",
34 "_Bool"
35 ];
36 const KWS = [
37 "while",
38 "export",
39 "sizeof",
40 "typedef",
41 "const",
42 "struct",
43 "for",
44 "union",
45 "volatile",
46 "static",
47 "mutable",
48 "if",
49 "do",
50 "return",
51 "goto",
52 "enum",
53 "else",
54 "break",
55 "extern",
56 "asm",
57 "case",
58 "default",
59 "register",
60 "explicit",
61 "typename",
62 "switch",
63 "continue",
64 "inline",
65 "readonly",
66 "assign",
67 "readwrite",
68 "self",
69 "@synchronized",
70 "id",
71 "typeof",
72 "nonatomic",
73 "IBOutlet",
74 "IBAction",
75 "strong",
76 "weak",
77 "copy",
78 "in",
79 "out",
80 "inout",
81 "bycopy",
82 "byref",
83 "oneway",
84 "__strong",
85 "__weak",
86 "__block",
87 "__autoreleasing",
88 "@private",
89 "@protected",
90 "@public",
91 "@try",
92 "@property",
93 "@end",
94 "@throw",
95 "@catch",
96 "@finally",
97 "@autoreleasepool",
98 "@synthesize",
99 "@dynamic",
100 "@selector",
101 "@optional",
102 "@required",
103 "@encode",
104 "@package",
105 "@import",
106 "@defs",
107 "@compatibility_alias",
108 "__bridge",
109 "__bridge_transfer",
110 "__bridge_retained",
111 "__bridge_retain",
112 "__covariant",
113 "__contravariant",
114 "__kindof",
115 "_Nonnull",
116 "_Nullable",
117 "_Null_unspecified",
118 "__FUNCTION__",
119 "__PRETTY_FUNCTION__",
120 "__attribute__",
121 "getter",
122 "setter",
123 "retain",
124 "unsafe_unretained",
125 "nonnull",
126 "nullable",
127 "null_unspecified",
128 "null_resettable",
129 "class",
130 "instancetype",
131 "NS_DESIGNATED_INITIALIZER",
132 "NS_UNAVAILABLE",
133 "NS_REQUIRES_SUPER",
134 "NS_RETURNS_INNER_POINTER",
135 "NS_INLINE",
136 "NS_AVAILABLE",
137 "NS_DEPRECATED",
138 "NS_ENUM",
139 "NS_OPTIONS",
140 "NS_SWIFT_UNAVAILABLE",
141 "NS_ASSUME_NONNULL_BEGIN",
142 "NS_ASSUME_NONNULL_END",
143 "NS_REFINED_FOR_SWIFT",
144 "NS_SWIFT_NAME",
145 "NS_SWIFT_NOTHROW",
146 "NS_DURING",
147 "NS_HANDLER",
148 "NS_ENDHANDLER",
149 "NS_VALUERETURN",
150 "NS_VOIDRETURN"
151 ];
152 const LITERALS = [
153 "false",
154 "true",
155 "FALSE",
156 "TRUE",
157 "nil",
158 "YES",
159 "NO",
160 "NULL"
161 ];
162 const BUILT_INS = [
163 "dispatch_once_t",
164 "dispatch_queue_t",
165 "dispatch_sync",
166 "dispatch_async",
167 "dispatch_once"
168 ];
169 const KEYWORDS = {
170 "variable.language": [
171 "this",
172 "super"
173 ],
174 $pattern: IDENTIFIER_RE,
175 keyword: KWS,
176 literal: LITERALS,
177 built_in: BUILT_INS,
178 type: TYPES
179 };
180 const CLASS_KEYWORDS = {
181 $pattern: IDENTIFIER_RE,
182 keyword: [
183 "@interface",
184 "@class",
185 "@protocol",
186 "@implementation"
187 ]
188 };
189 return {
190 name: 'Objective-C',
191 aliases: [
192 'mm',
193 'objc',
194 'obj-c',
195 'obj-c++',
196 'objective-c++'
197 ],
198 keywords: KEYWORDS,
199 illegal: '</',
200 contains: [
201 API_CLASS,
202 hljs.C_LINE_COMMENT_MODE,
203 hljs.C_BLOCK_COMMENT_MODE,
204 hljs.C_NUMBER_MODE,
205 hljs.QUOTE_STRING_MODE,
206 hljs.APOS_STRING_MODE,
207 {
208 className: 'string',
209 variants: [
210 {
211 begin: '@"',
212 end: '"',
213 illegal: '\\n',
214 contains: [ hljs.BACKSLASH_ESCAPE ]
215 }
216 ]
217 },
218 {
219 className: 'meta',
220 begin: /#\s*[a-z]+\b/,
221 end: /$/,
222 keywords: { keyword:
223 'if else elif endif define undef warning error line '
224 + 'pragma ifdef ifndef include' },
225 contains: [
226 {
227 begin: /\\\n/,
228 relevance: 0
229 },
230 hljs.inherit(hljs.QUOTE_STRING_MODE, { className: 'string' }),
231 {
232 className: 'string',
233 begin: /<.*?>/,
234 end: /$/,
235 illegal: '\\n'
236 },
237 hljs.C_LINE_COMMENT_MODE,
238 hljs.C_BLOCK_COMMENT_MODE
239 ]
240 },
241 {
242 className: 'class',
243 begin: '(' + CLASS_KEYWORDS.keyword.join('|') + ')\\b',
244 end: /(\{|$)/,
245 excludeEnd: true,
246 keywords: CLASS_KEYWORDS,
247 contains: [ hljs.UNDERSCORE_TITLE_MODE ]
248 },
249 {
250 begin: '\\.' + hljs.UNDERSCORE_IDENT_RE,
251 relevance: 0
252 }
253 ]
254 };
255 }
256
257 return objectivec;
258
259 })();
260 ;
261 export default hljsGrammar;