bicep.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Copyright (c) Microsoft Corporation.
  2. // Licensed under the MIT License.
  3. define('vs/basic-languages/bicep/bicep',["require", "exports"], function (require, exports) {
  4. "use strict";
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. exports.language = exports.conf = void 0;
  7. var bounded = function (text) { return "\\b" + text + "\\b"; };
  8. var identifierStart = '[_a-zA-Z]';
  9. var identifierContinue = '[_a-zA-Z0-9]';
  10. var identifier = bounded("" + identifierStart + identifierContinue + "*");
  11. var keywords = [
  12. 'targetScope',
  13. 'resource',
  14. 'module',
  15. 'param',
  16. 'var',
  17. 'output',
  18. 'for',
  19. 'in',
  20. 'if',
  21. 'existing'
  22. ];
  23. var namedLiterals = ['true', 'false', 'null'];
  24. var nonCommentWs = "[ \\t\\r\\n]";
  25. var numericLiteral = "[0-9]+";
  26. exports.conf = {
  27. comments: {
  28. lineComment: '//',
  29. blockComment: ['/*', '*/']
  30. },
  31. brackets: [
  32. ['{', '}'],
  33. ['[', ']'],
  34. ['(', ')']
  35. ],
  36. surroundingPairs: [
  37. { open: '{', close: '}' },
  38. { open: '[', close: ']' },
  39. { open: '(', close: ')' },
  40. { open: "'", close: "'" },
  41. { open: "'''", close: "'''" }
  42. ],
  43. autoClosingPairs: [
  44. { open: '{', close: '}' },
  45. { open: '[', close: ']' },
  46. { open: '(', close: ')' },
  47. { open: "'", close: "'", notIn: ['string', 'comment'] },
  48. { open: "'''", close: "'''", notIn: ['string', 'comment'] }
  49. ],
  50. autoCloseBefore: ":.,=}])' \n\t",
  51. indentationRules: {
  52. increaseIndentPattern: new RegExp('^((?!\\/\\/).)*(\\{[^}"\'`]*|\\([^)"\'`]*|\\[[^\\]"\'`]*)$'),
  53. decreaseIndentPattern: new RegExp('^((?!.*?\\/\\*).*\\*/)?\\s*[\\}\\]].*$')
  54. }
  55. };
  56. exports.language = {
  57. defaultToken: '',
  58. tokenPostfix: '.bicep',
  59. brackets: [
  60. { open: '{', close: '}', token: 'delimiter.curly' },
  61. { open: '[', close: ']', token: 'delimiter.square' },
  62. { open: '(', close: ')', token: 'delimiter.parenthesis' }
  63. ],
  64. symbols: /[=><!~?:&|+\-*/^%]+/,
  65. keywords: keywords,
  66. namedLiterals: namedLiterals,
  67. escapes: "\\\\(u{[0-9A-Fa-f]+}|n|r|t|\\\\|'|\\${)",
  68. tokenizer: {
  69. root: [{ include: '@expression' }, { include: '@whitespace' }],
  70. stringVerbatim: [
  71. { regex: "(|'|'')[^']", action: { token: 'string' } },
  72. { regex: "'''", action: { token: 'string.quote', next: '@pop' } }
  73. ],
  74. stringLiteral: [
  75. { regex: "\\${", action: { token: 'delimiter.bracket', next: '@bracketCounting' } },
  76. { regex: "[^\\\\'$]+", action: { token: 'string' } },
  77. { regex: '@escapes', action: { token: 'string.escape' } },
  78. { regex: "\\\\.", action: { token: 'string.escape.invalid' } },
  79. { regex: "'", action: { token: 'string', next: '@pop' } }
  80. ],
  81. bracketCounting: [
  82. { regex: "{", action: { token: 'delimiter.bracket', next: '@bracketCounting' } },
  83. { regex: "}", action: { token: 'delimiter.bracket', next: '@pop' } },
  84. { include: 'expression' }
  85. ],
  86. comment: [
  87. { regex: "[^\\*]+", action: { token: 'comment' } },
  88. { regex: "\\*\\/", action: { token: 'comment', next: '@pop' } },
  89. { regex: "[\\/*]", action: { token: 'comment' } }
  90. ],
  91. whitespace: [
  92. { regex: nonCommentWs },
  93. { regex: "\\/\\*", action: { token: 'comment', next: '@comment' } },
  94. { regex: "\\/\\/.*$", action: { token: 'comment' } }
  95. ],
  96. expression: [
  97. { regex: "'''", action: { token: 'string.quote', next: '@stringVerbatim' } },
  98. { regex: "'", action: { token: 'string.quote', next: '@stringLiteral' } },
  99. { regex: numericLiteral, action: { token: 'number' } },
  100. {
  101. regex: identifier,
  102. action: {
  103. cases: {
  104. '@keywords': { token: 'keyword' },
  105. '@namedLiterals': { token: 'keyword' },
  106. '@default': { token: 'identifier' }
  107. }
  108. }
  109. }
  110. ]
  111. }
  112. };
  113. });