yaml.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. define('vs/basic-languages/yaml/yaml',["require", "exports"], function (require, exports) {
  2. "use strict";
  3. Object.defineProperty(exports, "__esModule", { value: true });
  4. exports.language = exports.conf = void 0;
  5. exports.conf = {
  6. comments: {
  7. lineComment: '#'
  8. },
  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. folding: {
  29. offSide: true
  30. }
  31. };
  32. exports.language = {
  33. tokenPostfix: '.yaml',
  34. brackets: [
  35. { token: 'delimiter.bracket', open: '{', close: '}' },
  36. { token: 'delimiter.square', open: '[', close: ']' }
  37. ],
  38. keywords: ['true', 'True', 'TRUE', 'false', 'False', 'FALSE', 'null', 'Null', 'Null', '~'],
  39. numberInteger: /(?:0|[+-]?[0-9]+)/,
  40. numberFloat: /(?:0|[+-]?[0-9]+)(?:\.[0-9]+)?(?:e[-+][1-9][0-9]*)?/,
  41. numberOctal: /0o[0-7]+/,
  42. numberHex: /0x[0-9a-fA-F]+/,
  43. numberInfinity: /[+-]?\.(?:inf|Inf|INF)/,
  44. numberNaN: /\.(?:nan|Nan|NAN)/,
  45. numberDate: /\d{4}-\d\d-\d\d([Tt ]\d\d:\d\d:\d\d(\.\d+)?(( ?[+-]\d\d?(:\d\d)?)|Z)?)?/,
  46. escapes: /\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,
  47. tokenizer: {
  48. root: [
  49. { include: '@whitespace' },
  50. { include: '@comment' },
  51. // Directive
  52. [/%[^ ]+.*$/, 'meta.directive'],
  53. // Document Markers
  54. [/---/, 'operators.directivesEnd'],
  55. [/\.{3}/, 'operators.documentEnd'],
  56. // Block Structure Indicators
  57. [/[-?:](?= )/, 'operators'],
  58. { include: '@anchor' },
  59. { include: '@tagHandle' },
  60. { include: '@flowCollections' },
  61. { include: '@blockStyle' },
  62. // Numbers
  63. [/@numberInteger(?![ \t]*\S+)/, 'number'],
  64. [/@numberFloat(?![ \t]*\S+)/, 'number.float'],
  65. [/@numberOctal(?![ \t]*\S+)/, 'number.octal'],
  66. [/@numberHex(?![ \t]*\S+)/, 'number.hex'],
  67. [/@numberInfinity(?![ \t]*\S+)/, 'number.infinity'],
  68. [/@numberNaN(?![ \t]*\S+)/, 'number.nan'],
  69. [/@numberDate(?![ \t]*\S+)/, 'number.date'],
  70. // Key:Value pair
  71. [/(".*?"|'.*?'|.*?)([ \t]*)(:)( |$)/, ['type', 'white', 'operators', 'white']],
  72. { include: '@flowScalars' },
  73. // String nodes
  74. [
  75. /[^#]+/,
  76. {
  77. cases: {
  78. '@keywords': 'keyword',
  79. '@default': 'string'
  80. }
  81. }
  82. ]
  83. ],
  84. // Flow Collection: Flow Mapping
  85. object: [
  86. { include: '@whitespace' },
  87. { include: '@comment' },
  88. // Flow Mapping termination
  89. [/\}/, '@brackets', '@pop'],
  90. // Flow Mapping delimiter
  91. [/,/, 'delimiter.comma'],
  92. // Flow Mapping Key:Value delimiter
  93. [/:(?= )/, 'operators'],
  94. // Flow Mapping Key:Value key
  95. [/(?:".*?"|'.*?'|[^,\{\[]+?)(?=: )/, 'type'],
  96. // Start Flow Style
  97. { include: '@flowCollections' },
  98. { include: '@flowScalars' },
  99. // Scalar Data types
  100. { include: '@tagHandle' },
  101. { include: '@anchor' },
  102. { include: '@flowNumber' },
  103. // Other value (keyword or string)
  104. [
  105. /[^\},]+/,
  106. {
  107. cases: {
  108. '@keywords': 'keyword',
  109. '@default': 'string'
  110. }
  111. }
  112. ]
  113. ],
  114. // Flow Collection: Flow Sequence
  115. array: [
  116. { include: '@whitespace' },
  117. { include: '@comment' },
  118. // Flow Sequence termination
  119. [/\]/, '@brackets', '@pop'],
  120. // Flow Sequence delimiter
  121. [/,/, 'delimiter.comma'],
  122. // Start Flow Style
  123. { include: '@flowCollections' },
  124. { include: '@flowScalars' },
  125. // Scalar Data types
  126. { include: '@tagHandle' },
  127. { include: '@anchor' },
  128. { include: '@flowNumber' },
  129. // Other value (keyword or string)
  130. [
  131. /[^\],]+/,
  132. {
  133. cases: {
  134. '@keywords': 'keyword',
  135. '@default': 'string'
  136. }
  137. }
  138. ]
  139. ],
  140. // First line of a Block Style
  141. multiString: [[/^( +).+$/, 'string', '@multiStringContinued.$1']],
  142. // Further lines of a Block Style
  143. // Workaround for indentation detection
  144. multiStringContinued: [
  145. [
  146. /^( *).+$/,
  147. {
  148. cases: {
  149. '$1==$S2': 'string',
  150. '@default': { token: '@rematch', next: '@popall' }
  151. }
  152. }
  153. ]
  154. ],
  155. whitespace: [[/[ \t\r\n]+/, 'white']],
  156. // Only line comments
  157. comment: [[/#.*$/, 'comment']],
  158. // Start Flow Collections
  159. flowCollections: [
  160. [/\[/, '@brackets', '@array'],
  161. [/\{/, '@brackets', '@object']
  162. ],
  163. // Start Flow Scalars (quoted strings)
  164. flowScalars: [
  165. [/"([^"\\]|\\.)*$/, 'string.invalid'],
  166. [/'([^'\\]|\\.)*$/, 'string.invalid'],
  167. [/'[^']*'/, 'string'],
  168. [/"/, 'string', '@doubleQuotedString']
  169. ],
  170. doubleQuotedString: [
  171. [/[^\\"]+/, 'string'],
  172. [/@escapes/, 'string.escape'],
  173. [/\\./, 'string.escape.invalid'],
  174. [/"/, 'string', '@pop']
  175. ],
  176. // Start Block Scalar
  177. blockStyle: [[/[>|][0-9]*[+-]?$/, 'operators', '@multiString']],
  178. // Numbers in Flow Collections (terminate with ,]})
  179. flowNumber: [
  180. [/@numberInteger(?=[ \t]*[,\]\}])/, 'number'],
  181. [/@numberFloat(?=[ \t]*[,\]\}])/, 'number.float'],
  182. [/@numberOctal(?=[ \t]*[,\]\}])/, 'number.octal'],
  183. [/@numberHex(?=[ \t]*[,\]\}])/, 'number.hex'],
  184. [/@numberInfinity(?=[ \t]*[,\]\}])/, 'number.infinity'],
  185. [/@numberNaN(?=[ \t]*[,\]\}])/, 'number.nan'],
  186. [/@numberDate(?=[ \t]*[,\]\}])/, 'number.date']
  187. ],
  188. tagHandle: [[/\![^ ]*/, 'tag']],
  189. anchor: [[/[&*][^ ]+/, 'namespace']]
  190. }
  191. };
  192. });