dart.js 6.1 KB

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