forked from AntonNguyen/JavaScriptNext.tmLanguage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JSON (JavaScriptNext).YAML-tmLanguage
151 lines (143 loc) · 4.42 KB
/
JSON (JavaScriptNext).YAML-tmLanguage
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# [PackageDev] target_format: plist, ext: tmLanguage
name: JSON (Javascript Next)
scopeName: source.json
fileTypes: [json, sublime-settings, sublime-menu, sublime-keymap, sublime-mousemap,
sublime-theme, sublime-build, sublime-project, sublime-completions]
uuid: 8f97457b-516e-48ce-83c7-08ae12fb327a
foldingStartMarker: >-
(?x) # turn on extended mode
^ # a line beginning with
\s* # some optional space
[{\[] # the start of an object or array
(?! # but not followed by
.* # whatever
[}\]] # and the close of an object or array
,? # an optional comma
\s* # some optional space
$ # at the end of the line
)
| # ...or...
[{\[] # the start of an object or array
\s* # some optional space
$ # at the end of the line
foldingStopMarker: >-
(?x) # turn on extended mode
^ # a line beginning with
\s* # some optional space
[}\]] # and the close of an object or array
keyEquivalent: ^~J
patterns:
- include: '#value'
repository:
array:
name: meta.structure.array.json
begin: \[
beginCaptures:
'0': {name: punctuation.definition.array.begin.json}
end: \]
endCaptures:
'0': {name: punctuation.definition.array.end.json}
patterns:
- include: '#value'
- name: punctuation.separator.array.json
match: ','
- name: invalid.illegal.expected-array-separator.json
match: '[^\s\]]'
comments:
patterns:
- name: comment.block.documentation.json
begin: /\*\*
end: \*/
captures:
'0': {name: punctuation.definition.comment.json}
- name: comment.block.json
begin: /\*
end: \*/
captures:
'0': {name: punctuation.definition.comment.json}
- name: comment.line.double-slash.js
match: (//).*$\n?
captures:
'1': {name: punctuation.definition.comment.json}
constant:
name: constant.language.json
match: \b(?:true|false|null)\b
# handles integer and decimal numbers
number:
name: constant.numeric.json
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
# a JSON object
object:
name: meta.structure.dictionary.json
begin: \{
beginCaptures:
'0': {name: punctuation.definition.dictionary.begin.json}
end: \}
endCaptures:
'0': {name: punctuation.definition.dictionary.end.json}
patterns:
- comment: the JSON object key
include: '#string'
- include: '#comments'
- name: meta.structure.dictionary.value.json
begin: ':'
beginCaptures:
'0': {name: punctuation.separator.dictionary.key-value.json}
end: (,)|(?=\})
endCaptures:
'1': {name: punctuation.separator.dictionary.pair.json}
patterns:
- comment: the JSON object value
include: '#value'
- name: invalid.illegal.expected-dictionary-separator.json
match: '[^\s,]'
- name: invalid.illegal.expected-dictionary-separator.json
match: '[^\s\}]'
string:
name: string.quoted.double.json
begin: '"'
beginCaptures:
'0': {name: punctuation.definition.string.begin.json}
end: '"'
endCaptures:
'0': {name: punctuation.definition.string.end.json}
patterns:
- name: constant.character.escape.json
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
- name: invalid.illegal.unrecognized-string-escape.json
match: \\.
# the 'value' diagram at http://json.org
value:
patterns:
- include: '#constant'
- include: '#number'
- include: '#string'
- include: '#array'
- include: '#object'
- include: '#comments'