angelscript.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. module.exports = function(hljs) {
  2. var builtInTypeMode = {
  3. className: 'built_in',
  4. begin: '\\b(void|bool|int|int8|int16|int32|int64|uint|uint8|uint16|uint32|uint64|string|ref|array|double|float|auto|dictionary)'
  5. };
  6. var objectHandleMode = {
  7. className: 'symbol',
  8. begin: '[a-zA-Z0-9_]+@'
  9. };
  10. var genericMode = {
  11. className: 'keyword',
  12. begin: '<', end: '>',
  13. contains: [ builtInTypeMode, objectHandleMode ]
  14. };
  15. builtInTypeMode.contains = [ genericMode ];
  16. objectHandleMode.contains = [ genericMode ];
  17. return {
  18. aliases: [ 'asc' ],
  19. keywords:
  20. 'for in|0 break continue while do|0 return if else case switch namespace is cast ' +
  21. 'or and xor not get|0 in inout|10 out override set|0 private public const default|0 ' +
  22. 'final shared external mixin|10 enum typedef funcdef this super import from interface ' +
  23. 'abstract|0 try catch protected explicit property',
  24. // avoid close detection with C# and JS
  25. illegal: '(^using\\s+[A-Za-z0-9_\\.]+;$|\\bfunction\s*[^\\(])',
  26. contains: [
  27. { // 'strings'
  28. className: 'string',
  29. begin: '\'', end: '\'',
  30. illegal: '\\n',
  31. contains: [ hljs.BACKSLASH_ESCAPE ],
  32. relevance: 0
  33. },
  34. { // "strings"
  35. className: 'string',
  36. begin: '"', end: '"',
  37. illegal: '\\n',
  38. contains: [ hljs.BACKSLASH_ESCAPE ],
  39. relevance: 0
  40. },
  41. // """heredoc strings"""
  42. {
  43. className: 'string',
  44. begin: '"""', end: '"""'
  45. },
  46. hljs.C_LINE_COMMENT_MODE, // single-line comments
  47. hljs.C_BLOCK_COMMENT_MODE, // comment blocks
  48. { // interface or namespace declaration
  49. beginKeywords: 'interface namespace', end: '{',
  50. illegal: '[;.\\-]',
  51. contains: [
  52. { // interface or namespace name
  53. className: 'symbol',
  54. begin: '[a-zA-Z0-9_]+'
  55. }
  56. ]
  57. },
  58. { // class declaration
  59. beginKeywords: 'class', end: '{',
  60. illegal: '[;.\\-]',
  61. contains: [
  62. { // class name
  63. className: 'symbol',
  64. begin: '[a-zA-Z0-9_]+',
  65. contains: [
  66. {
  67. begin: '[:,]\\s*',
  68. contains: [
  69. {
  70. className: 'symbol',
  71. begin: '[a-zA-Z0-9_]+'
  72. }
  73. ]
  74. }
  75. ]
  76. }
  77. ]
  78. },
  79. builtInTypeMode, // built-in types
  80. objectHandleMode, // object handles
  81. { // literals
  82. className: 'literal',
  83. begin: '\\b(null|true|false)'
  84. },
  85. { // numbers
  86. className: 'number',
  87. begin: '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)'
  88. }
  89. ]
  90. };
  91. };