/
source.ltspice.symbol.js
185 lines (184 loc) · 5.58 KB
/
source.ltspice.symbol.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
181
182
183
184
185
// 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: [],
names: ['ltspice-symbol'],
patterns: [{include: '#main'}],
repository: {
attr: {
begin: '^\\s*(SYMATTR)(?=\\s|$)',
beginCaptures: {1: {name: 'storage.type.var.attribute.ltspice.symbol'}},
end: '$',
name: 'meta.attribute.ltspice.symbol',
patterns: [
{
captures: {1: {name: 'entity.attribute.name.ltspice.symbol'}},
match: '\\G\\s+(\\S+)'
},
{match: '.+', name: 'string.unquoted.attribute.value.ltspice.symbol'}
]
},
main: {
patterns: [
{include: '#version'},
{include: '#symbolType'},
{include: '#shapes'},
{include: '#window'},
{include: '#pinAttr'},
{include: '#pin'},
{include: '#attr'},
{include: '#text'}
]
},
number: {
patterns: [
{
match: '[-+]?[0-9]+\\.[0-9]+',
name: 'constant.numeric.float.real.decimal.ltspice.symbol'
},
{
match: '[-+]?[0-9]+',
name: 'constant.numeric.integer.int.decimal.ltspice.symbol'
}
]
},
pin: {
begin: '^\\s*(PIN)(?=\\s|$)',
beginCaptures: {1: {name: 'keyword.control.pin.ltspice.symbol'}},
end: '$',
name: 'meta.pin.ltspice.symbol',
patterns: [
{include: '#number'},
{match: '\\w+', name: 'constant.language.pin-alignment.ltspice.symbol'}
]
},
pinAttr: {
begin: '^\\s*(PINATTR)(?=\\s|$)',
beginCaptures: {1: {name: 'storage.type.var.attribute.ltspice.symbol'}},
end: '$',
name: 'meta.pin.attribute.ltspice.symbol',
patterns: [
{
captures: {
1: {name: 'entity.pin.attribute.name.ltspice.symbol'},
2: {patterns: [{include: '#number'}]}
},
match: '\\G\\s+(SpiceOrder)\\s+(\\d+)',
patterns: [{include: '#number'}]
},
{
captures: {1: {name: 'entity.attribute.name.ltspice.symbol'}},
match: '\\G\\s+(\\S+)'
},
{
captures: {
1: {
name: 'punctuation.definition.brace.square.bracket.begin.ltspice.symbol'
},
2: {
patterns: [
{
match: ':',
name: 'punctuation.delimiter.separator.colon.key-value.ltspice.symbol'
},
{include: '#number'}
]
},
3: {
name: 'punctuation.definition.brace.square.bracket.begin.ltspice.symbol'
}
},
match: '(\\[)([^\\]]+)(\\])'
},
{
match: '[^\\s\\[]+',
name: 'string.unquoted.attribute.value.ltspice.symbol'
}
]
},
shapes: {
begin: '^\\s*(ARC|LINE|CIRCLE|RECTANGLE)(?=\\s|$)',
beginCaptures: {1: {name: 'storage.type.var.shape.ltspice.symbol'}},
end: '$',
name: 'meta.shape.${1:/downcase}.ltspice.symbol',
patterns: [
{
match: '\\G\\s*(?!\\d)(\\w+)',
name: 'variable.parameter.type.ltspice.symbol'
},
{include: '#number'}
]
},
symbolType: {
begin: '^\\s*(SymbolType)(?=\\s|$)',
beginCaptures: {1: {name: 'keyword.control.symbol-type.ltspice.symbol'}},
end: '$',
name: 'meta.symbol-type.ltspice.symbol',
patterns: [
{
match: '[A-Za-z_$]+',
name: 'constant.language.symbol-type.ltspice.symbol'
}
]
},
text: {
begin: '^\\s*(TEXT)(?=\\s|$)',
beginCaptures: {1: {name: 'storage.type.var.text.ltspice.symbol'}},
end: '$',
name: 'meta.text.ltspice.symbol',
patterns: [
{
captures: {
1: {
name: 'meta.vector.x-axis.ltspice.symbol',
patterns: [{include: '#number'}]
},
2: {
name: 'meta.vector.y-axis.ltspice.symbol',
patterns: [{include: '#number'}]
},
3: {name: 'constant.language.text-alignment.ltspice.symbol'},
4: {
name: 'meta.text-size.ltspice.symbol',
patterns: [{include: '#number'}]
}
},
match:
'(?x) \\G\n\\s+ ([-\\d.]+) # X\n\\s+ ([-\\d.]+) # Y\n\\s+ ([-\\w$]+) # Alignment\n\\s+ ([-\\d.]+) # Text-size',
name: 'meta.function-call.arguments.ltspice.symbol'
},
{match: '.+', name: 'string.unquoted.text.ltspice.symbol'}
]
},
version: {
begin: '^\\s*(Version)(?=\\s|$)',
beginCaptures: {1: {name: 'keyword.control.file-version.ltspice.symbol'}},
end: '$',
name: 'meta.version.ltspice.symbol',
patterns: [{include: '#number'}]
},
window: {
begin: '^\\s*(WINDOW)(?=\\s|$)',
beginCaptures: {1: {name: 'keyword.control.window.ltspice.symbol'}},
end: '$',
name: 'meta.window.ltspice.symbol',
patterns: [
{
captures: {
1: {patterns: [{include: '#number'}]},
2: {name: 'constant.language.window-alignment.ltspice.symbol'},
3: {patterns: [{include: '#number'}]}
},
match: '\\G((?:\\s+[-\\d.]+){3})\\s+(\\w+)\\s+([-\\d.]+)',
name: 'meta.function-call.arguments.ltspice.symbol'
}
]
}
},
scopeName: 'source.ltspice.symbol'
}
export default grammar