shBrushObjC.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /**
  2. * Wordpress SyntaxHighlighter brush for Objective-C
  3. * By Matej Bukovinski, www.bukovinski.com
  4. *
  5. * Copyright (C) 2009 Matej Bukovinski
  6. *
  7. * Adapted from:
  8. * SyntaxHighlighter - Objective-C Brush, version 1.0.0
  9. * http://codepirate.seaandco.com/
  10. * Copyright (C) 2009 Geoffrey Byers.
  11. *
  12. * Licensed under a GNU Lesser General Public License.
  13. * http://creativecommons.org/licenses/LGPL/2.1/
  14. *
  15. */
  16. SyntaxHighlighter.brushes.ObjC = function() {
  17. var datatypes = 'char bool BOOL double float int long short id void';
  18. var keywords = 'IBAction IBOutlet SEL YES NO readwrite readonly nonatomic nil NULL ';
  19. keywords += 'super self copy ';
  20. keywords += 'break case catch class const copy __finally __exception __try ';
  21. keywords += 'const_cast continue private public protected __declspec ';
  22. keywords += 'default delete deprecated dllexport dllimport do dynamic_cast ';
  23. keywords += 'else enum explicit extern if for friend goto inline ';
  24. keywords += 'mutable naked namespace new noinline noreturn nothrow ';
  25. keywords += 'register reinterpret_cast return selectany ';
  26. keywords += 'sizeof static static_cast struct switch template this ';
  27. keywords += 'thread throw true false try typedef typeid typename union ';
  28. keywords += 'using uuid virtual volatile whcar_t while';
  29. this.regexList = [
  30. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comment' }, // one line comments
  31. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comment' }, // multiline comments
  32. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // double quoted strings
  33. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // single quoted strings
  34. { regex: new RegExp('^ *#.*', 'gm'), css: 'preprocessor' }, // preprocessor
  35. { regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'datatypes' }, // datatypes
  36. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword' }, // keyword
  37. { regex: new RegExp('\\bNS\\w+\\b', 'g'), css: 'keyword' }, // keyword
  38. { regex: new RegExp('@\\w+\\b', 'g'), css: 'keyword' }, // keyword
  39. { regex: new RegExp('@"(?:\\.|(\\\\\\")|[^\\""\\n])*"', 'g'), css: 'string' } // objc string
  40. ];
  41. }
  42. SyntaxHighlighter.brushes.ObjC.prototype = new SyntaxHighlighter.Highlighter();
  43. SyntaxHighlighter.brushes.ObjC.aliases = ['objc', 'obj-c'];