swift.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. "use strict";
  2. /*!-----------------------------------------------------------------------------
  3. * Copyright (c) Microsoft Corporation. All rights reserved.
  4. * Version: 0.38.0(0e330ae453813de4e6cf272460fb79c7117073d0)
  5. * Released under the MIT license
  6. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  7. *-----------------------------------------------------------------------------*/
  8. define("vs/basic-languages/swift/swift", ["require"],(require)=>{
  9. var moduleExports = (() => {
  10. var __defProp = Object.defineProperty;
  11. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  12. var __getOwnPropNames = Object.getOwnPropertyNames;
  13. var __hasOwnProp = Object.prototype.hasOwnProperty;
  14. var __export = (target, all) => {
  15. for (var name in all)
  16. __defProp(target, name, { get: all[name], enumerable: true });
  17. };
  18. var __copyProps = (to, from, except, desc) => {
  19. if (from && typeof from === "object" || typeof from === "function") {
  20. for (let key of __getOwnPropNames(from))
  21. if (!__hasOwnProp.call(to, key) && key !== except)
  22. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  23. }
  24. return to;
  25. };
  26. var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
  27. // src/basic-languages/swift/swift.ts
  28. var swift_exports = {};
  29. __export(swift_exports, {
  30. conf: () => conf,
  31. language: () => language
  32. });
  33. var conf = {
  34. comments: {
  35. lineComment: "//",
  36. blockComment: ["/*", "*/"]
  37. },
  38. brackets: [
  39. ["{", "}"],
  40. ["[", "]"],
  41. ["(", ")"]
  42. ],
  43. autoClosingPairs: [
  44. { open: "{", close: "}" },
  45. { open: "[", close: "]" },
  46. { open: "(", close: ")" },
  47. { open: '"', close: '"' },
  48. { open: "'", close: "'" },
  49. { open: "`", close: "`" }
  50. ],
  51. surroundingPairs: [
  52. { open: "{", close: "}" },
  53. { open: "[", close: "]" },
  54. { open: "(", close: ")" },
  55. { open: '"', close: '"' },
  56. { open: "'", close: "'" },
  57. { open: "`", close: "`" }
  58. ]
  59. };
  60. var language = {
  61. defaultToken: "",
  62. tokenPostfix: ".swift",
  63. identifier: /[a-zA-Z_][\w$]*/,
  64. attributes: [
  65. "@GKInspectable",
  66. "@IBAction",
  67. "@IBDesignable",
  68. "@IBInspectable",
  69. "@IBOutlet",
  70. "@IBSegueAction",
  71. "@NSApplicationMain",
  72. "@NSCopying",
  73. "@NSManaged",
  74. "@Sendable",
  75. "@UIApplicationMain",
  76. "@autoclosure",
  77. "@actorIndependent",
  78. "@asyncHandler",
  79. "@available",
  80. "@convention",
  81. "@derivative",
  82. "@differentiable",
  83. "@discardableResult",
  84. "@dynamicCallable",
  85. "@dynamicMemberLookup",
  86. "@escaping",
  87. "@frozen",
  88. "@globalActor",
  89. "@inlinable",
  90. "@inline",
  91. "@main",
  92. "@noDerivative",
  93. "@nonobjc",
  94. "@noreturn",
  95. "@objc",
  96. "@objcMembers",
  97. "@preconcurrency",
  98. "@propertyWrapper",
  99. "@requires_stored_property_inits",
  100. "@resultBuilder",
  101. "@testable",
  102. "@unchecked",
  103. "@unknown",
  104. "@usableFromInline",
  105. "@warn_unqualified_access"
  106. ],
  107. accessmodifiers: ["open", "public", "internal", "fileprivate", "private"],
  108. keywords: [
  109. "#available",
  110. "#colorLiteral",
  111. "#column",
  112. "#dsohandle",
  113. "#else",
  114. "#elseif",
  115. "#endif",
  116. "#error",
  117. "#file",
  118. "#fileID",
  119. "#fileLiteral",
  120. "#filePath",
  121. "#function",
  122. "#if",
  123. "#imageLiteral",
  124. "#keyPath",
  125. "#line",
  126. "#selector",
  127. "#sourceLocation",
  128. "#warning",
  129. "Any",
  130. "Protocol",
  131. "Self",
  132. "Type",
  133. "actor",
  134. "as",
  135. "assignment",
  136. "associatedtype",
  137. "associativity",
  138. "async",
  139. "await",
  140. "break",
  141. "case",
  142. "catch",
  143. "class",
  144. "continue",
  145. "convenience",
  146. "default",
  147. "defer",
  148. "deinit",
  149. "didSet",
  150. "do",
  151. "dynamic",
  152. "dynamicType",
  153. "else",
  154. "enum",
  155. "extension",
  156. "fallthrough",
  157. "false",
  158. "fileprivate",
  159. "final",
  160. "for",
  161. "func",
  162. "get",
  163. "guard",
  164. "higherThan",
  165. "if",
  166. "import",
  167. "in",
  168. "indirect",
  169. "infix",
  170. "init",
  171. "inout",
  172. "internal",
  173. "is",
  174. "isolated",
  175. "lazy",
  176. "left",
  177. "let",
  178. "lowerThan",
  179. "mutating",
  180. "nil",
  181. "none",
  182. "nonisolated",
  183. "nonmutating",
  184. "open",
  185. "operator",
  186. "optional",
  187. "override",
  188. "postfix",
  189. "precedence",
  190. "precedencegroup",
  191. "prefix",
  192. "private",
  193. "protocol",
  194. "public",
  195. "repeat",
  196. "required",
  197. "rethrows",
  198. "return",
  199. "right",
  200. "safe",
  201. "self",
  202. "set",
  203. "some",
  204. "static",
  205. "struct",
  206. "subscript",
  207. "super",
  208. "switch",
  209. "throw",
  210. "throws",
  211. "true",
  212. "try",
  213. "typealias",
  214. "unowned",
  215. "unsafe",
  216. "var",
  217. "weak",
  218. "where",
  219. "while",
  220. "willSet",
  221. "__consuming",
  222. "__owned"
  223. ],
  224. symbols: /[=(){}\[\].,:;@#\_&\-<>`?!+*\\\/]/,
  225. 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]/,
  226. operatorend: /[\u0300-\u036F\u1DC0-\u1DFF\u20D0-\u20FF\uFE00-\uFE0F\uFE20-\uFE2F\uE0100-\uE01EF]/,
  227. operators: /(@operatorstart)((@operatorstart)|(@operatorend))*/,
  228. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  229. tokenizer: {
  230. root: [
  231. { include: "@whitespace" },
  232. { include: "@comment" },
  233. { include: "@attribute" },
  234. { include: "@literal" },
  235. { include: "@keyword" },
  236. { include: "@invokedmethod" },
  237. { include: "@symbol" }
  238. ],
  239. whitespace: [
  240. [/\s+/, "white"],
  241. [/"""/, "string.quote", "@endDblDocString"]
  242. ],
  243. endDblDocString: [
  244. [/[^"]+/, "string"],
  245. [/\\"/, "string"],
  246. [/"""/, "string.quote", "@popall"],
  247. [/"/, "string"]
  248. ],
  249. symbol: [
  250. [/[{}()\[\]]/, "@brackets"],
  251. [/[<>](?!@symbols)/, "@brackets"],
  252. [/[.]/, "delimiter"],
  253. [/@operators/, "operator"],
  254. [/@symbols/, "operator"]
  255. ],
  256. comment: [
  257. [/\/\/\/.*$/, "comment.doc"],
  258. [/\/\*\*/, "comment.doc", "@commentdocbody"],
  259. [/\/\/.*$/, "comment"],
  260. [/\/\*/, "comment", "@commentbody"]
  261. ],
  262. commentdocbody: [
  263. [/\/\*/, "comment", "@commentbody"],
  264. [/\*\//, "comment.doc", "@pop"],
  265. [/\:[a-zA-Z]+\:/, "comment.doc.param"],
  266. [/./, "comment.doc"]
  267. ],
  268. commentbody: [
  269. [/\/\*/, "comment", "@commentbody"],
  270. [/\*\//, "comment", "@pop"],
  271. [/./, "comment"]
  272. ],
  273. attribute: [
  274. [
  275. /@@@identifier/,
  276. {
  277. cases: {
  278. "@attributes": "keyword.control",
  279. "@default": ""
  280. }
  281. }
  282. ]
  283. ],
  284. literal: [
  285. [/"/, { token: "string.quote", next: "@stringlit" }],
  286. [/0[b]([01]_?)+/, "number.binary"],
  287. [/0[o]([0-7]_?)+/, "number.octal"],
  288. [/0[x]([0-9a-fA-F]_?)+([pP][\-+](\d_?)+)?/, "number.hex"],
  289. [/(\d_?)*\.(\d_?)+([eE][\-+]?(\d_?)+)?/, "number.float"],
  290. [/(\d_?)+/, "number"]
  291. ],
  292. stringlit: [
  293. [/\\\(/, { token: "operator", next: "@interpolatedexpression" }],
  294. [/@escapes/, "string"],
  295. [/\\./, "string.escape.invalid"],
  296. [/"/, { token: "string.quote", next: "@pop" }],
  297. [/./, "string"]
  298. ],
  299. interpolatedexpression: [
  300. [/\(/, { token: "operator", next: "@interpolatedexpression" }],
  301. [/\)/, { token: "operator", next: "@pop" }],
  302. { include: "@literal" },
  303. { include: "@keyword" },
  304. { include: "@symbol" }
  305. ],
  306. keyword: [
  307. [/`/, { token: "operator", next: "@escapedkeyword" }],
  308. [
  309. /@identifier/,
  310. {
  311. cases: {
  312. "@keywords": "keyword",
  313. "[A-Z][a-zA-Z0-9$]*": "type.identifier",
  314. "@default": "identifier"
  315. }
  316. }
  317. ]
  318. ],
  319. escapedkeyword: [
  320. [/`/, { token: "operator", next: "@pop" }],
  321. [/./, "identifier"]
  322. ],
  323. invokedmethod: [
  324. [
  325. /([.])(@identifier)/,
  326. {
  327. cases: {
  328. $2: ["delimeter", "type.identifier"],
  329. "@default": ""
  330. }
  331. }
  332. ]
  333. ]
  334. }
  335. };
  336. return __toCommonJS(swift_exports);
  337. })();
  338. /*!---------------------------------------------------------------------------------------------
  339. * Copyright (C) David Owens II, owensd.io. All rights reserved.
  340. *--------------------------------------------------------------------------------------------*/
  341. return moduleExports;
  342. });