powershell.js 6.3 KB

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