powershell.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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/powershell/powershell", ["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/powershell/powershell.ts
  28. var powershell_exports = {};
  29. __export(powershell_exports, {
  30. conf: () => conf,
  31. language: () => language
  32. });
  33. var conf = {
  34. wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g,
  35. comments: {
  36. lineComment: "#",
  37. blockComment: ["<#", "#>"]
  38. },
  39. brackets: [
  40. ["{", "}"],
  41. ["[", "]"],
  42. ["(", ")"]
  43. ],
  44. autoClosingPairs: [
  45. { open: "{", close: "}" },
  46. { open: "[", close: "]" },
  47. { open: "(", close: ")" },
  48. { open: '"', close: '"', notIn: ["string"] },
  49. { open: "'", close: "'", notIn: ["string", "comment"] }
  50. ],
  51. surroundingPairs: [
  52. { open: "{", close: "}" },
  53. { open: "[", close: "]" },
  54. { open: "(", close: ")" },
  55. { open: '"', close: '"' },
  56. { open: "'", close: "'" }
  57. ],
  58. folding: {
  59. markers: {
  60. start: new RegExp("^\\s*#region\\b"),
  61. end: new RegExp("^\\s*#endregion\\b")
  62. }
  63. }
  64. };
  65. var language = {
  66. defaultToken: "",
  67. ignoreCase: true,
  68. tokenPostfix: ".ps1",
  69. brackets: [
  70. { token: "delimiter.curly", open: "{", close: "}" },
  71. { token: "delimiter.square", open: "[", close: "]" },
  72. { token: "delimiter.parenthesis", open: "(", close: ")" }
  73. ],
  74. keywords: [
  75. "begin",
  76. "break",
  77. "catch",
  78. "class",
  79. "continue",
  80. "data",
  81. "define",
  82. "do",
  83. "dynamicparam",
  84. "else",
  85. "elseif",
  86. "end",
  87. "exit",
  88. "filter",
  89. "finally",
  90. "for",
  91. "foreach",
  92. "from",
  93. "function",
  94. "if",
  95. "in",
  96. "param",
  97. "process",
  98. "return",
  99. "switch",
  100. "throw",
  101. "trap",
  102. "try",
  103. "until",
  104. "using",
  105. "var",
  106. "while",
  107. "workflow",
  108. "parallel",
  109. "sequence",
  110. "inlinescript",
  111. "configuration"
  112. ],
  113. helpKeywords: /SYNOPSIS|DESCRIPTION|PARAMETER|EXAMPLE|INPUTS|OUTPUTS|NOTES|LINK|COMPONENT|ROLE|FUNCTIONALITY|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP/,
  114. symbols: /[=><!~?&%|+\-*\/\^;\.,]+/,
  115. escapes: /`(?:[abfnrtv\\"'$]|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  116. tokenizer: {
  117. root: [
  118. [
  119. /[a-zA-Z_][\w-]*/,
  120. {
  121. cases: {
  122. "@keywords": { token: "keyword.$0" },
  123. "@default": ""
  124. }
  125. }
  126. ],
  127. [/[ \t\r\n]+/, ""],
  128. [/^:\w*/, "metatag"],
  129. [
  130. /\$(\{((global|local|private|script|using):)?[\w]+\}|((global|local|private|script|using):)?[\w]+)/,
  131. "variable"
  132. ],
  133. [/<#/, "comment", "@comment"],
  134. [/#.*$/, "comment"],
  135. [/[{}()\[\]]/, "@brackets"],
  136. [/@symbols/, "delimiter"],
  137. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"],
  138. [/0[xX][0-9a-fA-F_]*[0-9a-fA-F]/, "number.hex"],
  139. [/\d+?/, "number"],
  140. [/[;,.]/, "delimiter"],
  141. [/\@"/, "string", '@herestring."'],
  142. [/\@'/, "string", "@herestring.'"],
  143. [
  144. /"/,
  145. {
  146. cases: {
  147. "@eos": "string",
  148. "@default": { token: "string", next: '@string."' }
  149. }
  150. }
  151. ],
  152. [
  153. /'/,
  154. {
  155. cases: {
  156. "@eos": "string",
  157. "@default": { token: "string", next: "@string.'" }
  158. }
  159. }
  160. ]
  161. ],
  162. string: [
  163. [
  164. /[^"'\$`]+/,
  165. {
  166. cases: {
  167. "@eos": { token: "string", next: "@popall" },
  168. "@default": "string"
  169. }
  170. }
  171. ],
  172. [
  173. /@escapes/,
  174. {
  175. cases: {
  176. "@eos": { token: "string.escape", next: "@popall" },
  177. "@default": "string.escape"
  178. }
  179. }
  180. ],
  181. [
  182. /`./,
  183. {
  184. cases: {
  185. "@eos": {
  186. token: "string.escape.invalid",
  187. next: "@popall"
  188. },
  189. "@default": "string.escape.invalid"
  190. }
  191. }
  192. ],
  193. [
  194. /\$[\w]+$/,
  195. {
  196. cases: {
  197. '$S2=="': { token: "variable", next: "@popall" },
  198. "@default": { token: "string", next: "@popall" }
  199. }
  200. }
  201. ],
  202. [
  203. /\$[\w]+/,
  204. {
  205. cases: {
  206. '$S2=="': "variable",
  207. "@default": "string"
  208. }
  209. }
  210. ],
  211. [
  212. /["']/,
  213. {
  214. cases: {
  215. "$#==$S2": { token: "string", next: "@pop" },
  216. "@default": {
  217. cases: {
  218. "@eos": { token: "string", next: "@popall" },
  219. "@default": "string"
  220. }
  221. }
  222. }
  223. }
  224. ]
  225. ],
  226. herestring: [
  227. [
  228. /^\s*(["'])@/,
  229. {
  230. cases: {
  231. "$1==$S2": { token: "string", next: "@pop" },
  232. "@default": "string"
  233. }
  234. }
  235. ],
  236. [/[^\$`]+/, "string"],
  237. [/@escapes/, "string.escape"],
  238. [/`./, "string.escape.invalid"],
  239. [
  240. /\$[\w]+/,
  241. {
  242. cases: {
  243. '$S2=="': "variable",
  244. "@default": "string"
  245. }
  246. }
  247. ]
  248. ],
  249. comment: [
  250. [/[^#\.]+/, "comment"],
  251. [/#>/, "comment", "@pop"],
  252. [/(\.)(@helpKeywords)(?!\w)/, { token: "comment.keyword.$2" }],
  253. [/[\.#]/, "comment"]
  254. ]
  255. }
  256. };
  257. return __toCommonJS(powershell_exports);
  258. })();
  259. return moduleExports;
  260. });