javascript.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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/typescript/typescript',["require", "exports", "../fillers/monaco-editor-core"], function (require, exports, monaco_editor_core_1) {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.language = exports.conf = void 0;
  9. exports.conf = {
  10. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  11. comments: {
  12. lineComment: '//',
  13. blockComment: ['/*', '*/']
  14. },
  15. brackets: [
  16. ['{', '}'],
  17. ['[', ']'],
  18. ['(', ')']
  19. ],
  20. onEnterRules: [
  21. {
  22. // e.g. /** | */
  23. beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
  24. afterText: /^\s*\*\/$/,
  25. action: {
  26. indentAction: monaco_editor_core_1.languages.IndentAction.IndentOutdent,
  27. appendText: ' * '
  28. }
  29. },
  30. {
  31. // e.g. /** ...|
  32. beforeText: /^\s*\/\*\*(?!\/)([^\*]|\*(?!\/))*$/,
  33. action: {
  34. indentAction: monaco_editor_core_1.languages.IndentAction.None,
  35. appendText: ' * '
  36. }
  37. },
  38. {
  39. // e.g. * ...|
  40. beforeText: /^(\t|(\ \ ))*\ \*(\ ([^\*]|\*(?!\/))*)?$/,
  41. action: {
  42. indentAction: monaco_editor_core_1.languages.IndentAction.None,
  43. appendText: '* '
  44. }
  45. },
  46. {
  47. // e.g. */|
  48. beforeText: /^(\t|(\ \ ))*\ \*\/\s*$/,
  49. action: {
  50. indentAction: monaco_editor_core_1.languages.IndentAction.None,
  51. removeText: 1
  52. }
  53. }
  54. ],
  55. autoClosingPairs: [
  56. { open: '{', close: '}' },
  57. { open: '[', close: ']' },
  58. { open: '(', close: ')' },
  59. { open: '"', close: '"', notIn: ['string'] },
  60. { open: "'", close: "'", notIn: ['string', 'comment'] },
  61. { open: '`', close: '`', notIn: ['string', 'comment'] },
  62. { open: '/**', close: ' */', notIn: ['string'] }
  63. ],
  64. folding: {
  65. markers: {
  66. start: new RegExp('^\\s*//\\s*#?region\\b'),
  67. end: new RegExp('^\\s*//\\s*#?endregion\\b')
  68. }
  69. }
  70. };
  71. exports.language = {
  72. // Set defaultToken to invalid to see what you do not tokenize yet
  73. defaultToken: 'invalid',
  74. tokenPostfix: '.ts',
  75. keywords: [
  76. // Should match the keys of textToKeywordObj in
  77. // https://github.com/microsoft/TypeScript/blob/master/src/compiler/scanner.ts
  78. 'abstract',
  79. 'any',
  80. 'as',
  81. 'asserts',
  82. 'bigint',
  83. 'boolean',
  84. 'break',
  85. 'case',
  86. 'catch',
  87. 'class',
  88. 'continue',
  89. 'const',
  90. 'constructor',
  91. 'debugger',
  92. 'declare',
  93. 'default',
  94. 'delete',
  95. 'do',
  96. 'else',
  97. 'enum',
  98. 'export',
  99. 'extends',
  100. 'false',
  101. 'finally',
  102. 'for',
  103. 'from',
  104. 'function',
  105. 'get',
  106. 'if',
  107. 'implements',
  108. 'import',
  109. 'in',
  110. 'infer',
  111. 'instanceof',
  112. 'interface',
  113. 'is',
  114. 'keyof',
  115. 'let',
  116. 'module',
  117. 'namespace',
  118. 'never',
  119. 'new',
  120. 'null',
  121. 'number',
  122. 'object',
  123. 'package',
  124. 'private',
  125. 'protected',
  126. 'public',
  127. 'override',
  128. 'readonly',
  129. 'require',
  130. 'global',
  131. 'return',
  132. 'set',
  133. 'static',
  134. 'string',
  135. 'super',
  136. 'switch',
  137. 'symbol',
  138. 'this',
  139. 'throw',
  140. 'true',
  141. 'try',
  142. 'type',
  143. 'typeof',
  144. 'undefined',
  145. 'unique',
  146. 'unknown',
  147. 'var',
  148. 'void',
  149. 'while',
  150. 'with',
  151. 'yield',
  152. 'async',
  153. 'await',
  154. 'of'
  155. ],
  156. operators: [
  157. '<=',
  158. '>=',
  159. '==',
  160. '!=',
  161. '===',
  162. '!==',
  163. '=>',
  164. '+',
  165. '-',
  166. '**',
  167. '*',
  168. '/',
  169. '%',
  170. '++',
  171. '--',
  172. '<<',
  173. '</',
  174. '>>',
  175. '>>>',
  176. '&',
  177. '|',
  178. '^',
  179. '!',
  180. '~',
  181. '&&',
  182. '||',
  183. '??',
  184. '?',
  185. ':',
  186. '=',
  187. '+=',
  188. '-=',
  189. '*=',
  190. '**=',
  191. '/=',
  192. '%=',
  193. '<<=',
  194. '>>=',
  195. '>>>=',
  196. '&=',
  197. '|=',
  198. '^=',
  199. '@'
  200. ],
  201. // we include these common regular expressions
  202. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  203. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  204. digits: /\d+(_+\d+)*/,
  205. octaldigits: /[0-7]+(_+[0-7]+)*/,
  206. binarydigits: /[0-1]+(_+[0-1]+)*/,
  207. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  208. regexpctl: /[(){}\[\]\$\^|\-*+?\.]/,
  209. regexpesc: /\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/,
  210. // The main tokenizer for our languages
  211. tokenizer: {
  212. root: [[/[{}]/, 'delimiter.bracket'], { include: 'common' }],
  213. common: [
  214. // identifiers and keywords
  215. [
  216. /[a-z_$][\w$]*/,
  217. {
  218. cases: {
  219. '@keywords': 'keyword',
  220. '@default': 'identifier'
  221. }
  222. }
  223. ],
  224. [/[A-Z][\w\$]*/, 'type.identifier'],
  225. // [/[A-Z][\w\$]*/, 'identifier'],
  226. // whitespace
  227. { include: '@whitespace' },
  228. // regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
  229. [
  230. /\/(?=([^\\\/]|\\.)+\/([dgimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/,
  231. { token: 'regexp', bracket: '@open', next: '@regexp' }
  232. ],
  233. // delimiters and operators
  234. [/[()\[\]]/, '@brackets'],
  235. [/[<>](?!@symbols)/, '@brackets'],
  236. [/!(?=([^=]|$))/, 'delimiter'],
  237. [
  238. /@symbols/,
  239. {
  240. cases: {
  241. '@operators': 'delimiter',
  242. '@default': ''
  243. }
  244. }
  245. ],
  246. // numbers
  247. [/(@digits)[eE]([\-+]?(@digits))?/, 'number.float'],
  248. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, 'number.float'],
  249. [/0[xX](@hexdigits)n?/, 'number.hex'],
  250. [/0[oO]?(@octaldigits)n?/, 'number.octal'],
  251. [/0[bB](@binarydigits)n?/, 'number.binary'],
  252. [/(@digits)n?/, 'number'],
  253. // delimiter: after number because of .\d floats
  254. [/[;,.]/, 'delimiter'],
  255. // strings
  256. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  257. [/'([^'\\]|\\.)*$/, 'string.invalid'],
  258. [/"/, 'string', '@string_double'],
  259. [/'/, 'string', '@string_single'],
  260. [/`/, 'string', '@string_backtick']
  261. ],
  262. whitespace: [
  263. [/[ \t\r\n]+/, ''],
  264. [/\/\*\*(?!\/)/, 'comment.doc', '@jsdoc'],
  265. [/\/\*/, 'comment', '@comment'],
  266. [/\/\/.*$/, 'comment']
  267. ],
  268. comment: [
  269. [/[^\/*]+/, 'comment'],
  270. [/\*\//, 'comment', '@pop'],
  271. [/[\/*]/, 'comment']
  272. ],
  273. jsdoc: [
  274. [/[^\/*]+/, 'comment.doc'],
  275. [/\*\//, 'comment.doc', '@pop'],
  276. [/[\/*]/, 'comment.doc']
  277. ],
  278. // We match regular expression quite precisely
  279. regexp: [
  280. [
  281. /(\{)(\d+(?:,\d*)?)(\})/,
  282. ['regexp.escape.control', 'regexp.escape.control', 'regexp.escape.control']
  283. ],
  284. [
  285. /(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/,
  286. ['regexp.escape.control', { token: 'regexp.escape.control', next: '@regexrange' }]
  287. ],
  288. [/(\()(\?:|\?=|\?!)/, ['regexp.escape.control', 'regexp.escape.control']],
  289. [/[()]/, 'regexp.escape.control'],
  290. [/@regexpctl/, 'regexp.escape.control'],
  291. [/[^\\\/]/, 'regexp'],
  292. [/@regexpesc/, 'regexp.escape'],
  293. [/\\\./, 'regexp.invalid'],
  294. [
  295. /(\/)([dgimsuy]*)/,
  296. [{ token: 'regexp', bracket: '@close', next: '@pop' }, 'keyword.other']
  297. ]
  298. ],
  299. regexrange: [
  300. [/-/, 'regexp.escape.control'],
  301. [/\^/, 'regexp.invalid'],
  302. [/@regexpesc/, 'regexp.escape'],
  303. [/[^\]]/, 'regexp'],
  304. [
  305. /\]/,
  306. {
  307. token: 'regexp.escape.control',
  308. next: '@pop',
  309. bracket: '@close'
  310. }
  311. ]
  312. ],
  313. string_double: [
  314. [/[^\\"]+/, 'string'],
  315. [/@escapes/, 'string.escape'],
  316. [/\\./, 'string.escape.invalid'],
  317. [/"/, 'string', '@pop']
  318. ],
  319. string_single: [
  320. [/[^\\']+/, 'string'],
  321. [/@escapes/, 'string.escape'],
  322. [/\\./, 'string.escape.invalid'],
  323. [/'/, 'string', '@pop']
  324. ],
  325. string_backtick: [
  326. [/\$\{/, { token: 'delimiter.bracket', next: '@bracketCounting' }],
  327. [/[^\\`$]+/, 'string'],
  328. [/@escapes/, 'string.escape'],
  329. [/\\./, 'string.escape.invalid'],
  330. [/`/, 'string', '@pop']
  331. ],
  332. bracketCounting: [
  333. [/\{/, 'delimiter.bracket', '@bracketCounting'],
  334. [/\}/, 'delimiter.bracket', '@pop'],
  335. { include: 'common' }
  336. ]
  337. }
  338. };
  339. });
  340. /*---------------------------------------------------------------------------------------------
  341. * Copyright (c) Microsoft Corporation. All rights reserved.
  342. * Licensed under the MIT License. See License.txt in the project root for license information.
  343. *--------------------------------------------------------------------------------------------*/
  344. define('vs/basic-languages/javascript/javascript',["require", "exports", "../typescript/typescript"], function (require, exports, typescript_1) {
  345. "use strict";
  346. Object.defineProperty(exports, "__esModule", { value: true });
  347. exports.language = exports.conf = void 0;
  348. exports.conf = typescript_1.conf;
  349. exports.language = {
  350. // Set defaultToken to invalid to see what you do not tokenize yet
  351. defaultToken: 'invalid',
  352. tokenPostfix: '.js',
  353. keywords: [
  354. 'break',
  355. 'case',
  356. 'catch',
  357. 'class',
  358. 'continue',
  359. 'const',
  360. 'constructor',
  361. 'debugger',
  362. 'default',
  363. 'delete',
  364. 'do',
  365. 'else',
  366. 'export',
  367. 'extends',
  368. 'false',
  369. 'finally',
  370. 'for',
  371. 'from',
  372. 'function',
  373. 'get',
  374. 'if',
  375. 'import',
  376. 'in',
  377. 'instanceof',
  378. 'let',
  379. 'new',
  380. 'null',
  381. 'return',
  382. 'set',
  383. 'super',
  384. 'switch',
  385. 'symbol',
  386. 'this',
  387. 'throw',
  388. 'true',
  389. 'try',
  390. 'typeof',
  391. 'undefined',
  392. 'var',
  393. 'void',
  394. 'while',
  395. 'with',
  396. 'yield',
  397. 'async',
  398. 'await',
  399. 'of'
  400. ],
  401. typeKeywords: [],
  402. operators: typescript_1.language.operators,
  403. symbols: typescript_1.language.symbols,
  404. escapes: typescript_1.language.escapes,
  405. digits: typescript_1.language.digits,
  406. octaldigits: typescript_1.language.octaldigits,
  407. binarydigits: typescript_1.language.binarydigits,
  408. hexdigits: typescript_1.language.hexdigits,
  409. regexpctl: typescript_1.language.regexpctl,
  410. regexpesc: typescript_1.language.regexpesc,
  411. tokenizer: typescript_1.language.tokenizer
  412. };
  413. });