hcl.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  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/hcl/hcl",[],()=>{
  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/hcl/hcl.ts
  17. var hcl_exports = {};
  18. __export(hcl_exports, {
  19. conf: () => conf,
  20. language: () => language
  21. });
  22. var conf = {
  23. comments: {
  24. lineComment: "#",
  25. blockComment: ["/*", "*/"]
  26. },
  27. brackets: [
  28. ["{", "}"],
  29. ["[", "]"],
  30. ["(", ")"]
  31. ],
  32. autoClosingPairs: [
  33. { open: "{", close: "}" },
  34. { open: "[", close: "]" },
  35. { open: "(", close: ")" },
  36. { open: '"', close: '"', notIn: ["string"] }
  37. ],
  38. surroundingPairs: [
  39. { open: "{", close: "}" },
  40. { open: "[", close: "]" },
  41. { open: "(", close: ")" },
  42. { open: '"', close: '"' }
  43. ]
  44. };
  45. var language = {
  46. defaultToken: "",
  47. tokenPostfix: ".hcl",
  48. keywords: [
  49. "var",
  50. "local",
  51. "path",
  52. "for_each",
  53. "any",
  54. "string",
  55. "number",
  56. "bool",
  57. "true",
  58. "false",
  59. "null",
  60. "if ",
  61. "else ",
  62. "endif ",
  63. "for ",
  64. "in",
  65. "endfor"
  66. ],
  67. operators: [
  68. "=",
  69. ">=",
  70. "<=",
  71. "==",
  72. "!=",
  73. "+",
  74. "-",
  75. "*",
  76. "/",
  77. "%",
  78. "&&",
  79. "||",
  80. "!",
  81. "<",
  82. ">",
  83. "?",
  84. "...",
  85. ":"
  86. ],
  87. symbols: /[=><!~?:&|+\-*\/\^%]+/,
  88. escapes: /\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,
  89. 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)/,
  90. terraformMainBlocks: /(module|data|terraform|resource|provider|variable|output|locals)/,
  91. tokenizer: {
  92. root: [
  93. [
  94. /^@terraformMainBlocks([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)(\{)/,
  95. ["type", "", "string", "", "string", "", "@brackets"]
  96. ],
  97. [
  98. /(\w+[ \t]+)([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)(\{)/,
  99. ["identifier", "", "string", "", "string", "", "@brackets"]
  100. ],
  101. [
  102. /(\w+[ \t]+)([ \t]*)([\w-]+|"[\w-]+"|)([ \t]*)([\w-]+|"[\w-]+"|)(=)(\{)/,
  103. ["identifier", "", "string", "", "operator", "", "@brackets"]
  104. ],
  105. { include: "@terraform" }
  106. ],
  107. terraform: [
  108. [/@terraformFunctions(\()/, ["type", "@brackets"]],
  109. [
  110. /[a-zA-Z_]\w*-*/,
  111. {
  112. cases: {
  113. "@keywords": { token: "keyword.$0" },
  114. "@default": "variable"
  115. }
  116. }
  117. ],
  118. { include: "@whitespace" },
  119. { include: "@heredoc" },
  120. [/[{}()\[\]]/, "@brackets"],
  121. [/[<>](?!@symbols)/, "@brackets"],
  122. [
  123. /@symbols/,
  124. {
  125. cases: {
  126. "@operators": "operator",
  127. "@default": ""
  128. }
  129. }
  130. ],
  131. [/\d*\d+[eE]([\-+]?\d+)?/, "number.float"],
  132. [/\d*\.\d+([eE][\-+]?\d+)?/, "number.float"],
  133. [/\d[\d']*/, "number"],
  134. [/\d/, "number"],
  135. [/[;,.]/, "delimiter"],
  136. [/"/, "string", "@string"],
  137. [/'/, "invalid"]
  138. ],
  139. heredoc: [
  140. [/<<[-]*\s*["]?([\w\-]+)["]?/, { token: "string.heredoc.delimiter", next: "@heredocBody.$1" }]
  141. ],
  142. heredocBody: [
  143. [
  144. /([\w\-]+)$/,
  145. {
  146. cases: {
  147. "$1==$S2": [
  148. {
  149. token: "string.heredoc.delimiter",
  150. next: "@popall"
  151. }
  152. ],
  153. "@default": "string.heredoc"
  154. }
  155. }
  156. ],
  157. [/./, "string.heredoc"]
  158. ],
  159. whitespace: [
  160. [/[ \t\r\n]+/, ""],
  161. [/\/\*/, "comment", "@comment"],
  162. [/\/\/.*$/, "comment"],
  163. [/#.*$/, "comment"]
  164. ],
  165. comment: [
  166. [/[^\/*]+/, "comment"],
  167. [/\*\//, "comment", "@pop"],
  168. [/[\/*]/, "comment"]
  169. ],
  170. string: [
  171. [/\$\{/, { token: "delimiter", next: "@stringExpression" }],
  172. [/[^\\"\$]+/, "string"],
  173. [/@escapes/, "string.escape"],
  174. [/\\./, "string.escape.invalid"],
  175. [/"/, "string", "@popall"]
  176. ],
  177. stringInsideExpression: [
  178. [/[^\\"]+/, "string"],
  179. [/@escapes/, "string.escape"],
  180. [/\\./, "string.escape.invalid"],
  181. [/"/, "string", "@pop"]
  182. ],
  183. stringExpression: [
  184. [/\}/, { token: "delimiter", next: "@pop" }],
  185. [/"/, "string", "@stringInsideExpression"],
  186. { include: "@terraform" }
  187. ]
  188. }
  189. };
  190. return hcl_exports;
  191. })();
  192. return moduleExports;
  193. });