angelscript.js 3.1 KB

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