PageRenderTime 77ms CodeModel.GetById 43ms RepoModel.GetById 1ms app.codeStats 0ms

/railties/guides/assets/javascripts/syntaxhighlighter/shBrushCpp.js

https://github.com/ghar/rails
JavaScript | 97 lines | 70 code | 8 blank | 19 comment | 5 complexity | f88b763be0c3069581db71bae6025bd8 MD5 | raw file
  1. /**
  2. * SyntaxHighlighter
  3. * http://alexgorbatchev.com/SyntaxHighlighter
  4. *
  5. * SyntaxHighlighter is donationware. If you are using it, please donate.
  6. * http://alexgorbatchev.com/SyntaxHighlighter/donate.html
  7. *
  8. * @version
  9. * 3.0.83 (July 02 2010)
  10. *
  11. * @copyright
  12. * Copyright (C) 2004-2010 Alex Gorbatchev.
  13. *
  14. * @license
  15. * Dual licensed under the MIT and GPL licenses.
  16. */
  17. ;(function()
  18. {
  19. // CommonJS
  20. typeof(require) != 'undefined' ? SyntaxHighlighter = require('shCore').SyntaxHighlighter : null;
  21. function Brush()
  22. {
  23. // Copyright 2006 Shin, YoungJin
  24. var datatypes = 'ATOM BOOL BOOLEAN BYTE CHAR COLORREF DWORD DWORDLONG DWORD_PTR ' +
  25. 'DWORD32 DWORD64 FLOAT HACCEL HALF_PTR HANDLE HBITMAP HBRUSH ' +
  26. 'HCOLORSPACE HCONV HCONVLIST HCURSOR HDC HDDEDATA HDESK HDROP HDWP ' +
  27. 'HENHMETAFILE HFILE HFONT HGDIOBJ HGLOBAL HHOOK HICON HINSTANCE HKEY ' +
  28. 'HKL HLOCAL HMENU HMETAFILE HMODULE HMONITOR HPALETTE HPEN HRESULT ' +
  29. 'HRGN HRSRC HSZ HWINSTA HWND INT INT_PTR INT32 INT64 LANGID LCID LCTYPE ' +
  30. 'LGRPID LONG LONGLONG LONG_PTR LONG32 LONG64 LPARAM LPBOOL LPBYTE LPCOLORREF ' +
  31. 'LPCSTR LPCTSTR LPCVOID LPCWSTR LPDWORD LPHANDLE LPINT LPLONG LPSTR LPTSTR ' +
  32. 'LPVOID LPWORD LPWSTR LRESULT PBOOL PBOOLEAN PBYTE PCHAR PCSTR PCTSTR PCWSTR ' +
  33. 'PDWORDLONG PDWORD_PTR PDWORD32 PDWORD64 PFLOAT PHALF_PTR PHANDLE PHKEY PINT ' +
  34. 'PINT_PTR PINT32 PINT64 PLCID PLONG PLONGLONG PLONG_PTR PLONG32 PLONG64 POINTER_32 ' +
  35. 'POINTER_64 PSHORT PSIZE_T PSSIZE_T PSTR PTBYTE PTCHAR PTSTR PUCHAR PUHALF_PTR ' +
  36. 'PUINT PUINT_PTR PUINT32 PUINT64 PULONG PULONGLONG PULONG_PTR PULONG32 PULONG64 ' +
  37. 'PUSHORT PVOID PWCHAR PWORD PWSTR SC_HANDLE SC_LOCK SERVICE_STATUS_HANDLE SHORT ' +
  38. 'SIZE_T SSIZE_T TBYTE TCHAR UCHAR UHALF_PTR UINT UINT_PTR UINT32 UINT64 ULONG ' +
  39. 'ULONGLONG ULONG_PTR ULONG32 ULONG64 USHORT USN VOID WCHAR WORD WPARAM WPARAM WPARAM ' +
  40. 'char bool short int __int32 __int64 __int8 __int16 long float double __wchar_t ' +
  41. 'clock_t _complex _dev_t _diskfree_t div_t ldiv_t _exception _EXCEPTION_POINTERS ' +
  42. 'FILE _finddata_t _finddatai64_t _wfinddata_t _wfinddatai64_t __finddata64_t ' +
  43. '__wfinddata64_t _FPIEEE_RECORD fpos_t _HEAPINFO _HFILE lconv intptr_t ' +
  44. 'jmp_buf mbstate_t _off_t _onexit_t _PNH ptrdiff_t _purecall_handler ' +
  45. 'sig_atomic_t size_t _stat __stat64 _stati64 terminate_function ' +
  46. 'time_t __time64_t _timeb __timeb64 tm uintptr_t _utimbuf ' +
  47. 'va_list wchar_t wctrans_t wctype_t wint_t signed';
  48. var keywords = 'break case catch class const __finally __exception __try ' +
  49. 'const_cast continue private public protected __declspec ' +
  50. 'default delete deprecated dllexport dllimport do dynamic_cast ' +
  51. 'else enum explicit extern if for friend goto inline ' +
  52. 'mutable naked namespace new noinline noreturn nothrow ' +
  53. 'register reinterpret_cast return selectany ' +
  54. 'sizeof static static_cast struct switch template this ' +
  55. 'thread throw true false try typedef typeid typename union ' +
  56. 'using uuid virtual void volatile whcar_t while';
  57. var functions = 'assert isalnum isalpha iscntrl isdigit isgraph islower isprint' +
  58. 'ispunct isspace isupper isxdigit tolower toupper errno localeconv ' +
  59. 'setlocale acos asin atan atan2 ceil cos cosh exp fabs floor fmod ' +
  60. 'frexp ldexp log log10 modf pow sin sinh sqrt tan tanh jmp_buf ' +
  61. 'longjmp setjmp raise signal sig_atomic_t va_arg va_end va_start ' +
  62. 'clearerr fclose feof ferror fflush fgetc fgetpos fgets fopen ' +
  63. 'fprintf fputc fputs fread freopen fscanf fseek fsetpos ftell ' +
  64. 'fwrite getc getchar gets perror printf putc putchar puts remove ' +
  65. 'rename rewind scanf setbuf setvbuf sprintf sscanf tmpfile tmpnam ' +
  66. 'ungetc vfprintf vprintf vsprintf abort abs atexit atof atoi atol ' +
  67. 'bsearch calloc div exit free getenv labs ldiv malloc mblen mbstowcs ' +
  68. 'mbtowc qsort rand realloc srand strtod strtol strtoul system ' +
  69. 'wcstombs wctomb memchr memcmp memcpy memmove memset strcat strchr ' +
  70. 'strcmp strcoll strcpy strcspn strerror strlen strncat strncmp ' +
  71. 'strncpy strpbrk strrchr strspn strstr strtok strxfrm asctime ' +
  72. 'clock ctime difftime gmtime localtime mktime strftime time';
  73. this.regexList = [
  74. { regex: SyntaxHighlighter.regexLib.singleLineCComments, css: 'comments' }, // one line comments
  75. { regex: SyntaxHighlighter.regexLib.multiLineCComments, css: 'comments' }, // multiline comments
  76. { regex: SyntaxHighlighter.regexLib.doubleQuotedString, css: 'string' }, // strings
  77. { regex: SyntaxHighlighter.regexLib.singleQuotedString, css: 'string' }, // strings
  78. { regex: /^ *#.*/gm, css: 'preprocessor' },
  79. { regex: new RegExp(this.getKeywords(datatypes), 'gm'), css: 'color1 bold' },
  80. { regex: new RegExp(this.getKeywords(functions), 'gm'), css: 'functions bold' },
  81. { regex: new RegExp(this.getKeywords(keywords), 'gm'), css: 'keyword bold' }
  82. ];
  83. };
  84. Brush.prototype = new SyntaxHighlighter.Highlighter();
  85. Brush.aliases = ['cpp', 'c'];
  86. SyntaxHighlighter.brushes.Cpp = Brush;
  87. // CommonJS
  88. typeof(exports) != 'undefined' ? exports.Brush = Brush : null;
  89. })();