dockerfile.js 4.0 KB

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