dart.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  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/dart/dart',["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. comments: {
  11. lineComment: '//',
  12. blockComment: ['/*', '*/']
  13. },
  14. brackets: [
  15. ['{', '}'],
  16. ['[', ']'],
  17. ['(', ')']
  18. ],
  19. autoClosingPairs: [
  20. { open: '{', close: '}' },
  21. { open: '[', close: ']' },
  22. { open: '(', close: ')' },
  23. { open: "'", close: "'", notIn: ['string', 'comment'] },
  24. { open: '"', close: '"', notIn: ['string'] },
  25. { open: '`', close: '`', notIn: ['string', 'comment'] },
  26. { open: '/**', close: ' */', notIn: ['string'] }
  27. ],
  28. surroundingPairs: [
  29. { open: '{', close: '}' },
  30. { open: '[', close: ']' },
  31. { open: '(', close: ')' },
  32. { open: '<', close: '>' },
  33. { open: "'", close: "'" },
  34. { open: '(', close: ')' },
  35. { open: '"', close: '"' },
  36. { open: '`', close: '`' }
  37. ],
  38. folding: {
  39. markers: {
  40. start: /^\s*\s*#?region\b/,
  41. end: /^\s*\s*#?endregion\b/
  42. }
  43. }
  44. };
  45. exports.language = {
  46. defaultToken: 'invalid',
  47. tokenPostfix: '.dart',
  48. keywords: [
  49. 'abstract',
  50. 'dynamic',
  51. 'implements',
  52. 'show',
  53. 'as',
  54. 'else',
  55. 'import',
  56. 'static',
  57. 'assert',
  58. 'enum',
  59. 'in',
  60. 'super',
  61. 'async',
  62. 'export',
  63. 'interface',
  64. 'switch',
  65. 'await',
  66. 'extends',
  67. 'is',
  68. 'sync',
  69. 'break',
  70. 'external',
  71. 'library',
  72. 'this',
  73. 'case',
  74. 'factory',
  75. 'mixin',
  76. 'throw',
  77. 'catch',
  78. 'false',
  79. 'new',
  80. 'true',
  81. 'class',
  82. 'final',
  83. 'null',
  84. 'try',
  85. 'const',
  86. 'finally',
  87. 'on',
  88. 'typedef',
  89. 'continue',
  90. 'for',
  91. 'operator',
  92. 'var',
  93. 'covariant',
  94. 'Function',
  95. 'part',
  96. 'void',
  97. 'default',
  98. 'get',
  99. 'rethrow',
  100. 'while',
  101. 'deferred',
  102. 'hide',
  103. 'return',
  104. 'with',
  105. 'do',
  106. 'if',
  107. 'set',
  108. 'yield'
  109. ],
  110. typeKeywords: ['int', 'double', 'String', 'bool'],
  111. operators: [
  112. '+',
  113. '-',
  114. '*',
  115. '/',
  116. '~/',
  117. '%',
  118. '++',
  119. '--',
  120. '==',
  121. '!=',
  122. '>',
  123. '<',
  124. '>=',
  125. '<=',
  126. '=',
  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. // we include these common regular expressions
  154. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  155. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  156. digits: /\d+(_+\d+)*/,
  157. octaldigits: /[0-7]+(_+[0-7]+)*/,
  158. binarydigits: /[0-1]+(_+[0-1]+)*/,
  159. hexdigits: /[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,
  160. regexpctl: /[(){}\[\]\$\^|\-*+?\.]/,
  161. regexpesc: /\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/,
  162. // The main tokenizer for our languages
  163. tokenizer: {
  164. root: [[/[{}]/, 'delimiter.bracket'], { include: 'common' }],
  165. common: [
  166. // identifiers and keywords
  167. [
  168. /[a-z_$][\w$]*/,
  169. {
  170. cases: {
  171. '@typeKeywords': 'type.identifier',
  172. '@keywords': 'keyword',
  173. '@default': 'identifier'
  174. }
  175. }
  176. ],
  177. [/[A-Z_$][\w\$]*/, 'type.identifier'],
  178. // [/[A-Z][\w\$]*/, 'identifier'],
  179. // whitespace
  180. { include: '@whitespace' },
  181. // regular expression: ensure it is terminated before beginning (otherwise it is an opeator)
  182. [
  183. /\/(?=([^\\\/]|\\.)+\/([gimsuy]*)(\s*)(\.|;|,|\)|\]|\}|$))/,
  184. { token: 'regexp', bracket: '@open', next: '@regexp' }
  185. ],
  186. // @ annotations.
  187. [/@[a-zA-Z]+/, 'annotation'],
  188. // variable
  189. // delimiters and operators
  190. [/[()\[\]]/, '@brackets'],
  191. [/[<>](?!@symbols)/, '@brackets'],
  192. [/!(?=([^=]|$))/, 'delimiter'],
  193. [
  194. /@symbols/,
  195. {
  196. cases: {
  197. '@operators': 'delimiter',
  198. '@default': ''
  199. }
  200. }
  201. ],
  202. // numbers
  203. [/(@digits)[eE]([\-+]?(@digits))?/, 'number.float'],
  204. [/(@digits)\.(@digits)([eE][\-+]?(@digits))?/, 'number.float'],
  205. [/0[xX](@hexdigits)n?/, 'number.hex'],
  206. [/0[oO]?(@octaldigits)n?/, 'number.octal'],
  207. [/0[bB](@binarydigits)n?/, 'number.binary'],
  208. [/(@digits)n?/, 'number'],
  209. // delimiter: after number because of .\d floats
  210. [/[;,.]/, 'delimiter'],
  211. // strings
  212. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  213. [/'([^'\\]|\\.)*$/, 'string.invalid'],
  214. [/"/, 'string', '@string_double'],
  215. [/'/, 'string', '@string_single']
  216. // [/[a-zA-Z]+/, "variable"]
  217. ],
  218. whitespace: [
  219. [/[ \t\r\n]+/, ''],
  220. [/\/\*\*(?!\/)/, 'comment.doc', '@jsdoc'],
  221. [/\/\*/, 'comment', '@comment'],
  222. [/\/\/\/.*$/, 'comment.doc'],
  223. [/\/\/.*$/, 'comment']
  224. ],
  225. comment: [
  226. [/[^\/*]+/, 'comment'],
  227. [/\*\//, 'comment', '@pop'],
  228. [/[\/*]/, 'comment']
  229. ],
  230. jsdoc: [
  231. [/[^\/*]+/, 'comment.doc'],
  232. [/\*\//, 'comment.doc', '@pop'],
  233. [/[\/*]/, 'comment.doc']
  234. ],
  235. // We match regular expression quite precisely
  236. regexp: [
  237. [
  238. /(\{)(\d+(?:,\d*)?)(\})/,
  239. ['regexp.escape.control', 'regexp.escape.control', 'regexp.escape.control']
  240. ],
  241. [
  242. /(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/,
  243. ['regexp.escape.control', { token: 'regexp.escape.control', next: '@regexrange' }]
  244. ],
  245. [/(\()(\?:|\?=|\?!)/, ['regexp.escape.control', 'regexp.escape.control']],
  246. [/[()]/, 'regexp.escape.control'],
  247. [/@regexpctl/, 'regexp.escape.control'],
  248. [/[^\\\/]/, 'regexp'],
  249. [/@regexpesc/, 'regexp.escape'],
  250. [/\\\./, 'regexp.invalid'],
  251. [
  252. /(\/)([gimsuy]*)/,
  253. [{ token: 'regexp', bracket: '@close', next: '@pop' }, 'keyword.other']
  254. ]
  255. ],
  256. regexrange: [
  257. [/-/, 'regexp.escape.control'],
  258. [/\^/, 'regexp.invalid'],
  259. [/@regexpesc/, 'regexp.escape'],
  260. [/[^\]]/, 'regexp'],
  261. [
  262. /\]/,
  263. {
  264. token: 'regexp.escape.control',
  265. next: '@pop',
  266. bracket: '@close'
  267. }
  268. ]
  269. ],
  270. string_double: [
  271. [/[^\\"\$]+/, 'string'],
  272. [/[^\\"]+/, 'string'],
  273. [/@escapes/, 'string.escape'],
  274. [/\\./, 'string.escape.invalid'],
  275. [/"/, 'string', '@pop'],
  276. [/\$\w+/, 'identifier']
  277. ],
  278. string_single: [
  279. [/[^\\'\$]+/, 'string'],
  280. [/@escapes/, 'string.escape'],
  281. [/\\./, 'string.escape.invalid'],
  282. [/'/, 'string', '@pop'],
  283. [/\$\w+/, 'identifier']
  284. ]
  285. }
  286. };
  287. });