dockerfile.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. // src/basic-languages/dockerfile/dockerfile.ts
  8. var conf = {
  9. brackets: [
  10. ["{", "}"],
  11. ["[", "]"],
  12. ["(", ")"]
  13. ],
  14. autoClosingPairs: [
  15. { open: "{", close: "}" },
  16. { open: "[", close: "]" },
  17. { open: "(", close: ")" },
  18. { open: '"', close: '"' },
  19. { open: "'", close: "'" }
  20. ],
  21. surroundingPairs: [
  22. { open: "{", close: "}" },
  23. { open: "[", close: "]" },
  24. { open: "(", close: ")" },
  25. { open: '"', close: '"' },
  26. { open: "'", close: "'" }
  27. ]
  28. };
  29. var language = {
  30. defaultToken: "",
  31. tokenPostfix: ".dockerfile",
  32. variable: /\${?[\w]+}?/,
  33. tokenizer: {
  34. root: [
  35. { include: "@whitespace" },
  36. { include: "@comment" },
  37. [/(ONBUILD)(\s+)/, ["keyword", ""]],
  38. [/(ENV)(\s+)([\w]+)/, ["keyword", "", { token: "variable", next: "@arguments" }]],
  39. [
  40. /(FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|ARG|VOLUME|LABEL|USER|WORKDIR|COPY|CMD|STOPSIGNAL|SHELL|HEALTHCHECK|ENTRYPOINT)/,
  41. { token: "keyword", next: "@arguments" }
  42. ]
  43. ],
  44. arguments: [
  45. { include: "@whitespace" },
  46. { include: "@strings" },
  47. [
  48. /(@variable)/,
  49. {
  50. cases: {
  51. "@eos": { token: "variable", next: "@popall" },
  52. "@default": "variable"
  53. }
  54. }
  55. ],
  56. [
  57. /\\/,
  58. {
  59. cases: {
  60. "@eos": "",
  61. "@default": ""
  62. }
  63. }
  64. ],
  65. [
  66. /./,
  67. {
  68. cases: {
  69. "@eos": { token: "", next: "@popall" },
  70. "@default": ""
  71. }
  72. }
  73. ]
  74. ],
  75. whitespace: [
  76. [
  77. /\s+/,
  78. {
  79. cases: {
  80. "@eos": { token: "", next: "@popall" },
  81. "@default": ""
  82. }
  83. }
  84. ]
  85. ],
  86. comment: [[/(^#.*$)/, "comment", "@popall"]],
  87. strings: [
  88. [/\\'$/, "", "@popall"],
  89. [/\\'/, ""],
  90. [/'$/, "string", "@popall"],
  91. [/'/, "string", "@stringBody"],
  92. [/"$/, "string", "@popall"],
  93. [/"/, "string", "@dblStringBody"]
  94. ],
  95. stringBody: [
  96. [
  97. /[^\\\$']/,
  98. {
  99. cases: {
  100. "@eos": { token: "string", next: "@popall" },
  101. "@default": "string"
  102. }
  103. }
  104. ],
  105. [/\\./, "string.escape"],
  106. [/'$/, "string", "@popall"],
  107. [/'/, "string", "@pop"],
  108. [/(@variable)/, "variable"],
  109. [/\\$/, "string"],
  110. [/$/, "string", "@popall"]
  111. ],
  112. dblStringBody: [
  113. [
  114. /[^\\\$"]/,
  115. {
  116. cases: {
  117. "@eos": { token: "string", next: "@popall" },
  118. "@default": "string"
  119. }
  120. }
  121. ],
  122. [/\\./, "string.escape"],
  123. [/"$/, "string", "@popall"],
  124. [/"/, "string", "@pop"],
  125. [/(@variable)/, "variable"],
  126. [/\\$/, "string"],
  127. [/$/, "string", "@popall"]
  128. ]
  129. }
  130. };
  131. export {
  132. conf,
  133. language
  134. };