PageRenderTime 33ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/samples/scalate-presentation/src/highlight/languages/delphi.js

http://github.com/scalate/scalate
JavaScript | 83 lines | 79 code | 1 blank | 3 comment | 0 complexity | 9180bd70443b3c505ad2d3c8b35286b1 MD5 | raw file
  1. /*
  2. Language: Delphi
  3. */
  4. hljs.LANGUAGES.delphi = function(){
  5. var DELPHI_KEYWORDS = {'and': 1, 'safecall': 1, 'cdecl': 1, 'then': 1, 'string': 1, 'exports': 1, 'library': 1, 'not': 1, 'pascal': 1, 'set': 1, 'virtual': 1, 'file': 1, 'in': 1, 'array': 1, 'label': 1, 'packed': 1, 'end.': 1, 'index': 1, 'while': 1, 'const': 1, 'raise': 1, 'for': 1, 'to': 1, 'implementation': 1, 'with': 1, 'except': 1, 'overload': 1, 'destructor': 1, 'downto': 1, 'finally': 1, 'program': 1, 'exit': 1, 'unit': 1, 'inherited': 1, 'override': 1, 'if': 1, 'type': 1, 'until': 1, 'function': 1, 'do': 1, 'begin': 1, 'repeat': 1, 'goto': 1, 'nil': 1, 'far': 1, 'initialization': 1, 'object': 1, 'else': 1, 'var': 1, 'uses': 1, 'external': 1, 'resourcestring': 1, 'interface': 1, 'end': 1, 'finalization': 1, 'class': 1, 'asm': 1, 'mod': 1, 'case': 1, 'on': 1, 'shr': 1, 'shl': 1, 'of': 1, 'register': 1, 'xorwrite': 1, 'threadvar': 1, 'try': 1, 'record': 1, 'near': 1, 'stored': 1, 'constructor': 1, 'stdcall': 1, 'inline': 1, 'div': 1, 'out': 1, 'or': 1, 'procedure': 1};
  6. var DELPHI_CLASS_KEYWORDS = {'safecall': 1, 'stdcall': 1, 'pascal': 1, 'stored': 1, 'const': 1, 'implementation': 1, 'finalization': 1, 'except': 1, 'to': 1, 'finally': 1, 'program': 1, 'inherited': 1, 'override': 1, 'then': 1, 'exports': 1, 'string': 1, 'read': 1, 'not': 1, 'mod': 1, 'shr': 1, 'try': 1, 'div': 1, 'shl': 1, 'set': 1, 'library': 1, 'message': 1, 'packed': 1, 'index': 1, 'for': 1, 'near': 1, 'overload': 1, 'label': 1, 'downto': 1, 'exit': 1, 'public': 1, 'goto': 1, 'interface': 1, 'asm': 1, 'on': 1, 'of': 1, 'constructor': 1, 'or': 1, 'private': 1, 'array': 1, 'unit': 1, 'raise': 1, 'destructor': 1, 'var': 1, 'type': 1, 'until': 1, 'function': 1, 'else': 1, 'external': 1, 'with': 1, 'case': 1, 'default': 1, 'record': 1, 'while': 1, 'protected': 1, 'property': 1, 'procedure': 1, 'published': 1, 'and': 1, 'cdecl': 1, 'do': 1, 'threadvar': 1, 'file': 1, 'in': 1, 'if': 1, 'end': 1, 'virtual': 1, 'write': 1, 'far': 1, 'out': 1, 'begin': 1, 'repeat': 1, 'nil': 1, 'initialization': 1, 'object': 1, 'uses': 1, 'resourcestring': 1, 'class': 1, 'register': 1, 'xorwrite': 1, 'inline': 1, 'static': 1};
  7. return {
  8. defaultMode: {
  9. lexems: [hljs.IDENT_RE],
  10. illegal: '("|\\$[G-Zg-z]|\\/\\*|</)',
  11. contains: ['comment', 'string', 'number', 'function', 'class'],
  12. keywords: DELPHI_KEYWORDS
  13. },
  14. case_insensitive: true,
  15. modes: [
  16. {
  17. className: 'comment',
  18. begin: '{', end: '}',
  19. relevance: 0
  20. },
  21. {
  22. className: 'comment',
  23. begin: '\\(\\*', end: '\\*\\)',
  24. relevance: 10
  25. },
  26. hljs.C_LINE_COMMENT_MODE,
  27. {
  28. className: 'number',
  29. begin: hljs.NUMBER_RE, end: '^',
  30. relevance: 0
  31. },
  32. {
  33. className: 'string',
  34. begin: '\'', end: '\'',
  35. contains: ['quote'],
  36. relevance: 0
  37. },
  38. {
  39. className: 'string',
  40. begin: '(#\\d+)+', end: '^'
  41. },
  42. {
  43. className: 'quote',
  44. begin: '\'\'', end: '^', noMarkup: true
  45. },
  46. {
  47. className: 'function',
  48. begin: 'function\\b', end: '[:;]',
  49. lexems: [hljs.IDENT_RE],
  50. keywords: {'function': 1},
  51. contains: ['title', 'params', 'comment'],
  52. relevance: 0
  53. },
  54. {
  55. className: 'function',
  56. begin: '(procedure|constructor|destructor)\\b', end: ';',
  57. lexems: [hljs.IDENT_RE],
  58. keywords: {'constructor': 1, 'destructor': 1, 'procedure': 1},
  59. contains: ['title', 'params', 'comment'],
  60. relevance: 10
  61. },
  62. {
  63. className: 'title',
  64. begin: hljs.IDENT_RE, end: '^'
  65. },
  66. {
  67. className: 'params',
  68. begin: '\\(', end: '\\)',
  69. lexems: [hljs.IDENT_RE],
  70. keywords: DELPHI_KEYWORDS,
  71. contains: ['string']
  72. },
  73. {
  74. className: 'class',
  75. begin: '=\\bclass\\b', end: 'end;',
  76. lexems: [hljs.IDENT_RE],
  77. keywords: DELPHI_CLASS_KEYWORDS,
  78. contains: ['string', 'comment', 'function']
  79. }
  80. ]
  81. };
  82. }();