|
| 1 | +// Reference: a5huynh/vscode-ron (MIT) - https://github.com/a5huynh/vscode-ron/blob/master/syntaxes/ron.tmGrammar.json |
| 2 | +export default { |
| 3 | + "scopeName": "source.ron", |
| 4 | + "patterns": [ |
| 5 | + { |
| 6 | + "include": "#expression" |
| 7 | + } |
| 8 | + ], |
| 9 | + "repository": { |
| 10 | + "expression": { |
| 11 | + "patterns": [ |
| 12 | + { |
| 13 | + "include": "#array" |
| 14 | + }, |
| 15 | + { |
| 16 | + "include": "#block_comment" |
| 17 | + }, |
| 18 | + { |
| 19 | + "include": "#constant" |
| 20 | + }, |
| 21 | + { |
| 22 | + "include": "#dictionary" |
| 23 | + }, |
| 24 | + { |
| 25 | + "include": "#line_comment" |
| 26 | + }, |
| 27 | + { |
| 28 | + "include": "#number" |
| 29 | + }, |
| 30 | + { |
| 31 | + "include": "#raw_string" |
| 32 | + }, |
| 33 | + { |
| 34 | + "include": "#struct-field" |
| 35 | + }, |
| 36 | + { |
| 37 | + "include": "#struct-name" |
| 38 | + }, |
| 39 | + { |
| 40 | + "include": "#object" |
| 41 | + }, |
| 42 | + { |
| 43 | + "include": "#string" |
| 44 | + }, |
| 45 | + { |
| 46 | + "include": "#character" |
| 47 | + }, |
| 48 | + { |
| 49 | + "include": "#enum-variant" |
| 50 | + } |
| 51 | + ] |
| 52 | + }, |
| 53 | + "array": { |
| 54 | + "begin": "\\[", |
| 55 | + "end": "\\]", |
| 56 | + "beginCaptures": { |
| 57 | + "0": { |
| 58 | + "name": "punctuation.section.array.begin.ron" |
| 59 | + } |
| 60 | + }, |
| 61 | + "endCaptures": { |
| 62 | + "0": { |
| 63 | + "name": "punctuation.section.array.end.ron" |
| 64 | + } |
| 65 | + }, |
| 66 | + "patterns": [ |
| 67 | + { |
| 68 | + "include": "#value" |
| 69 | + }, |
| 70 | + { |
| 71 | + "include": "#struct-name" |
| 72 | + }, |
| 73 | + { |
| 74 | + "meta_scope": "meta.structure.array.ron" |
| 75 | + } |
| 76 | + ] |
| 77 | + }, |
| 78 | + "block_comment": { |
| 79 | + "name": "comment.block.ron", |
| 80 | + "begin": "/\\*", |
| 81 | + "end": "\\*/", |
| 82 | + "patterns": [ |
| 83 | + { |
| 84 | + "include": "#block_comment" |
| 85 | + } |
| 86 | + ] |
| 87 | + }, |
| 88 | + "constant": { |
| 89 | + "match": "\\b(true|false)\\b", |
| 90 | + "name": "constant.language.ron" |
| 91 | + }, |
| 92 | + "dictionary": { |
| 93 | + "begin": "\\{", |
| 94 | + "end": "\\}", |
| 95 | + "beginCaptures": { |
| 96 | + "0": { |
| 97 | + "name": "punctuation.section.dictionary.begin.ron" |
| 98 | + } |
| 99 | + }, |
| 100 | + "endCaptures": { |
| 101 | + "0": { |
| 102 | + "name": "punctuation.section.dictionary.end.ron" |
| 103 | + } |
| 104 | + }, |
| 105 | + "patterns": [ |
| 106 | + { |
| 107 | + "include": "#value" |
| 108 | + }, |
| 109 | + { |
| 110 | + "include": "#struct-name" |
| 111 | + }, |
| 112 | + { |
| 113 | + "include": "#object" |
| 114 | + }, |
| 115 | + { |
| 116 | + "include": "#enum-variant" |
| 117 | + }, |
| 118 | + { |
| 119 | + "match": ",", |
| 120 | + "name": "punctuation.separator.dictionary.ron" |
| 121 | + }, |
| 122 | + { |
| 123 | + "match": ":", |
| 124 | + "name": "punctuation.separator.dictionary.key-value.ron" |
| 125 | + } |
| 126 | + ] |
| 127 | + }, |
| 128 | + "line_comment": { |
| 129 | + "name": "comment.line.double-slash.ron", |
| 130 | + "begin": "//", |
| 131 | + "end": "$" |
| 132 | + }, |
| 133 | + "struct-field": { |
| 134 | + "comment": "Struct field key: identifier followed by :", |
| 135 | + "match": "([a-z_][A-Za-z_0-9]*)\\s*(:)", |
| 136 | + "captures": { |
| 137 | + "1": { |
| 138 | + "name": "variable.other.member.ron" |
| 139 | + }, |
| 140 | + "2": { |
| 141 | + "name": "punctuation.separator.key-value.ron" |
| 142 | + } |
| 143 | + } |
| 144 | + }, |
| 145 | + "struct-name": { |
| 146 | + "comment": "Struct/type name: capitalized identifier typically followed by ( or {", |
| 147 | + "match": "[A-Z][A-Za-z_0-9]*", |
| 148 | + "name": "entity.name.type.ron" |
| 149 | + }, |
| 150 | + "enum-variant": { |
| 151 | + "comment": "Enum variant or field name (lowercase identifier not followed by :)", |
| 152 | + "match": "[a-z_][A-Za-z_0-9]*", |
| 153 | + "name": "entity.name.tag.ron" |
| 154 | + }, |
| 155 | + "object": { |
| 156 | + "begin": "\\(", |
| 157 | + "end": "\\)", |
| 158 | + "beginCaptures": { |
| 159 | + "0": { |
| 160 | + "name": "punctuation.section.parens.begin.ron" |
| 161 | + } |
| 162 | + }, |
| 163 | + "endCaptures": { |
| 164 | + "0": { |
| 165 | + "name": "punctuation.section.parens.end.ron" |
| 166 | + } |
| 167 | + }, |
| 168 | + "patterns": [ |
| 169 | + { |
| 170 | + "include": "#value" |
| 171 | + }, |
| 172 | + { |
| 173 | + "include": "#dictionary" |
| 174 | + }, |
| 175 | + { |
| 176 | + "include": "#struct-field" |
| 177 | + }, |
| 178 | + { |
| 179 | + "include": "#struct-name" |
| 180 | + }, |
| 181 | + { |
| 182 | + "include": "#enum-variant" |
| 183 | + }, |
| 184 | + { |
| 185 | + "include": "#object" |
| 186 | + } |
| 187 | + ] |
| 188 | + }, |
| 189 | + "number": { |
| 190 | + "patterns": [ |
| 191 | + { |
| 192 | + "comment": "Hexadecimal integer", |
| 193 | + "match": "-?\\b0x[0-9a-fA-F_]+\\b", |
| 194 | + "name": "constant.numeric.hex.ron" |
| 195 | + }, |
| 196 | + { |
| 197 | + "comment": "Binary integer", |
| 198 | + "match": "-?\\b0b[01_]+\\b", |
| 199 | + "name": "constant.numeric.binary.ron" |
| 200 | + }, |
| 201 | + { |
| 202 | + "comment": "Octal integer", |
| 203 | + "match": "-?\\b0o[0-7_]+\\b", |
| 204 | + "name": "constant.numeric.octal.ron" |
| 205 | + }, |
| 206 | + { |
| 207 | + "comment": "Float or decimal integer", |
| 208 | + "match": "-?\\b[0-9][0-9_]*(?:\\.[0-9][0-9_]*)?(?:[eE][+-]?[0-9_]+)?\\b", |
| 209 | + "name": "constant.numeric.ron" |
| 210 | + } |
| 211 | + ] |
| 212 | + }, |
| 213 | + "raw_string": { |
| 214 | + "patterns": [ |
| 215 | + { |
| 216 | + "comment": "Raw string r#####\"...\"#####", |
| 217 | + "begin": "r#{5}\"", |
| 218 | + "end": "\"#{5}", |
| 219 | + "name": "string.quoted.other.raw.ron" |
| 220 | + }, |
| 221 | + { |
| 222 | + "comment": "Raw string r####\"...\"####", |
| 223 | + "begin": "r#{4}\"", |
| 224 | + "end": "\"#{4}", |
| 225 | + "name": "string.quoted.other.raw.ron" |
| 226 | + }, |
| 227 | + { |
| 228 | + "comment": "Raw string r###\"...\"###", |
| 229 | + "begin": "r#{3}\"", |
| 230 | + "end": "\"#{3}", |
| 231 | + "name": "string.quoted.other.raw.ron" |
| 232 | + }, |
| 233 | + { |
| 234 | + "comment": "Raw string r##\"...\"##", |
| 235 | + "begin": "r#{2}\"", |
| 236 | + "end": "\"#{2}", |
| 237 | + "name": "string.quoted.other.raw.ron" |
| 238 | + }, |
| 239 | + { |
| 240 | + "comment": "Raw string r#\"...\"#", |
| 241 | + "begin": "r#\"", |
| 242 | + "end": "\"#", |
| 243 | + "name": "string.quoted.other.raw.ron" |
| 244 | + }, |
| 245 | + { |
| 246 | + "comment": "Raw string r\"...\"", |
| 247 | + "begin": "r\"", |
| 248 | + "end": "\"", |
| 249 | + "name": "string.quoted.other.raw.ron" |
| 250 | + } |
| 251 | + ] |
| 252 | + }, |
| 253 | + "string": { |
| 254 | + "begin": "(b?)(\")", |
| 255 | + "end": "\"", |
| 256 | + "name": "string.quoted.double", |
| 257 | + "patterns": [ |
| 258 | + { |
| 259 | + "include": "#escapes" |
| 260 | + } |
| 261 | + ] |
| 262 | + }, |
| 263 | + "character": { |
| 264 | + "begin": "'", |
| 265 | + "end": "'", |
| 266 | + "contentName": "constant.character.ron", |
| 267 | + "name": "string.quoted.single", |
| 268 | + "patterns": [ |
| 269 | + { |
| 270 | + "include": "#escapes" |
| 271 | + } |
| 272 | + ] |
| 273 | + }, |
| 274 | + "value": { |
| 275 | + "patterns": [ |
| 276 | + { |
| 277 | + "include": "#array" |
| 278 | + }, |
| 279 | + { |
| 280 | + "include": "#block_comment" |
| 281 | + }, |
| 282 | + { |
| 283 | + "include": "#constant" |
| 284 | + }, |
| 285 | + { |
| 286 | + "include": "#dictionary" |
| 287 | + }, |
| 288 | + { |
| 289 | + "include": "#line_comment" |
| 290 | + }, |
| 291 | + { |
| 292 | + "include": "#number" |
| 293 | + }, |
| 294 | + { |
| 295 | + "include": "#object" |
| 296 | + }, |
| 297 | + { |
| 298 | + "include": "#raw_string" |
| 299 | + }, |
| 300 | + { |
| 301 | + "include": "#string" |
| 302 | + }, |
| 303 | + { |
| 304 | + "include": "#character" |
| 305 | + } |
| 306 | + ] |
| 307 | + }, |
| 308 | + "escapes": { |
| 309 | + "comment": "escapes: ASCII, byte, Unicode, quote, regex", |
| 310 | + "name": "constant.character.escape.ron", |
| 311 | + "match": "(\\\\)(?:(?:(x[0-7][0-7a-fA-F])|(u(\\{)[\\da-fA-F]{4,6}(\\}))|.))", |
| 312 | + "captures": { |
| 313 | + "1": { |
| 314 | + "name": "constant.character.escape.backslash.ron" |
| 315 | + }, |
| 316 | + "2": { |
| 317 | + "name": "constant.character.escape.bit.ron" |
| 318 | + }, |
| 319 | + "3": { |
| 320 | + "name": "constant.character.escape.unicode.ron" |
| 321 | + }, |
| 322 | + "4": { |
| 323 | + "name": "constant.character.escape.unicode.punctuation.ron" |
| 324 | + }, |
| 325 | + "5": { |
| 326 | + "name": "constant.character.escape.unicode.punctuation.ron" |
| 327 | + } |
| 328 | + } |
| 329 | + } |
| 330 | + } |
| 331 | +}; |
0 commit comments