-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
source.sfv.js
97 lines (95 loc) · 2.99 KB
/
source.sfv.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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-etc>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.sfv'],
names: ['simple-file-verification', 'sfv'],
patterns: [
{
begin: '\\A(?=; Generated by RHash v\\d)',
end: '(?=A)B',
name: 'meta.rhash-output.sfv',
patterns: [{include: '#rhash'}, {include: '#main'}]
},
{
begin: '^(?=[a-fA-F0-9]+ \\*pocorgtfo\\d{2}\\.pdf\\s*$)',
end: '(?=A)B',
name: 'text.checksums',
patterns: [{include: 'text.checksums'}]
},
{include: '#main'}
],
repository: {
checksum: {
captures: {
1: {name: 'string.quoted.double.filename.sfv'},
2: {name: 'punctuation.definition.string.begin.sfv'},
3: {name: 'punctuation.definition.string.end.sfv'},
4: {name: 'string.unquoted.filename.sfv'},
5: {name: 'constant.numeric.integer.int.hexadecimal.hex.crc32.sfv'}
},
match: '^\\s*(?:((")[^"]*("))|(\\S.*?))\\s+([a-fA-F0-9]{8})(?=\\s*$)',
name: 'meta.crc32.checksum.sfv'
},
comment: {
patterns: [
{
begin: '^\\s*(;)((!)SFV_COMMENT_START)[ \\t]*$',
beginCaptures: {
1: {name: 'punctuation.definition.comment.sfv'},
2: {name: 'keyword.control.comment.begin.sfv'},
3: {name: 'punctuation.definition.keyword.sfv'}
},
end: '^\\s*(;)((!)SFV_COMMENT_END)[ \\t]*$',
endCaptures: {
1: {name: 'punctuation.definition.comment.sfv'},
2: {name: 'keyword.control.comment.end.sfv'},
3: {name: 'punctuation.definition.keyword.sfv'}
},
name: 'comment.block.sfv'
},
{
begin: '^\\s*(;)',
beginCaptures: {1: {name: 'punctuation.definition.comment.sfv'}},
end: '$',
name: 'comment.line.semicolon.sfv'
}
]
},
main: {
patterns: [
{include: '#comment'},
{include: '#checksum'},
{include: '#rhash'}
]
},
rhash: {
captures: {
1: {name: 'string.unquoted.filename.sfv'},
2: {
patterns: [
{
match: '\\b[a-zA-Z2-7]+\\b',
name: 'constant.numeric.base32.rfc4648.sfv'
},
{
match: '\\b[a-fA-F0-9]+\\b',
name: 'constant.numeric.integer.int.hexadecimal.hex.sfv'
}
]
}
},
match:
'(?x) ^ \\s* (\\S.*?(?<=\\S)) ((?: \\s+ (?: [a-fA-F0-9]{8} | [a-fA-F0-9]{32} | [a-fA-F0-9]{40} | [a-fA-F0-9]{48} | [a-fA-F0-9]{56} | [a-fA-F0-9]{64} | [a-fA-F0-9]{96} | [a-fA-F0-9]{128} | [a-zA-Z2-7]{32} | [a-zA-Z2-7]{39} ) )+) (?=\\s*$)',
name: 'meta.checksum-record.sfv'
}
},
scopeName: 'source.sfv'
}
export default grammar