dockerfile.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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(["require", "exports"], function (require, exports) {
  6. 'use strict';
  7. Object.defineProperty(exports, "__esModule", { value: true });
  8. exports.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. exports.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. [/(FROM|MAINTAINER|RUN|EXPOSE|ENV|ADD|ARG|VOLUME|LABEL|USER|WORKDIR|COPY|CMD|STOPSIGNAL|SHELL|HEALTHCHECK|ENTRYPOINT)/, { token: 'keyword', next: '@arguments' }]
  40. ],
  41. arguments: [
  42. { include: '@whitespace' },
  43. { include: '@strings' },
  44. [/(@variable)/, {
  45. cases: {
  46. '@eos': { token: 'variable', next: '@popall' },
  47. '@default': 'variable'
  48. }
  49. }],
  50. [/\\/, {
  51. cases: {
  52. '@eos': '',
  53. '@default': ''
  54. }
  55. }],
  56. [/./, {
  57. cases: {
  58. '@eos': { token: '', next: '@popall' },
  59. '@default': ''
  60. }
  61. }],
  62. ],
  63. // Deal with white space, including comments
  64. whitespace: [
  65. [/\s+/, {
  66. cases: {
  67. '@eos': { token: '', next: '@popall' },
  68. '@default': ''
  69. }
  70. }],
  71. ],
  72. comment: [
  73. [/(^#.*$)/, 'comment', '@popall']
  74. ],
  75. // Recognize strings, including those broken across lines with \ (but not without)
  76. strings: [
  77. [/'$/, 'string', '@popall'],
  78. [/'/, 'string', '@stringBody'],
  79. [/"$/, 'string', '@popall'],
  80. [/"/, 'string', '@dblStringBody']
  81. ],
  82. stringBody: [
  83. [/[^\\\$']/, {
  84. cases: {
  85. '@eos': { token: 'string', next: '@popall' },
  86. '@default': 'string'
  87. }
  88. }],
  89. [/\\./, 'string.escape'],
  90. [/'$/, 'string', '@popall'],
  91. [/'/, 'string', '@pop'],
  92. [/(@variable)/, 'variable'],
  93. [/\\$/, 'string'],
  94. [/$/, 'string', '@popall']
  95. ],
  96. dblStringBody: [
  97. [/[^\\\$"]/, {
  98. cases: {
  99. '@eos': { token: 'string', next: '@popall' },
  100. '@default': 'string'
  101. }
  102. }],
  103. [/\\./, 'string.escape'],
  104. [/"$/, 'string', '@popall'],
  105. [/"/, 'string', '@pop'],
  106. [/(@variable)/, 'variable'],
  107. [/\\$/, 'string'],
  108. [/$/, 'string', '@popall']
  109. ]
  110. }
  111. };
  112. });