-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.hocon.js
112 lines (110 loc) · 3.2 KB
/
source.hocon.js
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/jacobwgillespie/language-hocon>
// and licensed `mit`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.hocon'],
names: ['hocon'],
patterns: [
{include: '#duration-long'},
{include: '#bytesize-long'},
{include: '#duration-short'},
{include: '#bytesize-short'},
{include: '#variables'},
{include: '#constant'},
{include: '#mstring'},
{include: '#string'},
{include: '#comments'},
{include: '#keywords'},
{include: '#number'},
{include: '#ustring'},
{
captures: {
1: {name: 'entity.name.tag.hocon'},
2: {name: 'punctuation.separator.key-value.hocon'}
},
match: '(?:[ \t]*([\\w-]+)\\s*?({|=|:))'
}
],
repository: {
'bytesize-long': {
match:
'\\b\\d+((kilo|mega|giga|tera|peta|exa|zetta|yotta|kibi|mebi|gibi|tebi|pebi|exbi|zebo|yobi)?byte[s]?)\\b',
name: 'constant.numeric.byte.long.hocon'
},
'bytesize-short': {
match:
'\\b\\d+(([kMGTPEZY]B)|([KMGTPEZY]B?)|([KMGTPEZY]iB?)|([kmgtpezybB]))\\b',
name: 'constant.numeric.byte.short.hocon'
},
comments: {
patterns: [
{
captures: {1: {name: 'punctuation.definition.comment.hocon'}},
match: '(//).*$\\n?',
name: 'comment.line.double-slash.hocon'
},
{
captures: {1: {name: 'punctuation.definition.comment.hocon'}},
match: '(#).*$\\n?',
name: 'comment.line.pound.hocon'
}
]
},
constant: {
captures: {1: {name: 'constant.language.hocon'}},
match: '[^-]\\b((?:true|false|null|on|off|yes|no))\\b[^-]'
},
'duration-long': {
match:
'\\b\\d+(day|hour|minute|millisecond|microsecond|nanosecond|second)[s]?\\b',
name: 'constant.numeric.duration.long.hocon'
},
'duration-short': {
match: '\\b(\\d+)(d|h|ns|ms|us|s)\\b',
name: 'constant.numeric.duration.short.hocon'
},
keywords: {
patterns: [
{
match: '\\b(include|url|file|classpath)\\b',
name: 'keyword.other.source.hocon'
}
]
},
mstring: {begin: '"""', end: '"""', name: 'string.quoted.triple.hocon'},
number: {
match: '(\\b\\-?\\d+(\\.\\d+)?([eE]\\d+)?\\b)',
name: 'constant.numeric.zzz.simple.numbers.hocon'
},
string: {
begin: '"',
end: '"',
name: 'string.quoted.double.hocon',
patterns: [
{
match: '(\\\\(?:["\\\\/bfnrt]|u[0-9a-fA-F]{4}))',
name: 'constant.character.escape.hocon'
},
{
match: '\\\\.',
name: 'invalid.illegal.unrecognized-string-escape.hocon'
}
]
},
ustring: {
captures: {1: {name: 'entity.name.tag.hocon'}},
match:
'([^:=\\{\\}\\[\\]\\s,][^0-9:=\\{\\}\\[\\],][^=:\\{\\}\\[\\]\\s,]*)',
name: 'string.other.zzz.unquoted.hocon'
},
variables: {match: '\\$\\{[^\\}]*\\}', name: 'storage.type.source.hocon'}
},
scopeName: 'source.hocon'
}
export default grammar