1%YAML 1.2
2---
3name: RON
4file_extensions:
5  - ron
6scope: source.ron
7contexts:
8  main:
9    - include: value
10  array:
11    - match: '\['
12      scope: punctuation.section.array.begin.ron
13      push:
14        - meta_scope: meta.structure.array.ron
15        - match: '\]'
16          scope: punctuation.section.array.end.ron
17          pop: true
18        - include: value
19        - match: ','
20          scope: punctuation.separator.array.ron
21        - match: '[^\s\]]'
22          scope: invalid.illegal.expected-array-separator.ron
23  comments:
24    - match: /\*\*(?!/)
25      scope: punctuation.definition.comment.ron
26      push:
27        - meta_scope: comment.block.documentation.ron
28        - match: \*/
29          pop: true
30    - match: /\*
31      scope: punctuation.definition.comment.ron
32      push:
33        - meta_scope: comment.block.ron
34        - match: \*/
35          pop: true
36    - match: (//).*$\n?
37      scope: comment.line.double-slash.js
38      captures:
39        1: punctuation.definition.comment.ron
40  constant:
41    - match: \b(true|false)\b
42      scope: constant.language.ron
43  number:
44    # handles integer and decimal numbers
45    - match: |-
46        (?x:         # turn on extended mode
47          -?         # an optional minus
48          (?:
49            0        # a zero
50            |        # ...or...
51            [1-9]    # a 1-9 character
52            \d*      # followed by zero or more digits
53          )
54          (?:
55            (?:
56              \.     # a period
57              \d+    # followed by one or more digits
58            )?
59            (?:
60              [eE]   # an e character
61              [+-]?  # followed by an option +/-
62              \d+    # followed by one or more digits
63            )?       # make exponent optional
64          )?         # make decimal portion optional
65        )
66      scope: constant.numeric.ron
67  object:
68    - match: '[A-Za-z_][A-Za-z_0-9]*'
69      scope: entity.name.class.ron
70    - match: '\('
71      scope: punctuation.section.dictionary.begin.ron
72      push:
73        - meta_scope: meta.structure.entity.ron
74        - match: '\)'
75          scope: punctuation.section.dictionary.end.ron
76          pop: true
77        - match: '[a-z_][A-Za-z_0-9]*'
78          scope: entity.name.tag.ron
79        - match: '\:'
80          scope: punctuation.separator.dictionary.key-value.ron
81        - include: value
82        - match: ','
83          scope: punctuation.separator.dictionary.ron
84  dictionary:
85    - match: '\{'
86      scope: punctuation.section.dictionary.begin.ron
87      push:
88        - meta_scope: meta.structure.dictionary.ron
89        - match: '\}'
90          scope: punctuation.section.dictionary.end.ron
91          pop: true
92        - include: value
93        - match: ':'
94          scope: punctuation.separator.dictionary.key-value.ron
95        - include: value
96        - match: ','
97          scope: punctuation.separator.dictionary.ron
98  string:
99    - match: '"'
100      scope: punctuation.definition.string.begin.ron
101      push: inside-string
102  inside-string:
103    - meta_scope: string.quoted.double.ron
104    - match: '"'
105      scope: punctuation.definition.string.end.ron
106      pop: true
107    - include: string-escape
108    - match: $\n?
109      scope: invalid.illegal.unclosed-string.ron
110      pop: true
111  string-escape:
112    - match: |-
113        (?x:                # turn on extended mode
114          \\                # a literal backslash
115          (?:               # ...followed by...
116            ["\\/bfnrt]     # one of these characters
117            |               # ...or...
118            u               # a u
119            [0-9a-fA-F]{4}  # and four hex digits
120          )
121        )
122      scope: constant.character.escape.ron
123    - match: \\.
124      scope: invalid.illegal.unrecognized-string-escape.ron
125  value:
126    - include: constant
127    - include: number
128    - include: string
129    - include: array
130    - include: dictionary
131    - include: object
132    - include: comments
133