swift.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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. define("vs/basic-languages/swift/swift",[],()=>{
  8. var moduleExports = (() => {
  9. var __defProp = Object.defineProperty;
  10. var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
  11. var __export = (target, all) => {
  12. __markAsModule(target);
  13. for (var name in all)
  14. __defProp(target, name, { get: all[name], enumerable: true });
  15. };
  16. // src/basic-languages/swift/swift.ts
  17. var swift_exports = {};
  18. __export(swift_exports, {
  19. conf: () => conf,
  20. language: () => language
  21. });
  22. var conf = {
  23. comments: {
  24. lineComment: "//",
  25. blockComment: ["/*", "*/"]
  26. },
  27. brackets: [
  28. ["{", "}"],
  29. ["[", "]"],
  30. ["(", ")"]
  31. ],
  32. autoClosingPairs: [
  33. { open: "{", close: "}" },
  34. { open: "[", close: "]" },
  35. { open: "(", close: ")" },
  36. { open: '"', close: '"' },
  37. { open: "'", close: "'" },
  38. { open: "`", close: "`" }
  39. ],
  40. surroundingPairs: [
  41. { open: "{", close: "}" },
  42. { open: "[", close: "]" },
  43. { open: "(", close: ")" },
  44. { open: '"', close: '"' },
  45. { open: "'", close: "'" },
  46. { open: "`", close: "`" }
  47. ]
  48. };
  49. var language = {
  50. defaultToken: "",
  51. tokenPostfix: ".swift",
  52. identifier: /[a-zA-Z_][\w$]*/,
  53. attributes: [
  54. "@autoclosure",
  55. "@noescape",
  56. "@noreturn",
  57. "@NSApplicationMain",
  58. "@NSCopying",
  59. "@NSManaged",
  60. "@objc",
  61. "@UIApplicationMain",
  62. "@noreturn",
  63. "@availability",
  64. "@IBAction",
  65. "@IBDesignable",
  66. "@IBInspectable",
  67. "@IBOutlet"
  68. ],
  69. accessmodifiers: ["public", "private", "fileprivate", "internal"],
  70. keywords: [
  71. "__COLUMN__",
  72. "__FILE__",
  73. "__FUNCTION__",
  74. "__LINE__",
  75. "as",
  76. "as!",
  77. "as?",
  78. "associativity",
  79. "break",
  80. "case",
  81. "catch",
  82. "class",
  83. "continue",
  84. "convenience",
  85. "default",
  86. "deinit",
  87. "didSet",
  88. "do",
  89. "dynamic",
  90. "dynamicType",
  91. "else",
  92. "enum",
  93. "extension",
  94. "fallthrough",
  95. "fileprivate",
  96. "final",
  97. "for",
  98. "func",
  99. "get",
  100. "guard",
  101. "if",
  102. "import",
  103. "in",
  104. "infix",
  105. "init",
  106. "inout",
  107. "internal",
  108. "is",
  109. "lazy",
  110. "left",
  111. "let",
  112. "mutating",
  113. "nil",
  114. "none",
  115. "nonmutating",
  116. "operator",
  117. "optional",
  118. "override",
  119. "postfix",
  120. "precedence",
  121. "prefix",
  122. "private",
  123. "protocol",
  124. "Protocol",
  125. "public",
  126. "repeat",
  127. "required",
  128. "return",
  129. "right",
  130. "self",
  131. "Self",
  132. "set",
  133. "static",
  134. "struct",
  135. "subscript",
  136. "super",
  137. "switch",
  138. "throw",
  139. "throws",
  140. "try",
  141. "try!",
  142. "Type",
  143. "typealias",
  144. "unowned",
  145. "var",
  146. "weak",
  147. "where",
  148. "while",
  149. "willSet",
  150. "FALSE",
  151. "TRUE"
  152. ],
  153. symbols: /[=(){}\[\].,:;@#\_&\-<>`?!+*\\\/]/,
  154. operatorstart: /[\/=\-+!*%<>&|^~?\u00A1-\u00A7\u00A9\u00AB\u00AC\u00AE\u00B0-\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7\u2016-\u2017\u2020-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E\u2190-\u23FF\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F\u3001-\u3003\u3008-\u3030]/,
  155. operatorend: /[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE00-\uFE0F\uFE20-\uFE2F\uE0100-\uE01EF]/,
  156. operators: /(@operatorstart)((@operatorstart)|(@operatorend))*/,
  157. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  158. tokenizer: {
  159. root: [
  160. { include: "@whitespace" },
  161. { include: "@comment" },
  162. { include: "@attribute" },
  163. { include: "@literal" },
  164. { include: "@keyword" },
  165. { include: "@invokedmethod" },
  166. { include: "@symbol" }
  167. ],
  168. whitespace: [
  169. [/\s+/, "white"],
  170. [/"""/, "string.quote", "@endDblDocString"]
  171. ],
  172. endDblDocString: [
  173. [/[^"]+/, "string"],
  174. [/\\"/, "string"],
  175. [/"""/, "string.quote", "@popall"],
  176. [/"/, "string"]
  177. ],
  178. symbol: [
  179. [/[{}()\[\]]/, "@brackets"],
  180. [/[<>](?!@symbols)/, "@brackets"],
  181. [/[.]/, "delimiter"],
  182. [/@operators/, "operator"],
  183. [/@symbols/, "operator"]
  184. ],
  185. comment: [
  186. [/\/\/\/.*$/, "comment.doc"],
  187. [/\/\*\*/, "comment.doc", "@commentdocbody"],
  188. [/\/\/.*$/, "comment"],
  189. [/\/\*/, "comment", "@commentbody"]
  190. ],
  191. commentdocbody: [
  192. [/\/\*/, "comment", "@commentbody"],
  193. [/\*\//, "comment.doc", "@pop"],
  194. [/\:[a-zA-Z]+\:/, "comment.doc.param"],
  195. [/./, "comment.doc"]
  196. ],
  197. commentbody: [
  198. [/\/\*/, "comment", "@commentbody"],
  199. [/\*\//, "comment", "@pop"],
  200. [/./, "comment"]
  201. ],
  202. attribute: [
  203. [
  204. /@@@identifier/,
  205. {
  206. cases: {
  207. "@attributes": "keyword.control",
  208. "@default": ""
  209. }
  210. }
  211. ]
  212. ],
  213. literal: [
  214. [/"/, { token: "string.quote", next: "@stringlit" }],
  215. [/0[b]([01]_?)+/, "number.binary"],
  216. [/0[o]([0-7]_?)+/, "number.octal"],
  217. [/0[x]([0-9a-fA-F]_?)+([pP][\-+](\d_?)+)?/, "number.hex"],
  218. [/(\d_?)*\.(\d_?)+([eE][\-+]?(\d_?)+)?/, "number.float"],
  219. [/(\d_?)+/, "number"]
  220. ],
  221. stringlit: [
  222. [/\\\(/, { token: "operator", next: "@interpolatedexpression" }],
  223. [/@escapes/, "string"],
  224. [/\\./, "string.escape.invalid"],
  225. [/"/, { token: "string.quote", next: "@pop" }],
  226. [/./, "string"]
  227. ],
  228. interpolatedexpression: [
  229. [/\(/, { token: "operator", next: "@interpolatedexpression" }],
  230. [/\)/, { token: "operator", next: "@pop" }],
  231. { include: "@literal" },
  232. { include: "@keyword" },
  233. { include: "@symbol" }
  234. ],
  235. keyword: [
  236. [/`/, { token: "operator", next: "@escapedkeyword" }],
  237. [
  238. /@identifier/,
  239. {
  240. cases: {
  241. "@keywords": "keyword",
  242. "[A-Z][a-zA-Z0-9$]*": "type.identifier",
  243. "@default": "identifier"
  244. }
  245. }
  246. ]
  247. ],
  248. escapedkeyword: [
  249. [/`/, { token: "operator", next: "@pop" }],
  250. [/./, "identifier"]
  251. ],
  252. invokedmethod: [
  253. [
  254. /([.])(@identifier)/,
  255. {
  256. cases: {
  257. $2: ["delimeter", "type.identifier"],
  258. "@default": ""
  259. }
  260. }
  261. ]
  262. ]
  263. }
  264. };
  265. return swift_exports;
  266. })();
  267. /*!---------------------------------------------------------------------------------------------
  268. * Copyright (C) David Owens II, owensd.io. All rights reserved.
  269. *--------------------------------------------------------------------------------------------*/
  270. return moduleExports;
  271. });