kotlin.js 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. define('vs/basic-languages/kotlin/kotlin',["require", "exports"], function (require, exports) {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.language = exports.conf = void 0;
  9. exports.conf = {
  10. // the default separators except `@$`
  11. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  12. comments: {
  13. lineComment: '//',
  14. blockComment: ['/*', '*/']
  15. },
  16. brackets: [
  17. ['{', '}'],
  18. ['[', ']'],
  19. ['(', ')']
  20. ],
  21. autoClosingPairs: [
  22. { open: '{', close: '}' },
  23. { open: '[', close: ']' },
  24. { open: '(', close: ')' },
  25. { open: '"', close: '"' },
  26. { open: "'", close: "'" }
  27. ],
  28. surroundingPairs: [
  29. { open: '{', close: '}' },
  30. { open: '[', close: ']' },
  31. { open: '(', close: ')' },
  32. { open: '"', close: '"' },
  33. { open: "'", close: "'" },
  34. { open: '<', close: '>' }
  35. ],
  36. folding: {
  37. markers: {
  38. start: new RegExp('^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))'),
  39. end: new RegExp('^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))')
  40. }
  41. }
  42. };
  43. exports.language = {
  44. defaultToken: '',
  45. tokenPostfix: '.kt',
  46. keywords: [
  47. 'as',
  48. 'as?',
  49. 'break',
  50. 'class',
  51. 'continue',
  52. 'do',
  53. 'else',
  54. 'false',
  55. 'for',
  56. 'fun',
  57. 'if',
  58. 'in',
  59. '!in',
  60. 'interface',
  61. 'is',
  62. '!is',
  63. 'null',
  64. 'object',
  65. 'package',
  66. 'return',
  67. 'super',
  68. 'this',
  69. 'throw',
  70. 'true',
  71. 'try',
  72. 'typealias',
  73. 'val',
  74. 'var',
  75. 'when',
  76. 'while',
  77. 'by',
  78. 'catch',
  79. 'constructor',
  80. 'delegate',
  81. 'dynamic',
  82. 'field',
  83. 'file',
  84. 'finally',
  85. 'get',
  86. 'import',
  87. 'init',
  88. 'param',
  89. 'property',
  90. 'receiver',
  91. 'set',
  92. 'setparam',
  93. 'where',
  94. 'actual',
  95. 'abstract',
  96. 'annotation',
  97. 'companion',
  98. 'const',
  99. 'crossinline',
  100. 'data',
  101. 'enum',
  102. 'expect',
  103. 'external',
  104. 'final',
  105. 'infix',
  106. 'inline',
  107. 'inner',
  108. 'internal',
  109. 'lateinit',
  110. 'noinline',
  111. 'open',
  112. 'operator',
  113. 'out',
  114. 'override',
  115. 'private',
  116. 'protected',
  117. 'public',
  118. 'reified',
  119. 'sealed',
  120. 'suspend',
  121. 'tailrec',
  122. 'vararg',
  123. 'field',
  124. 'it'
  125. ],
  126. operators: [
  127. '+',
  128. '-',
  129. '*',
  130. '/',
  131. '%',
  132. '=',
  133. '+=',
  134. '-=',
  135. '*=',
  136. '/=',
  137. '%=',
  138. '++',
  139. '--',
  140. '&&',
  141. '||',
  142. '!',
  143. '==',
  144. '!=',
  145. '===',
  146. '!==',
  147. '>',
  148. '<',
  149. '<=',
  150. '>=',
  151. '[',
  152. ']',
  153. '!!',
  154. '?.',
  155. '?:',
  156. '::',
  157. '..',
  158. ':',
  159. '?',
  160. '->',
  161. '@',
  162. ';',
  163. '$',
  164. '_'
  165. ],
  166. // we include these common regular expressions
  167. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  168. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  169. digits: /\d+(_+\d+)*/,
  170. octaldigits: /[0-7]+(_+[0-7]+)*/,
  171. binarydigits: /[0-1]+(_+[0-1]+)*/,
  172. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  173. // The main tokenizer for our languages
  174. tokenizer: {
  175. root: [
  176. // class name highlighting
  177. [/[A-Z][\w\$]*/, 'type.identifier'],
  178. // identifiers and keywords
  179. [
  180. /[a-zA-Z_$][\w$]*/,
  181. {
  182. cases: {
  183. '@keywords': { token: 'keyword.$0' },
  184. '@default': 'identifier'
  185. }
  186. }
  187. ],
  188. // whitespace
  189. { include: '@whitespace' },
  190. // delimiters and operators
  191. [/[{}()\[\]]/, '@brackets'],
  192. [/[<>](?!@symbols)/, '@brackets'],
  193. [
  194. /@symbols/,
  195. {
  196. cases: {
  197. '@operators': 'delimiter',
  198. '@default': ''
  199. }
  200. }
  201. ],
  202. // @ annotations.
  203. [/@\s*[a-zA-Z_\$][\w\$]*/, 'annotation'],
  204. // numbers
  205. [/(@digits)[eE]([\-+]?(@digits))?[fFdD]?/, 'number.float'],
  206. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?[fFdD]?/, 'number.float'],
  207. [/0[xX](@hexdigits)[Ll]?/, 'number.hex'],
  208. [/0(@octaldigits)[Ll]?/, 'number.octal'],
  209. [/0[bB](@binarydigits)[Ll]?/, 'number.binary'],
  210. [/(@digits)[fFdD]/, 'number.float'],
  211. [/(@digits)[lL]?/, 'number'],
  212. // delimiter: after number because of .\d floats
  213. [/[;,.]/, 'delimiter'],
  214. // strings
  215. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  216. [/"""/, 'string', '@multistring'],
  217. [/"/, 'string', '@string'],
  218. // characters
  219. [/'[^\\']'/, 'string'],
  220. [/(')(@escapes)(')/, ['string', 'string.escape', 'string']],
  221. [/'/, 'string.invalid']
  222. ],
  223. whitespace: [
  224. [/[ \t\r\n]+/, ''],
  225. [/\/\*\*(?!\/)/, 'comment.doc', '@javadoc'],
  226. [/\/\*/, 'comment', '@comment'],
  227. [/\/\/.*$/, 'comment']
  228. ],
  229. comment: [
  230. [/[^\/*]+/, 'comment'],
  231. [/\/\*/, 'comment', '@comment'],
  232. [/\*\//, 'comment', '@pop'],
  233. [/[\/*]/, 'comment']
  234. ],
  235. //Identical copy of comment above, except for the addition of .doc
  236. javadoc: [
  237. [/[^\/*]+/, 'comment.doc'],
  238. [/\/\*/, 'comment.doc', '@push'],
  239. [/\/\*/, 'comment.doc.invalid'],
  240. [/\*\//, 'comment.doc', '@pop'],
  241. [/[\/*]/, 'comment.doc']
  242. ],
  243. string: [
  244. [/[^\\"]+/, 'string'],
  245. [/@escapes/, 'string.escape'],
  246. [/\\./, 'string.escape.invalid'],
  247. [/"/, 'string', '@pop']
  248. ],
  249. multistring: [
  250. [/[^\\"]+/, 'string'],
  251. [/@escapes/, 'string.escape'],
  252. [/\\./, 'string.escape.invalid'],
  253. [/"""/, 'string', '@pop'],
  254. [/./, 'string']
  255. ]
  256. }
  257. };
  258. });