yaml.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. /*!-----------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.34.1(547870b6881302c5b4ff32173c16d06009e3588f)
  4. * Released under the MIT license
  5. * https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
  6. *-----------------------------------------------------------------------------*/
  7. var __defProp = Object.defineProperty;
  8. var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  9. var __getOwnPropNames = Object.getOwnPropertyNames;
  10. var __hasOwnProp = Object.prototype.hasOwnProperty;
  11. var __copyProps = (to, from, except, desc) => {
  12. if (from && typeof from === "object" || typeof from === "function") {
  13. for (let key of __getOwnPropNames(from))
  14. if (!__hasOwnProp.call(to, key) && key !== except)
  15. __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  16. }
  17. return to;
  18. };
  19. var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
  20. // src/fillers/monaco-editor-core.ts
  21. var monaco_editor_core_exports = {};
  22. __reExport(monaco_editor_core_exports, monaco_editor_core_star);
  23. import * as monaco_editor_core_star from "../../editor/editor.api.js";
  24. // src/basic-languages/yaml/yaml.ts
  25. var conf = {
  26. comments: {
  27. lineComment: "#"
  28. },
  29. brackets: [
  30. ["{", "}"],
  31. ["[", "]"],
  32. ["(", ")"]
  33. ],
  34. autoClosingPairs: [
  35. { open: "{", close: "}" },
  36. { open: "[", close: "]" },
  37. { open: "(", close: ")" },
  38. { open: '"', close: '"' },
  39. { open: "'", close: "'" }
  40. ],
  41. surroundingPairs: [
  42. { open: "{", close: "}" },
  43. { open: "[", close: "]" },
  44. { open: "(", close: ")" },
  45. { open: '"', close: '"' },
  46. { open: "'", close: "'" }
  47. ],
  48. folding: {
  49. offSide: true
  50. },
  51. onEnterRules: [
  52. {
  53. beforeText: /:\s*$/,
  54. action: {
  55. indentAction: monaco_editor_core_exports.languages.IndentAction.Indent
  56. }
  57. }
  58. ]
  59. };
  60. var language = {
  61. tokenPostfix: ".yaml",
  62. brackets: [
  63. { token: "delimiter.bracket", open: "{", close: "}" },
  64. { token: "delimiter.square", open: "[", close: "]" }
  65. ],
  66. keywords: ["true", "True", "TRUE", "false", "False", "FALSE", "null", "Null", "Null", "~"],
  67. numberInteger: /(?:0|[+-]?[0-9]+)/,
  68. numberFloat: /(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/,
  69. numberOctal: /0o[0-7]+/,
  70. numberHex: /0x[0-9a-fA-F]+/,
  71. numberInfinity: /[+-]?\.(?:inf|Inf|INF)/,
  72. numberNaN: /\.(?:nan|Nan|NAN)/,
  73. numberDate: /\d{4}-\d\d-\d\d([Tt ]\d\d:\d\d:\d\d(\.\d+)?(( ?[+-]\d\d?(:\d\d)?)|Z)?)?/,
  74. escapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
  75. tokenizer: {
  76. root: [
  77. { include: "@whitespace" },
  78. { include: "@comment" },
  79. [/%[^ ]+.*$/, "meta.directive"],
  80. [/---/, "operators.directivesEnd"],
  81. [/\.{3}/, "operators.documentEnd"],
  82. [/[-?:](?= )/, "operators"],
  83. { include: "@anchor" },
  84. { include: "@tagHandle" },
  85. { include: "@flowCollections" },
  86. { include: "@blockStyle" },
  87. [/@numberInteger(?![ \t]*\S+)/, "number"],
  88. [/@numberFloat(?![ \t]*\S+)/, "number.float"],
  89. [/@numberOctal(?![ \t]*\S+)/, "number.octal"],
  90. [/@numberHex(?![ \t]*\S+)/, "number.hex"],
  91. [/@numberInfinity(?![ \t]*\S+)/, "number.infinity"],
  92. [/@numberNaN(?![ \t]*\S+)/, "number.nan"],
  93. [/@numberDate(?![ \t]*\S+)/, "number.date"],
  94. [/(".*?"|'.*?'|.*?)([ \t]*)(:)( |$)/, ["type", "white", "operators", "white"]],
  95. { include: "@flowScalars" },
  96. [
  97. /[^#]+/,
  98. {
  99. cases: {
  100. "@keywords": "keyword",
  101. "@default": "string"
  102. }
  103. }
  104. ]
  105. ],
  106. object: [
  107. { include: "@whitespace" },
  108. { include: "@comment" },
  109. [/\}/, "@brackets", "@pop"],
  110. [/,/, "delimiter.comma"],
  111. [/:(?= )/, "operators"],
  112. [/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/, "type"],
  113. { include: "@flowCollections" },
  114. { include: "@flowScalars" },
  115. { include: "@tagHandle" },
  116. { include: "@anchor" },
  117. { include: "@flowNumber" },
  118. [
  119. /[^\},]+/,
  120. {
  121. cases: {
  122. "@keywords": "keyword",
  123. "@default": "string"
  124. }
  125. }
  126. ]
  127. ],
  128. array: [
  129. { include: "@whitespace" },
  130. { include: "@comment" },
  131. [/\]/, "@brackets", "@pop"],
  132. [/,/, "delimiter.comma"],
  133. { include: "@flowCollections" },
  134. { include: "@flowScalars" },
  135. { include: "@tagHandle" },
  136. { include: "@anchor" },
  137. { include: "@flowNumber" },
  138. [
  139. /[^\],]+/,
  140. {
  141. cases: {
  142. "@keywords": "keyword",
  143. "@default": "string"
  144. }
  145. }
  146. ]
  147. ],
  148. multiString: [[/^( +).+$/, "string", "@multiStringContinued.$1"]],
  149. multiStringContinued: [
  150. [
  151. /^( *).+$/,
  152. {
  153. cases: {
  154. "$1==$S2": "string",
  155. "@default": { token: "@rematch", next: "@popall" }
  156. }
  157. }
  158. ]
  159. ],
  160. whitespace: [[/[ \t\r\n]+/, "white"]],
  161. comment: [[/#.*$/, "comment"]],
  162. flowCollections: [
  163. [/\[/, "@brackets", "@array"],
  164. [/\{/, "@brackets", "@object"]
  165. ],
  166. flowScalars: [
  167. [/"([^"\\]|\\.)*$/, "string.invalid"],
  168. [/'([^'\\]|\\.)*$/, "string.invalid"],
  169. [/'[^']*'/, "string"],
  170. [/"/, "string", "@doubleQuotedString"]
  171. ],
  172. doubleQuotedString: [
  173. [/[^\\"]+/, "string"],
  174. [/@escapes/, "string.escape"],
  175. [/\\./, "string.escape.invalid"],
  176. [/"/, "string", "@pop"]
  177. ],
  178. blockStyle: [[/[>|][0-9]*[+-]?$/, "operators", "@multiString"]],
  179. flowNumber: [
  180. [/@numberInteger(?=[ \t]*[,\]\}])/, "number"],
  181. [/@numberFloat(?=[ \t]*[,\]\}])/, "number.float"],
  182. [/@numberOctal(?=[ \t]*[,\]\}])/, "number.octal"],
  183. [/@numberHex(?=[ \t]*[,\]\}])/, "number.hex"],
  184. [/@numberInfinity(?=[ \t]*[,\]\}])/, "number.infinity"],
  185. [/@numberNaN(?=[ \t]*[,\]\}])/, "number.nan"],
  186. [/@numberDate(?=[ \t]*[,\]\}])/, "number.date"]
  187. ],
  188. tagHandle: [[/\![^ ]*/, "tag"]],
  189. anchor: [[/[&*][^ ]+/, "namespace"]]
  190. }
  191. };
  192. export {
  193. conf,
  194. language
  195. };