/
source.pcb.sexp.js
153 lines (152 loc) · 4.9 KB
/
source.pcb.sexp.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
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
152
153
// This is a TextMate grammar distributed by `starry-night`.
// This grammar is developed at
// <https://github.com/Alhadis/language-pcb>
// and licensed `isc`.
// See <https://github.com/wooorm/starry-night> for more info.
/** @type {import('../lib/index.js').Grammar} */
const grammar = {
extensions: ['.kicad_pcb', '.kicad_mod', '.kicad_wks'],
names: ['kicad-layout', 'pcbnew'],
patterns: [
{
begin: '(\\()\\s*(layers)(?=\\s|$|\\()',
beginCaptures: {
1: {name: 'punctuation.section.expression.begin.pcb.sexp'},
2: {name: 'storage.type.class.layers.pcb.sexp'}
},
end: '\\)',
endCaptures: {0: {name: 'punctuation.section.expression.end.pcb.sexp'}},
name: 'meta.expression.layers.pcb.sexp',
patterns: [
{
begin: '(\\()\\s*(\\d+)(?:\\s+|(?=$|\\())',
beginCaptures: {
1: {name: 'punctuation.section.expression.begin.pcb.sexp'},
2: {name: 'constant.numeric.integer.decimal.pcb.sexp'}
},
end: '\\)',
endCaptures: {
0: {name: 'punctuation.section.expression.end.pcb.sexp'}
},
name: 'meta.expression.layer.pcb.sexp',
patterns: [
{
captures: {1: {name: 'entity.name.function.pcb.sexp'}},
match: '\\G\\s*(-?(?:(?![\\s\\(\\)])[\\0-\\x7F])+)'
},
{include: '#shared'}
]
},
{include: '#shared'}
]
},
{
begin: '(\\()\\s*(comment)(?=\\s|$|\\()',
beginCaptures: {
1: {name: 'punctuation.section.expression.begin.pcb.sexp'},
2: {name: 'entity.name.function.comment.pcb.sexp'}
},
contentName: 'comment.block.expression.pcb.sexp',
end: '\\)',
endCaptures: {0: {name: 'punctuation.section.expression.end.pcb.sexp'}},
name: 'meta.expression.comment.pcb.sexp',
patterns: [
{begin: '"', end: '"|^|$', patterns: [{include: '#stringInnards'}]}
]
},
{
begin: '\\(',
beginCaptures: {
0: {name: 'punctuation.section.expression.begin.pcb.sexp'}
},
end: '\\)',
endCaptures: {0: {name: 'punctuation.section.expression.end.pcb.sexp'}},
name: 'meta.expression.pcb.sexp',
patterns: [
{
captures: {1: {name: 'storage.type.class.pcb.sexp'}},
match:
'\\G\\s*(kicad_pcb|kicad_sch|module|page_layout|fp_lib_table|sym_lib_table)(?=\\s|$|\\()'
},
{
captures: {
1: {name: 'entity.name.function.pcb.sexp'},
2: {name: 'constant.character.quote.pcb.sexp'}
},
match: '\\G\\s*(string_quote)\\s+(")(?=\\))'
},
{
captures: {1: {name: 'entity.name.function.pcb.sexp'}},
match: '\\G\\s*(-?(?:(?![\\s\\(\\)])[\\0-\\x7F])+)'
},
{include: '#shared'}
]
}
],
repository: {
shared: {patterns: [{include: '#values'}, {include: '$self'}]},
stringInnards: {
patterns: [
{match: '\\\\\\S', name: 'constant.character.escape.pcb.sexp'},
{
match: '\\G(?:[^"\\\\]|\\\\.)+(?=$)',
name: 'invalid.illegal.unclosed.string.pcb.sexp'
}
]
},
values: {
patterns: [
{
match: '[-+]?\\d*\\.\\d+',
name: 'constant.numeric.float.decimal.pcb.sexp'
},
{
match: '[-+]?\\d+(?=\\s|\\))',
name: 'constant.numeric.integer.decimal.pcb.sexp'
},
{
match: '0x[A-Fa-f0-9]+(?:_[A-Fa-f0-9]+)*',
name: 'constant.numeric.integer.hex.pcb.sexp'
},
{
match: '(?<=\\s|\\(|\\))(true|false|yes|no)(?=\\s|\\(|\\))',
name: 'constant.language.boolean.$1.pcb.sexp'
},
{
captures: {
1: {name: 'punctuation.definition.string.begin.pcb.sexp'},
2: {name: 'punctuation.definition.string.end.pcb.sexp'}
},
match: '(")(")',
name: 'string.quoted.double.empty.pcb.sexp'
},
{
begin: '"',
beginCaptures: {
0: {name: 'punctuation.definition.string.begin.pcb.sexp'}
},
end: '"|^|$',
endCaptures: {
0: {name: 'punctuation.definition.string.end.pcb.sexp'}
},
name: 'string.quoted.double.pcb.sexp',
patterns: [{include: '#stringInnards'}]
},
{
captures: {
1: {
name: 'punctuation.section.embedded.bracket.curly.begin.pcb.sexp'
},
2: {name: 'string.interpolated.embedded.pcb.sexp'},
3: {name: 'punctuation.section.embedded.bracket.curly.end.pcb.sexp'}
},
match: '(\\${)([^\\s}\\(\\)]+)(})',
name: 'meta.embedded.source.pcb.sexp'
},
{match: '[^\\s\\(\\)]+', name: 'variable.parameter.identifier.pcb.sexp'}
]
}
},
scopeName: 'source.pcb.sexp'
}
export default grammar