%YAML 1.2
---
name: RON
file_extensions:
- ron
scope: source.ron
contexts:
main:
- include: value
array:
- match: '\['
scope: punctuation.section.array.begin.ron
push:
- meta_scope: meta.structure.array.ron
- match: '\]'
scope: punctuation.section.array.end.ron
pop: true
- include: value
- match: ','
scope: punctuation.separator.array.ron
- match: '[^\s\]]'
scope: invalid.illegal.expected-array-separator.ron
comments:
- match: /\*\*(?!/)
scope: punctuation.definition.comment.ron
push:
- meta_scope: comment.block.documentation.ron
- match: \*/
pop: true
- match: /\*
scope: punctuation.definition.comment.ron
push:
- meta_scope: comment.block.ron
- match: \*/
pop: true
- match: (//).*$\n?
scope: comment.line.double-slash.js
captures:
1: punctuation.definition.comment.ron
constant:
- match: \b(true|false)\b
scope: constant.language.ron
number:
- match: |-
(?x: # turn on extended mode
-? # an optional minus
(?:
0 # a zero
| # ...or...
[1-9] # a 1-9 character
\d* # followed by zero or more digits
)
(?:
(?:
\. # a period
\d+ # followed by one or more digits
)?
(?:
[eE] # an e character
[+-]? # followed by an option +/-
\d+ # followed by one or more digits
)? # make exponent optional
)? # make decimal portion optional
)
scope: constant.numeric.ron
object:
- match: '[A-Za-z_][A-Za-z_0-9]*'
scope: entity.name.class.ron
- match: '\('
scope: punctuation.section.dictionary.begin.ron
push:
- meta_scope: meta.structure.entity.ron
- match: '\)'
scope: punctuation.section.dictionary.end.ron
pop: true
- match: '[a-z_][A-Za-z_0-9]*'
scope: entity.name.tag.ron
- match: '\:'
scope: punctuation.separator.dictionary.key-value.ron
- include: value
- match: ','
scope: punctuation.separator.dictionary.ron
dictionary:
- match: '\{'
scope: punctuation.section.dictionary.begin.ron
push:
- meta_scope: meta.structure.dictionary.ron
- match: '\}'
scope: punctuation.section.dictionary.end.ron
pop: true
- include: value
- match: ':'
scope: punctuation.separator.dictionary.key-value.ron
- include: value
- match: ','
scope: punctuation.separator.dictionary.ron
string:
- match: '"'
scope: punctuation.definition.string.begin.ron
push: inside-string
inside-string:
- meta_scope: string.quoted.double.ron
- match: '"'
scope: punctuation.definition.string.end.ron
pop: true
- include: string-escape
- match: $\n?
scope: invalid.illegal.unclosed-string.ron
pop: true
string-escape:
- match: |-
(?x: # turn on extended mode
\\ # a literal backslash
(?: # ...followed by...
["\\/bfnrt] # one of these characters
| # ...or...
u # a u
[0-9a-fA-F]{4} # and four hex digits
)
)
scope: constant.character.escape.ron
- match: \\.
scope: invalid.illegal.unrecognized-string-escape.ron
value:
- include: constant
- include: number
- include: string
- include: array
- include: dictionary
- include: object
- include: comments