/
source.pcb.board.js
180 lines (179 loc) · 5.78 KB
/
source.pcb.board.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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// 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 = {
dependencies: ['source.pcb.sexp'],
extensions: [],
names: ['kicad-legacy-layout'],
patterns: [
{
begin: '\\A(?=<\\?xml\\s+version="[\\d.]+"\\s)',
contentName: 'source.eagle.pcb.board',
end: '(?=A)B',
patterns: [{include: 'text.xml'}]
},
{include: '#main'}
],
repository: {
comment: {
begin: '#',
beginCaptures: {0: {name: 'punctuation.definition.comment.pcb.board'}},
end: '$',
name: 'comment.line.number-sign.pcb.board'
},
fields: {
patterns: [
{
captures: {
1: {name: 'entity.name.var.pcb.board'},
2: {patterns: [{include: 'source.pcb.sexp'}]}
},
match: '^\\s*(PcbPlotParams)\\s+(.+)$'
},
{
captures: {
1: {name: 'entity.name.var.pcb.board'},
2: {
name: 'punctuation.section.begin.brace.bracket.square.pcb.board'
},
3: {name: 'constant.numeric.integer.decimal.pcb.board'},
4: {name: 'punctuation.section.end.brace.bracket.square.pcb.board'}
},
match: '^\\s*(Layer)(\\[)([0-9]+)(\\])(?=\\s)'
},
{
captures: {
1: {name: 'entity.name.var.pcb.board'},
2: {name: 'string.unquoted.pcb.board'}
},
match: '^\\s*(Cd)\\s+(\\S.*)\\s*$'
},
{
captures: {1: {name: 'entity.name.var.pcb.board'}},
match: '^\\s*([^$\\s]\\S*)'
},
{
captures: {
1: {name: 'punctuation.definition.string.begin.pcb.board'},
2: {
patterns: [
{match: '\\\\.', name: 'constant.character.escape.pcb.board'}
]
},
3: {name: 'punctuation.definition.string.end.pcb.board'}
},
match: '(")((?:[^"\\\\]|\\\\.)*)("|(?=$))',
name: 'string.quoted.double.pcb.board'
},
{
match: '[-+]?\\d*\\.\\d+',
name: 'constant.numeric.float.decimal.pcb.board'
},
{include: '#integer'},
{
captures: {1: {name: 'punctuation.definition.constant.pcb.board'}},
match: '[-+]?(?:(/)?[A-F0-9]+|0x[A-Fa-f0-9]+)(?=\\s|$)',
name: 'constant.numeric.integer.hex.pcb.board'
},
{
match: '(?<=\\s|^)[A-Z]+(?=\\s|$)',
name: 'constant.language.other.pcb.board'
},
{match: '[^$\\s]\\S*', name: 'variable.parameter.pcb.board'},
{include: '$self'}
]
},
header: {
captures: {
1: {name: 'storage.type.class.pcb.board'},
2: {name: 'entity.name.var.pcb.board'},
3: {name: 'constant.numeric.decimal.pcb.board'},
4: {name: 'entity.name.var.pcb.board'},
5: {name: 'constant.numeric.date.timestamp.pcb.board'}
},
match:
'^\\s*(PCBNEW-BOARD)\\s+(Version)\\s+([\\d.]+)\\s+(date)\\s+(\\S.*)\\s*$',
name: 'meta.header.pcb.board'
},
integer: {
match: '[-+]?\\d+(?=\\s|$)',
name: 'constant.numeric.integer.decimal.pcb.board'
},
main: {
patterns: [
{include: '#header'},
{include: '#comment'},
{include: '#sections'}
]
},
sections: {
patterns: [
{
begin: '^\\s*((\\$)MODULE)\\s+(\\S+)',
beginCaptures: {
1: {name: 'keyword.control.section.module.pcb.board'},
2: {name: 'punctuation.section.begin.pcb.board'},
3: {name: 'entity.name.type.class.pcb.board'}
},
end: '^\\s*((\\$)EndMODULE)\\s+(\\3)(?=\\s|$)',
endCaptures: {
1: {name: 'keyword.control.section.module.pcb.board'},
2: {name: 'punctuation.section.end.pcb.board'},
3: {name: 'entity.name.type.class.pcb.board'}
},
name: 'meta.section.module.pcb.board',
patterns: [
{
captures: {
1: {patterns: [{include: '#fields'}]},
2: {name: 'keyword.operator.position-type.pcb.board'}
},
match: '^\\s*(Po\\s+.+\\s+)([~F][~P])\\s*$'
},
{include: '#fields'}
]
},
{
begin: '^\\s*((\\$)POLYSCORNERS)\\s*$',
beginCaptures: {
1: {name: 'keyword.control.section.pcb.board'},
2: {name: 'punctuation.section.begin.pcb.board'}
},
end: '^\\s*((\\$)endPOLYSCORNERS)(?=\\s|$)',
endCaptures: {
1: {name: 'keyword.control.section.pcb.board'},
2: {name: 'punctuation.section.end.pcb.board'}
},
name: 'meta.section.polyscorners.pcb.board',
patterns: [{include: '#integer'}]
},
{
begin: '^\\s*((\\$)([A-Z][A-Z0-9_]*+))(?=\\s|$)',
beginCaptures: {
1: {name: 'keyword.control.section.pcb.board'},
2: {name: 'punctuation.section.begin.pcb.board'}
},
end: '^\\s*((\\$)[Ee]nd\\3)(?=\\s|$)',
endCaptures: {
1: {name: 'keyword.control.section.pcb.board'},
2: {name: 'punctuation.section.end.pcb.board'}
},
name: 'meta.section.${3:/downcase}.pcb.board',
patterns: [{include: '#fields'}]
},
{
captures: {
1: {name: 'keyword.control.eof.pcb.board'},
2: {name: 'punctuation.section.end.pcb.board'}
},
match: '^\\s*((\\$)EndBOARD)(?=\\s|$)'
}
]
}
},
scopeName: 'source.pcb.board'
}
export default grammar