l0bsterssg

node.js static responsive blog post generator
Log | Files | Refs | README

objectivec.js (3886B)


      1 /*
      2 Language: Objective-C
      3 Author: Valerii Hiora <valerii.hiora@gmail.com>
      4 Contributors: Angel G. Olloqui <angelgarcia.mail@gmail.com>, Matt Diephouse <matt@diephouse.com>, Andrew Farmer <ahfarmer@gmail.com>, Minh Nguyễn <mxn@1ec5.org>
      5 Website: https://developer.apple.com/documentation/objectivec
      6 Category: common
      7 */
      8 
      9 function objectivec(hljs) {
     10   var API_CLASS = {
     11     className: 'built_in',
     12     begin: '\\b(AV|CA|CF|CG|CI|CL|CM|CN|CT|MK|MP|MTK|MTL|NS|SCN|SK|UI|WK|XC)\\w+',
     13   };
     14   var IDENTIFIER_RE = /[a-zA-Z@][a-zA-Z0-9_]*/;
     15   var OBJC_KEYWORDS = {
     16     $pattern: IDENTIFIER_RE,
     17     keyword:
     18       'int float while char export sizeof typedef const struct for union ' +
     19       'unsigned long volatile static bool mutable if do return goto void ' +
     20       'enum else break extern asm case short default double register explicit ' +
     21       'signed typename this switch continue wchar_t inline readonly assign ' +
     22       'readwrite self @synchronized id typeof ' +
     23       'nonatomic super unichar IBOutlet IBAction strong weak copy ' +
     24       'in out inout bycopy byref oneway __strong __weak __block __autoreleasing ' +
     25       '@private @protected @public @try @property @end @throw @catch @finally ' +
     26       '@autoreleasepool @synthesize @dynamic @selector @optional @required ' +
     27       '@encode @package @import @defs @compatibility_alias ' +
     28       '__bridge __bridge_transfer __bridge_retained __bridge_retain ' +
     29       '__covariant __contravariant __kindof ' +
     30       '_Nonnull _Nullable _Null_unspecified ' +
     31       '__FUNCTION__ __PRETTY_FUNCTION__ __attribute__ ' +
     32       'getter setter retain unsafe_unretained ' +
     33       'nonnull nullable null_unspecified null_resettable class instancetype ' +
     34       'NS_DESIGNATED_INITIALIZER NS_UNAVAILABLE NS_REQUIRES_SUPER ' +
     35       'NS_RETURNS_INNER_POINTER NS_INLINE NS_AVAILABLE NS_DEPRECATED ' +
     36       'NS_ENUM NS_OPTIONS NS_SWIFT_UNAVAILABLE ' +
     37       'NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_END ' +
     38       'NS_REFINED_FOR_SWIFT NS_SWIFT_NAME NS_SWIFT_NOTHROW ' +
     39       'NS_DURING NS_HANDLER NS_ENDHANDLER NS_VALUERETURN NS_VOIDRETURN',
     40     literal:
     41       'false true FALSE TRUE nil YES NO NULL',
     42     built_in:
     43       'BOOL dispatch_once_t dispatch_queue_t dispatch_sync dispatch_async dispatch_once'
     44   };
     45   var CLASS_KEYWORDS = {
     46     $pattern: IDENTIFIER_RE,
     47     keyword: '@interface @class @protocol @implementation'
     48   };
     49   return {
     50     name: 'Objective-C',
     51     aliases: ['mm', 'objc', 'obj-c'],
     52     keywords: OBJC_KEYWORDS,
     53     illegal: '</',
     54     contains: [
     55       API_CLASS,
     56       hljs.C_LINE_COMMENT_MODE,
     57       hljs.C_BLOCK_COMMENT_MODE,
     58       hljs.C_NUMBER_MODE,
     59       hljs.QUOTE_STRING_MODE,
     60       hljs.APOS_STRING_MODE,
     61       {
     62         className: 'string',
     63         variants: [
     64           {
     65             begin: '@"', end: '"',
     66             illegal: '\\n',
     67             contains: [hljs.BACKSLASH_ESCAPE]
     68           }
     69         ]
     70       },
     71       {
     72         className: 'meta',
     73         begin: /#\s*[a-z]+\b/, end: /$/,
     74         keywords: {
     75           'meta-keyword':
     76             'if else elif endif define undef warning error line ' +
     77             'pragma ifdef ifndef include'
     78         },
     79         contains: [
     80           {
     81             begin: /\\\n/, relevance: 0
     82           },
     83           hljs.inherit(hljs.QUOTE_STRING_MODE, {className: 'meta-string'}),
     84           {
     85             className: 'meta-string',
     86             begin: /<.*?>/, end: /$/,
     87             illegal: '\\n',
     88           },
     89           hljs.C_LINE_COMMENT_MODE,
     90           hljs.C_BLOCK_COMMENT_MODE
     91         ]
     92       },
     93       {
     94         className: 'class',
     95         begin: '(' + CLASS_KEYWORDS.keyword.split(' ').join('|') + ')\\b', end: '({|$)', excludeEnd: true,
     96         keywords: CLASS_KEYWORDS,
     97         contains: [
     98           hljs.UNDERSCORE_TITLE_MODE
     99         ]
    100       },
    101       {
    102         begin: '\\.'+hljs.UNDERSCORE_IDENT_RE,
    103         relevance: 0
    104       }
    105     ]
    106   };
    107 }
    108 
    109 module.exports = objectivec;