-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathsource.csv.js
More file actions
106 lines (104 loc) · 3.29 KB
/
source.csv.js
File metadata and controls
106 lines (104 loc) · 3.29 KB
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
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-dsv>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/**
* @import {Grammar} from '@wooorm/starry-night'
*/
/** @type {Grammar} */
const grammar = {
extensions: ['.csv'],
names: ['csv'],
patterns: [{include: '#main'}],
repository: {
escape: {match: '""', name: 'constant.character.escape.quote.csv'},
header: {
applyEndPatternLast: true,
begin: '\\A',
end: '(?!\\G)',
patterns: [
{begin: '\\G(?=\\s*$)', end: '\\s*(?=\\S)'},
{
applyEndPatternLast: true,
begin: '(?=\\S)',
end: '(?!\\G)',
name: 'meta.table.header.csv',
patterns: [
{
begin: '(?:^|\\G|(?<=,))(\\s*)(?=[^\\s,])',
beginCaptures: {1: {name: 'punctuation.whitespace.leading.csv'}},
end: '([ \\t\\f\\v]*)(?=,|$)',
endCaptures: {1: {name: 'punctuation.whitespace.trailing.csv'}},
name: 'meta.table.field.csv',
patterns: [
{
applyEndPatternLast: true,
begin: '\\G"',
beginCaptures: {
0: {name: 'punctuation.definition.column.begin.csv'}
},
end: '"',
endCaptures: {
0: {name: 'punctuation.definition.column.end.csv'}
},
name: 'entity.name.column.quoted.csv',
patterns: [{include: '#escape'}]
},
{
begin: '\\G(?=[^\\s,"])',
end: '(?=\\s*(?:,|$))',
name: 'entity.name.column.unquoted.csv'
}
]
},
{include: '#separator'}
]
}
]
},
main: {patterns: [{include: '#header'}, {include: '#record'}]},
record: {
applyEndPatternLast: true,
begin: '^(?=.*?,)',
end: '$',
name: 'meta.table.record.csv',
patterns: [
{
applyEndPatternLast: true,
begin: '(?:^|\\G|(?<=,))(\\s*)(?=[^\\s,])',
beginCaptures: {1: {name: 'punctuation.whitespace.leading.csv'}},
end: '([ \\t\\f\\v]*)(?=,|$)',
endCaptures: {1: {name: 'punctuation.whitespace.trailing.csv'}},
name: 'meta.table.field.csv',
patterns: [
{
applyEndPatternLast: true,
begin: '\\G"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.csv'}
},
end: '"',
endCaptures: {0: {name: 'punctuation.definition.string.end.csv'}},
name: 'string.quoted.double.csv',
patterns: [{include: '#escape'}]
},
{
begin: '\\G(?=[^\\s,"])',
end: '(?=\\s*(?:,|$))',
name: 'string.unquoted.csv'
}
]
},
{include: '#separator'}
]
},
separator: {
captures: {0: {name: 'punctuation.separator.delimiter.comma.csv'}},
match: ',',
name: 'keyword.operator.separator.csv'
}
},
scopeName: 'source.csv'
}
export default grammar