angelscript.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. { // "strings"
  43. className: 'string',
  44. begin: '"', end: '"',
  45. illegal: '\\n',
  46. contains: [ hljs.BACKSLASH_ESCAPE ],
  47. relevance: 0
  48. },
  49. // """heredoc strings"""
  50. {
  51. className: 'string',
  52. begin: '"""', end: '"""'
  53. },
  54. hljs.C_LINE_COMMENT_MODE, // single-line comments
  55. hljs.C_BLOCK_COMMENT_MODE, // comment blocks
  56. { // interface or namespace declaration
  57. beginKeywords: 'interface namespace', end: '{',
  58. illegal: '[;.\\-]',
  59. contains: [
  60. { // interface or namespace name
  61. className: 'symbol',
  62. begin: '[a-zA-Z0-9_]+'
  63. }
  64. ]
  65. },
  66. { // class declaration
  67. beginKeywords: 'class', end: '{',
  68. illegal: '[;.\\-]',
  69. contains: [
  70. { // class name
  71. className: 'symbol',
  72. begin: '[a-zA-Z0-9_]+',
  73. contains: [
  74. {
  75. begin: '[:,]\\s*',
  76. contains: [
  77. {
  78. className: 'symbol',
  79. begin: '[a-zA-Z0-9_]+'
  80. }
  81. ]
  82. }
  83. ]
  84. }
  85. ]
  86. },
  87. builtInTypeMode, // built-in types
  88. objectHandleMode, // object handles
  89. { // literals
  90. className: 'literal',
  91. begin: '\\b(null|true|false)'
  92. },
  93. { // numbers
  94. className: 'number',
  95. begin: '(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?f?|\\.\\d+f?)([eE][-+]?\\d+f?)?)'
  96. }
  97. ]
  98. };
  99. }
  100. module.exports = angelscript;