biofriction-wp-theme/node_modules/highlight.js/lib/languages/objectivec.js

78 lines
2.3 KiB
JavaScript
Raw Normal View History

2021-10-26 14:18:09 +02:00
module.exports = function(hljs) {
var API_CLASS = {
className: 'built_in',
begin: '(AV|CA|CF|CG|CI|MK|MP|NS|UI)\\w+',
};
var OBJC_KEYWORDS = {
keyword:
'int float while char export sizeof typedef const struct for union ' +
'unsigned long volatile static bool mutable if do return goto void ' +
'enum else break extern asm case short default double register explicit ' +
'signed typename this switch continue wchar_t inline readonly assign ' +
'readwrite self @synchronized id typeof ' +
'nonatomic super unichar IBOutlet IBAction strong weak copy ' +
'in out inout bycopy byref oneway __strong __weak __block __autoreleasing ' +
'@private @protected @public @try @property @end @throw @catch @finally ' +
'@autoreleasepool @synthesize @dynamic @selector @optional @required',
literal:
'false true FALSE TRUE nil YES NO NULL',
built_in:
'BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once'
};
var LEXEMES = /[a-zA-Z@][a-zA-Z0-9_]*/;
var CLASS_KEYWORDS = '@interface @class @protocol @implementation';
return {
aliases: ['mm', 'objc', 'obj-c'],
keywords: OBJC_KEYWORDS,
lexemes: LEXEMES,
illegal: '</',
contains: [
API_CLASS,
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_NUMBER_MODE,
hljs.QUOTE_STRING_MODE,
{
className: 'string',
variants: [
{
begin: '@"', end: '"',
illegal: '\\n',
contains: [hljs.BACKSLASH_ESCAPE]
},
{
begin: '\'', end: '[^\\\\]\'',
illegal: '[^\\\\][^\']'
}
]
},
{
className: 'preprocessor',
begin: '#',
end: '$',
contains: [
{
className: 'title',
variants: [
{ begin: '\"', end: '\"' },
{ begin: '<', end: '>' }
]
}
]
},
{
className: 'class',
begin: '(' + CLASS_KEYWORDS.split(' ').join('|') + ')\\b', end: '({|$)', excludeEnd: true,
keywords: CLASS_KEYWORDS, lexemes: LEXEMES,
contains: [
hljs.UNDERSCORE_TITLE_MODE
]
},
{
className: 'variable',
begin: '\\.'+hljs.UNDERSCORE_IDENT_RE,
relevance: 0
}
]
};
};