You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
5.0KB

  1. %YAML 1.2
  2. ---
  3. # http://www.sublimetext.com/docs/3/syntax.html
  4. name: TOML
  5. file_extensions:
  6. - toml
  7. - tml
  8. scope: source.toml
  9. contexts:
  10. main:
  11. - include: comments
  12. - include: tables
  13. - include: keys
  14. - include: illegal
  15. array:
  16. - match: '(?<!\w)(\[)\s*'
  17. comment: Array
  18. captures:
  19. 1: punctuation.definition.array.toml
  20. push:
  21. - match: '\s*(\])(?!\w)'
  22. captures:
  23. 1: punctuation.definition.array.toml
  24. pop: true
  25. - include: comments
  26. - include: dataTypes
  27. boolean:
  28. - match: (?<!\w)(true|false)(?!\w)
  29. comment: Boolean
  30. captures:
  31. 1: constant.other.boolean.toml
  32. comments:
  33. - match: \s*((#).*)$
  34. comment: Comments
  35. captures:
  36. 1: comment.line.number-sign.toml
  37. 2: punctuation.definition.comment.toml
  38. dataTypes:
  39. - include: inlinetable
  40. - include: array
  41. - include: string
  42. - include: dateTime
  43. - include: float
  44. - include: integer
  45. - include: boolean
  46. dateTime:
  47. - match: '(?<!\w)(\d{4}\-\d{2}\-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[\+\-]\d{2}:\d{2}))(?!\w)'
  48. comment: DateTime
  49. captures:
  50. 1: constant.other.datetime.toml
  51. float:
  52. - match: '(?<!\w)([\+\-]?(?:[1-9][0-9]*|0)(?:(?:\.[0-9]*)?[eE][\+\-]?[1-9][0-9]*|(?:\.[0-9]*)))(?!\w)'
  53. comment: Float, decimal and exponential representation
  54. captures:
  55. 1: constant.numeric.float.toml
  56. illegal:
  57. - match: (.*)
  58. comment: Invalid things -> everything unmatched
  59. captures:
  60. 1: invalid.illegal.toml
  61. inlinetable:
  62. - match: '(?<!\w)(\{)\s*'
  63. captures:
  64. 1: punctuation.definition.inlinetable.toml
  65. push:
  66. - match: '\s*(\})(?!\w)'
  67. captures:
  68. 1: punctuation.definition.inlinetable.toml
  69. pop: true
  70. - include: keys
  71. - include: dataTypes
  72. integer:
  73. - match: '(?<!\w)((?:[\+\-]?[1-9][0-9]*|0))(?!\w)'
  74. comment: Integer (with and without + and - prefixes)
  75. captures:
  76. 1: constant.numeric.integer.toml
  77. keys:
  78. - match: (\s*=.*)$
  79. comment: Assignments without key are invalid
  80. scope: invalid.illegal.noKeyDefined.toml
  81. - match: '(\s*[A-Za-z_\-][A-Za-z0-9_\-]*\s*=)(?=\s*$)'
  82. comment: Assignments without value are unusual
  83. scope: invalid.deprecated.noValueGiven.toml
  84. - match: '\s*([A-Za-z_-][A-Za-z0-9_-]*|".+"|''.+''|[0-9]+)\s*(=)\s*'
  85. captures:
  86. 1: keyword.key.toml
  87. 2: punctuation.definition.keyValuePair.toml
  88. push:
  89. - match: '($|(?==)|\,|\s*(?=\}))'
  90. pop: true
  91. - include: comments
  92. - include: dataTypes
  93. - include: illegal
  94. string:
  95. - match: "'''"
  96. comment: literal string block (no escape sequences)
  97. push:
  98. - meta_scope: string.quoted.triple.literal.block.toml
  99. - match: "'''"
  100. pop: true
  101. - match: "'.*?'"
  102. comment: literal string line (no escape sequences)
  103. scope: string.quoted.single.literal.line.toml
  104. - match: '"""'
  105. comment: basic string block
  106. push:
  107. - meta_scope: string.quoted.triple.basic.block.toml
  108. - match: '"""'
  109. pop: true
  110. - match: '[^"\\]*(?:\\.?[^"\\]*)*'
  111. scope: string.quoted.triple.basic.block.toml
  112. - match: '"[^"\\]*(?:\\.[^"\\]*)*"'
  113. comment: basic string line
  114. scope: string.quoted.single.basic.line.toml
  115. tables:
  116. - match: '^\s*(\[\[\]\]|\[\[\..*\]\]|\[\[.*\.\]\]|\[\[.*\.\..*\]\]|\[\[.*[\[\]#].*\]\]|\[\[.*\]\].+\n)'
  117. comment: non-empty etc. like tables, see below!
  118. push:
  119. - meta_scope: invalid.illegal.table.array.toml
  120. - match: '(?=^\s*\[?\[.*\]\]?)'
  121. pop: true
  122. - match: '^\s*(\[\[)([A-Za-z_\-][A-Za-z0-9_\-\.]*)(\]\])\s*'
  123. comment: A named TOML-Table-Array
  124. captures:
  125. 1: punctuation.definition.table.array.toml
  126. 2: entity.other.attribute-name.table.array.toml
  127. 3: punctuation.definition.table.array.toml
  128. push:
  129. - meta_scope: meta.tag.table.array.toml
  130. - match: '(?=^\s*\[?\[[A-Za-z_\-][A-Za-z0-9_\-\.]*\]\]?)'
  131. pop: true
  132. - include: comments
  133. - include: keys
  134. - include: illegal
  135. - match: '^\s*(\[\]|\[\..*\]|\[.*\.\]|\[.*\.\..*\]|\[.*[\[\]#].*\]|\[.*\].+\n)'
  136. comment: 'Each table name segment must be non-empty, must not contain the characters ''['', '']'' or ''#'' and is delimited by a ''.''. Tables "appear in square brackets *on a line by themselves*"'
  137. push:
  138. - meta_scope: invalid.illegal.table.toml
  139. - match: '(?=^\s*\[?\[.*\]\]?)'
  140. pop: true
  141. - match: '^\s*(\[)([A-Za-z_\-][A-Za-z0-9_\-\.]*)(\])\s*'
  142. comment: A named TOML-Table
  143. captures:
  144. 1: punctuation.definition.table.toml
  145. 2: entity.other.attribute-name.table.toml
  146. 3: punctuation.definition.table.toml
  147. push:
  148. - meta_scope: meta.tag.table.toml
  149. - match: '(?=^\s*\[?\[[A-Za-z_\-][A-Za-z0-9_\-\.]*\]\]?)'
  150. pop: true
  151. - include: comments
  152. - include: keys
  153. - include: illegal