hcl.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  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/hcl/hcl", ["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/hcl/hcl.ts
  28. var hcl_exports = {};
  29. __export(hcl_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: '"', notIn: ["string"] }
  48. ],
  49. surroundingPairs: [
  50. { open: "{", close: "}" },
  51. { open: "[", close: "]" },
  52. { open: "(", close: ")" },
  53. { open: '"', close: '"' }
  54. ]
  55. };
  56. var language = {
  57. defaultToken: "",
  58. tokenPostfix: ".hcl",
  59. keywords: [
  60. "var",
  61. "local",
  62. "path",
  63. "for_each",
  64. "any",
  65. "string",
  66. "number",
  67. "bool",
  68. "true",
  69. "false",
  70. "null",
  71. "if ",
  72. "else ",
  73. "endif ",
  74. "for ",
  75. "in",
  76. "endfor"
  77. ],
  78. operators: [
  79. "=",
  80. ">=",
  81. "<=",
  82. "==",
  83. "!=",
  84. "+",
  85. "-",
  86. "*",
  87. "/",
  88. "%",
  89. "&&",
  90. "||",
  91. "!",
  92. "<",
  93. ">",
  94. "?",
  95. "...",
  96. ":"
  97. ],
  98. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  99. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  100. terraformFunctions: /(abs|ceil|floor|log|max|min|pow|signum|chomp|format|formatlist|indent|join|lower|regex|regexall|replace|split|strrev|substr|title|trimspace|upper|chunklist|coalesce|coalescelist|compact|concat|contains|distinct|element|flatten|index|keys|length|list|lookup|map|matchkeys|merge|range|reverse|setintersection|setproduct|setunion|slice|sort|transpose|values|zipmap|base64decode|base64encode|base64gzip|csvdecode|jsondecode|jsonencode|urlencode|yamldecode|yamlencode|abspath|dirname|pathexpand|basename|file|fileexists|fileset|filebase64|templatefile|formatdate|timeadd|timestamp|base64sha256|base64sha512|bcrypt|filebase64sha256|filebase64sha512|filemd5|filemd1|filesha256|filesha512|md5|rsadecrypt|sha1|sha256|sha512|uuid|uuidv5|cidrhost|cidrnetmask|cidrsubnet|tobool|tolist|tomap|tonumber|toset|tostring)/,
  101. terraformMainBlocks: /(module|data|terraform|resource|provider|variable|output|locals)/,
  102. tokenizer: {
  103. root: [
  104. [
  105. /^@terraformMainBlocks([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)(\{)/,
  106. ["type", "", "string", "", "string", "", "@brackets"]
  107. ],
  108. [
  109. /(\w+[ \t]+)([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)(\{)/,
  110. ["identifier", "", "string", "", "string", "", "@brackets"]
  111. ],
  112. [
  113. /(\w+[ \t]+)([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)([\w-]+|"[\w-]+"|)(=)(\{)/,
  114. ["identifier", "", "string", "", "operator", "", "@brackets"]
  115. ],
  116. { include: "@terraform" }
  117. ],
  118. terraform: [
  119. [/@terraformFunctions(\()/, ["type", "@brackets"]],
  120. [
  121. /[a-zA-Z_]\w*-*/,
  122. {
  123. cases: {
  124. "@keywords": { token: "keyword.$0" },
  125. "@default": "variable"
  126. }
  127. }
  128. ],
  129. { include: "@whitespace" },
  130. { include: "@heredoc" },
  131. [/[{}()\[\]]/, "@brackets"],
  132. [/[<>](?!@symbols)/, "@brackets"],
  133. [
  134. /@symbols/,
  135. {
  136. cases: {
  137. "@operators": "operator",
  138. "@default": ""
  139. }
  140. }
  141. ],
  142. [/\d*\d+[eE]([\-+]?\d+)?/, "number.float"],
  143. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"],
  144. [/\d[\d']*/, "number"],
  145. [/\d/, "number"],
  146. [/[;,.]/, "delimiter"],
  147. [/"/, "string", "@string"],
  148. [/'/, "invalid"]
  149. ],
  150. heredoc: [
  151. [/<<[-]*\s*["]?([\w\-]+)["]?/, { token: "string.heredoc.delimiter", next: "@heredocBody.$1" }]
  152. ],
  153. heredocBody: [
  154. [
  155. /([\w\-]+)$/,
  156. {
  157. cases: {
  158. "$1==$S2": [
  159. {
  160. token: "string.heredoc.delimiter",
  161. next: "@popall"
  162. }
  163. ],
  164. "@default": "string.heredoc"
  165. }
  166. }
  167. ],
  168. [/./, "string.heredoc"]
  169. ],
  170. whitespace: [
  171. [/[ \t\r\n]+/, ""],
  172. [/\/\*/, "comment", "@comment"],
  173. [/\/\/.*$/, "comment"],
  174. [/#.*$/, "comment"]
  175. ],
  176. comment: [
  177. [/[^\/*]+/, "comment"],
  178. [/\*\//, "comment", "@pop"],
  179. [/[\/*]/, "comment"]
  180. ],
  181. string: [
  182. [/\$\{/, { token: "delimiter", next: "@stringExpression" }],
  183. [/[^\\"\$]+/, "string"],
  184. [/@escapes/, "string.escape"],
  185. [/\\./, "string.escape.invalid"],
  186. [/"/, "string", "@popall"]
  187. ],
  188. stringInsideExpression: [
  189. [/[^\\"]+/, "string"],
  190. [/@escapes/, "string.escape"],
  191. [/\\./, "string.escape.invalid"],
  192. [/"/, "string", "@pop"]
  193. ],
  194. stringExpression: [
  195. [/\}/, { token: "delimiter", next: "@pop" }],
  196. [/"/, "string", "@stringInsideExpression"],
  197. { include: "@terraform" }
  198. ]
  199. }
  200. };
  201. return __toCommonJS(hcl_exports);
  202. })();
  203. return moduleExports;
  204. });