Skip to content

Instantly share code, notes, and snippets.

@stan1y
Created October 13, 2010 19:35
Show Gist options
  • Save stan1y/624720 to your computer and use it in GitHub Desktop.
Save stan1y/624720 to your computer and use it in GitHub Desktop.
/*
Language: Objective C
ObjC keywords & classes for highlight.js (c) Stanislav Yudin <decvar@gmail.com>
*/
hljs.LANGUAGES.objc = function(){
var OBJC_KEYWORDS = {
'keyword': { 'IBAction' : 10, 'IBOutlet' : 10, 'atomic': 5, 'nonatomic': 5, 'assign' : 5, 'NO' : 2, 'BOOL' : 1, 'id' : 1, 'int': 1, 'float': 1, 'while': 1, 'char': 1, 'protocol': 3, 'catch': 1, 'selector': 2, 'encode': 1, 'export': 2, 'sizeof': 2, 'self': 2, 'property' : 2, 'synchronized': 2, 'typedef': 2, 'alloc': 2, 'const': 1, 'struct': 1, 'for': 1, 'retain': 2, 'union': 1, 'release': 2, 'super' : 2, 'autorelease' : 2, 'import': 1, 'unsigned': 1, 'long': 1, '\@throw': 1, 'static': 1, 'bool': 1, 'if': 1, 'public': 1, 'do': 1, 'return': 1, 'goto': 1, 'void': 2, 'enum': 1, 'else': 1, 'break': 1, 'YES': 2, 'class': 1, 'asm': 1, 'case': 1, 'typeid': 1, 'short': 1, 'double': 1, 'implementation': 2, 'interface': 2, 'end': 1, 'signed': 1, 'typename': 1, 'try': 1, 'finally': 1, 'switch': 1, 'continue': 1, 'inline': 1},
'built_in': { }
};
return {
defaultMode: {
lexems: [hljs.UNDERSCORE_IDENT_RE],
illegal: '</',
contains: ['comment', 'string', 'number', 'preprocessor', 'ns_string', 'class_member'],
keywords: OBJC_KEYWORDS
},
modes: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_NUMBER_MODE,
hljs.QUOTE_STRING_MODE,
hljs.BACKSLASH_ESCAPE,
{
className: 'string',
begin: '\'', end: '[^\\\\]\'',
illegal: '[^\\\\][^\']'
},
{
className: 'ns_string',
begin: '\@\'', end: '[^\\\\]\'',
illegal: '[^\\\\][^\']'
},
{
className: 'preprocessor',
begin: '#', end: '$'
},
{
className: 'class_member',
begin: '\\\[', end: '\W'
}
,
{
className: 'cocoa_class',
begin: 'NS', end: '\W'
}
]
};
}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment