Sure. This is for JSON. You will notice that escape chars such as \t will scope as invalid instead of normal escape chars because the regex engine will not recognize (?x: some syntax ). If you adjust those to use (?x) instead, it starts to scope proper.
[code]%YAML 1.2
http://www.sublimetext.com/docs/3/syntax.html
name: JSON
file_extensions:
- json
- sublime-settings
- sublime-menu
- sublime-keymap
- sublime-mousemap
- sublime-theme
- sublime-build
- sublime-project
- sublime-completions
- sublime-commands
scope: source.json
contexts:
main:- include: value
array: - match: ‘’
captures:
0: punctuation.definition.array.begin.json
push:- meta_scope: meta.structure.array.json
- match: ‘]’
captures:
0: punctuation.definition.array.end.json
pop: true - include: value
- match: “,”
scope: punctuation.separator.array.json - match: ‘^\s]]’
scope: invalid.illegal.expected-array-separator.json
comments:
- match: /**
captures:
0: punctuation.definition.comment.json
push:- meta_scope: comment.block.documentation.json
- match: */
pop: true
- match: /*
captures:
0: punctuation.definition.comment.json
push:- meta_scope: comment.block.json
- match: */
pop: true
- match: (//).*$\n?
scope: comment.line.double-slash.js
captures:
1: punctuation.definition.comment.json
constant: - match: \b(?:true|false|null)\b
scope: constant.language.json
keyString: - match: ‘"’
captures:
0: punctuation.definition.string.begin.json
push:- meta_scope: string.quoted.double.key.json
- match: ‘"’
captures:
0: punctuation.definition.string.end.json
pop: true - 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.json - match: \.
scope: invalid.illegal.unrecognized-string-escape.json
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
)
comment: handles integer and decimal numbers
scope: constant.numeric.json
object: - match: ‘{’
comment: a JSON object
captures:
0: punctuation.definition.dictionary.begin.json
push:- meta_scope: meta.structure.dictionary.json
- match: ‘}’
captures:
0: punctuation.definition.dictionary.end.json
pop: true - include: keyString
- include: comments
- match: “:”
captures:
0: punctuation.separator.dictionary.key-value.json
push:- meta_scope: meta.structure.dictionary.value.json
- match: ‘(,)|(?=})’
captures:
1: punctuation.separator.dictionary.pair.json
pop: true - include: value
- match: ‘^\s,]’
scope: invalid.illegal.expected-dictionary-separator.json
- match: ‘^\s}]’
scope: invalid.illegal.expected-dictionary-separator.json
string:
- match: ‘"’
captures:
0: punctuation.definition.string.begin.json
push:- meta_scope: string.quoted.double.json
- match: ‘"’
captures:
0: punctuation.definition.string.end.json
pop: true - 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.json - match: \.
scope: invalid.illegal.unrecognized-string-escape.json
value:
- include: constant
- include: number
- include: string
- include: array
- include: object
- include: comments
[/code]
- include: value