-
Notifications
You must be signed in to change notification settings - Fork 5
/
spice.lang
245 lines (217 loc) · 7.15 KB
/
spice.lang
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?xml version="1.0" encoding="UTF-8"?>
<language id="spice" _name="SPICE" version="2.0" _section="Source">
<metadata>
<property name="mimetypes">text/x-sp;text/x-spsrc</property>
<property name="globs">*.sp;*.net;*.sub;*.cir;*.ckt;*.cdl;*.mdl;*.mod;*.scs;*.spi</property>
</metadata>
<styles>
<style id="comment" _name="Comment" map-to="def:comment" />
<style id="string" _name="String" map-to="def:string" />
<style id="escaped-character" _name="Escaped Character" map-to="def:special-char" />
<style id="preprocessor" _name="Preprocessor" map-to="def:preprocessor" />
<style id="included-file" _name="Included File" map-to="def:string" />
<style id="char" _name="Character" map-to="def:character" />
<style id="keyword" _name="Keyword" map-to="def:keyword" />
<style id="type" _name="Data Type" map-to="def:type" />
<style id="attribute-name" _name="Attribute name" map-to="def:identifier" />
<style id="number" _name="Number" map-to="def:number" />
<style id="constant" _name="Constant" map-to="def:preprocessor" />
<style id="net-address" _name="URL" map-to="def:underlined"/>
</styles>
<default-regex-options case-sensitive="false" />
<definitions>
<context id="spice">
<include>
<define-regex id="prefix">[a-zA-Z_][a-zA-Z0-9._-]*</define-regex>
<define-regex id="name">[a-zA-Z_][a-zA-Z0-9.:_-]*((\[|<)?[0-9]*(\]|>)?)?</define-regex>
<define-regex id="values">[-+]?((((\.|[0-9]+)\.?)([0-9]*)([eE][-+]?[0-9]+)?[fpnumcdhkxMegGTAVWFHzHSsC]{0,3})|([0-9]+[fpnumcdhkMegxGTAVWFHzHSsC]{1,3}))</define-regex>
<!-- Comments -->
<context id="comment-firstline" once-only="true" end-at-line-end="true" style-ref="comment">
<start>^</start>
<end>$</end>
<include>
<context ref="def:in-comment"/>
</include>
</context>
<context id="comment" style-ref="comment">
<start>(\*|\;|\$)</start>
<end>$</end>
<include>
<context ref="def:in-comment"/>
</include>
</context>
<!-- Values and Numbers -->
<context id="values" style-ref="constant">
<match>[ \t]\%{values}</match>
</context>
<!-- Parameter Value -->
<context id="param-value1" end-at-line-end="true" style-ref="string">
<start>"</start>
<end>"</end>
<include>
<context id="escaped-character" style-ref="escaped-character">
<match>\\.</match>
</context>
<context ref="values" />
</include>
</context>
<context id="param-value2" end-at-line-end="true" style-ref="string">
<start>'</start>
<end>'</end>
<include>
<context ref="escaped-character"/>
<context ref="values" />
</include>
</context>
<context id="param-value3" end-at-line-end="true" style-ref="string">
<start>{</start>
<end>}</end>
<include>
<context ref="escaped-character"/>
<context ref="values" />
<context ref="attribute-name" />
</include>
</context>
<context id="param-value4" end-at-line-end="true" style-ref="string">
<start><</start>
<end>></end>
<include>
<context ref="escaped-character"/>
<context ref="values" />
<context ref="attribute-name" />
</include>
</context>
<context id="param-value5" end-at-line-end="true" style-ref="string">
<start>(v|i)?\(</start>
<end>\)</end>
<include>
<context id="line-continue" style-ref="preprocessor">
<start>$</start>
<end>^\+</end>
</context>
<context ref="escaped-character"/>
<context ref="values" />
<context ref="attribute-name" />
</include>
</context>
<context id="param-value6" end-at-line-end="true" style-ref="string">
<start>\[</start>
<end>\]</end>
<include>
<context ref="escaped-character"/>
<context ref="values" />
<context ref="attribute-name" />
</include>
</context>
<!-- Attribute Names -->
<context id="attribute-name" style-ref="attribute-name" class="no-spell-check">
<match>\b\%{name}\s*=[ \t]*(\%{values})?</match>
<include>
<context id="included-file"
sub-pattern="4"
style-ref="constant"/>
</include>
</context>
<!-- Simulation Commands -->
<context id="sim-commands" style-ref="keyword">
<prefix>^\.</prefix>
<keyword>global</keyword>
<keyword>subckt</keyword>
<keyword>model</keyword>
<keyword>tran</keyword>
<keyword>temp</keyword>
<keyword>ac</keyword>
<keyword>dc</keyword>
<keyword>four</keyword>
<keyword>disto</keyword>
<keyword>sens</keyword>
<keyword>noise</keyword>
<keyword>tf</keyword>
<keyword>pz</keyword>
<keyword>print</keyword>
<keyword>plot</keyword>
<keyword>op</keyword>
<keyword>option</keyword>
<keyword>ends</keyword>
<keyword>endl</keyword>
</context>
<!-- Sources -->
<context id="sources" style-ref="type">
<keyword>^v\w*</keyword>
<keyword>^i\w*</keyword>
<keyword>^e\w*</keyword><!-- VCVS -->
<keyword>^f\w*</keyword><!-- CCCS -->
<keyword>^g\w*</keyword><!-- VCCS -->
<keyword>^h\w*</keyword><!-- CCVS -->
</context>
<!-- Switch Source (had to be separated because of conflicts with sin and sffm. -->
<context id="sources-switch" style-ref="type">
<match>^(S|s)\w+\s</match>
</context>
<!-- Passive Components -->
<context id="passives" style-ref="type">
<keyword>^r\w*</keyword>
<keyword>^c\w*</keyword>
<keyword>^l\w*</keyword>
<keyword>^k\w*</keyword>
<keyword>^y\w*</keyword>
<keyword>^t\w*</keyword>
</context>
<!-- Active Components -->
<context id="actives" style-ref="type">
<keyword>^d\w*</keyword>
<keyword>^q\w*</keyword>
<keyword>^m\w*</keyword>
<keyword>^j\w*</keyword>
<keyword>^x\w*</keyword>
</context>
<!-- Commands -->
<context id="commands" style-ref="preprocessor">
<prefix>.</prefix>
<keyword>include</keyword>
<keyword>lib</keyword>
<keyword>param</keyword>
<keyword>probe</keyword>
<keyword>nodeset</keyword>
<keyword>ic</keyword>
<keyword>end</keyword>
</context>
<!-- Functions -->
<context id="functions" style-ref="escaped-character">
<keyword>abs</keyword>
<keyword>ac</keyword>
<keyword>acos</keyword>
<keyword>asin</keyword>
<keyword>atan</keyword>
<keyword>cos</keyword>
<keyword>cosh</keyword>
<keyword>db</keyword>
<keyword>dc</keyword>
<keyword>dec</keyword>
<keyword>exp</keyword>
<keyword>int</keyword>
<keyword>lin</keyword>
<keyword>log</keyword>
<keyword>log10</keyword>
<keyword>lv</keyword>
<keyword>lx</keyword>
<keyword>max</keyword>
<keyword>min</keyword>
<keyword>oct</keyword>
<keyword>pow</keyword>
<keyword>pulse</keyword>
<keyword>pwl</keyword>
<keyword>pwr</keyword>
<keyword>sffm</keyword>
<keyword>sgn</keyword>
<keyword>sign</keyword>
<keyword>sin</keyword>
<keyword>sinh</keyword>
<keyword>sqrt</keyword>
<keyword>tan</keyword>
<keyword>tanh</keyword>
</context>
</include>
</context>
</definitions>
</language>