dockerfile.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. define('vs/basic-languages/dockerfile/dockerfile',["require", "exports"], function (require, exports) {
  6. "use strict";
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.language = exports.conf = void 0;
  9. exports.conf = {
  10. brackets: [
  11. ['{', '}'],
  12. ['[', ']'],
  13. ['(', ')']
  14. ],
  15. autoClosingPairs: [
  16. { open: '{', close: '}' },
  17. { open: '[', close: ']' },
  18. { open: '(', close: ')' },
  19. { open: '"', close: '"' },
  20. { open: "'", close: "'" }
  21. ],
  22. surroundingPairs: [
  23. { open: '{', close: '}' },
  24. { open: '[', close: ']' },
  25. { open: '(', close: ')' },
  26. { open: '"', close: '"' },
  27. { open: "'", close: "'" }
  28. ]
  29. };
  30. exports.language = {
  31. defaultToken: '',
  32. tokenPostfix: '.dockerfile',
  33. variable: /\${?[\w]+}?/,
  34. tokenizer: {
  35. root: [
  36. { include: '@whitespace' },
  37. { include: '@comment' },
  38. [/(ONBUILD)(\s+)/, ['keyword', '']],
  39. [/(ENV)(\s+)([\w]+)/, ['keyword', '', { token: 'variable', next: '@arguments' }]],
  40. [
  41. /(FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|ARG|VOLUME|LABEL|USER|WORKDIR|COPY|CMD|STOPSIGNAL|SHELL|HEALTHCHECK|ENTRYPOINT)/,
  42. { token: 'keyword', next: '@arguments' }
  43. ]
  44. ],
  45. arguments: [
  46. { include: '@whitespace' },
  47. { include: '@strings' },
  48. [
  49. /(@variable)/,
  50. {
  51. cases: {
  52. '@eos': { token: 'variable', next: '@popall' },
  53. '@default': 'variable'
  54. }
  55. }
  56. ],
  57. [
  58. /\\/,
  59. {
  60. cases: {
  61. '@eos': '',
  62. '@default': ''
  63. }
  64. }
  65. ],
  66. [
  67. /./,
  68. {
  69. cases: {
  70. '@eos': { token: '', next: '@popall' },
  71. '@default': ''
  72. }
  73. }
  74. ]
  75. ],
  76. // Deal with white space, including comments
  77. whitespace: [
  78. [
  79. /\s+/,
  80. {
  81. cases: {
  82. '@eos': { token: '', next: '@popall' },
  83. '@default': ''
  84. }
  85. }
  86. ]
  87. ],
  88. comment: [[/(^#.*$)/, 'comment', '@popall']],
  89. // Recognize strings, including those broken across lines with \ (but not without)
  90. strings: [
  91. [/\\'$/, '', '@popall'],
  92. [/\\'/, ''],
  93. [/'$/, 'string', '@popall'],
  94. [/'/, 'string', '@stringBody'],
  95. [/"$/, 'string', '@popall'],
  96. [/"/, 'string', '@dblStringBody']
  97. ],
  98. stringBody: [
  99. [
  100. /[^\\\$']/,
  101. {
  102. cases: {
  103. '@eos': { token: 'string', next: '@popall' },
  104. '@default': 'string'
  105. }
  106. }
  107. ],
  108. [/\\./, 'string.escape'],
  109. [/'$/, 'string', '@popall'],
  110. [/'/, 'string', '@pop'],
  111. [/(@variable)/, 'variable'],
  112. [/\\$/, 'string'],
  113. [/$/, 'string', '@popall']
  114. ],
  115. dblStringBody: [
  116. [
  117. /[^\\\$"]/,
  118. {
  119. cases: {
  120. '@eos': { token: 'string', next: '@popall' },
  121. '@default': 'string'
  122. }
  123. }
  124. ],
  125. [/\\./, 'string.escape'],
  126. [/"$/, 'string', '@popall'],
  127. [/"/, 'string', '@pop'],
  128. [/(@variable)/, 'variable'],
  129. [/\\$/, 'string'],
  130. [/$/, 'string', '@popall']
  131. ]
  132. }
  133. };
  134. });