circuitscript 0.1.5 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BaseVisitor.js +127 -73
- package/dist/cjs/SemanticTokenVisitor.js +19 -13
- package/dist/cjs/antlr/CircuitScriptParser.js +711 -671
- package/dist/cjs/builtinMethods.js +29 -25
- package/dist/cjs/environment.js +118 -0
- package/dist/cjs/execute.js +53 -12
- package/dist/cjs/export.js +0 -5
- package/dist/cjs/geometry.js +1 -0
- package/dist/cjs/globals.js +11 -6
- package/dist/cjs/helpers.js +152 -127
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/layout.js +86 -44
- package/dist/cjs/main.js +31 -19
- package/dist/cjs/objects/ExecutionScope.js +33 -0
- package/dist/cjs/objects/ParamDefinition.js +15 -15
- package/dist/cjs/parser.js +27 -21
- package/dist/cjs/regenerate-tests.js +14 -10
- package/dist/cjs/render.js +3 -1
- package/dist/cjs/sizing.js +5 -58
- package/dist/cjs/utils.js +85 -30
- package/dist/cjs/validate/SymbolTable.js +96 -0
- package/dist/cjs/validate/SymbolValidatorResolveVisitor.js +14 -0
- package/dist/cjs/validate/SymbolValidatorVisitor.js +170 -0
- package/dist/cjs/validate.js +71 -44
- package/dist/cjs/visitor.js +140 -24
- package/dist/esm/{BaseVisitor.mjs → BaseVisitor.js} +98 -45
- package/dist/esm/{SemanticTokenVisitor.mjs → SemanticTokenVisitor.js} +17 -11
- package/dist/esm/antlr/{CircuitScriptParser.mjs → CircuitScriptParser.js} +711 -671
- package/dist/esm/{builtinMethods.mjs → builtinMethods.js} +20 -16
- package/dist/esm/{draw_symbols.mjs → draw_symbols.js} +7 -7
- package/dist/esm/environment.js +110 -0
- package/dist/esm/{execute.mjs → execute.js} +66 -25
- package/dist/esm/{export.mjs → export.js} +2 -7
- package/dist/esm/{geometry.mjs → geometry.js} +6 -5
- package/dist/esm/{globals.mjs → globals.js} +6 -1
- package/dist/esm/helpers.js +394 -0
- package/dist/esm/index.js +20 -0
- package/dist/esm/{layout.mjs → layout.js} +72 -53
- package/dist/esm/{lexer.mjs → lexer.js} +2 -2
- package/dist/esm/{main.mjs → main.js} +33 -21
- package/dist/esm/objects/{ClassComponent.mjs → ClassComponent.js} +5 -4
- package/dist/esm/objects/{ExecutionScope.mjs → ExecutionScope.js} +33 -0
- package/dist/esm/objects/{Frame.mjs → Frame.js} +1 -1
- package/dist/esm/objects/{ParamDefinition.mjs → ParamDefinition.js} +1 -1
- package/dist/esm/objects/{PinDefinition.mjs → PinDefinition.js} +1 -1
- package/dist/esm/parser.js +71 -0
- package/dist/esm/{regenerate-tests.mjs → regenerate-tests.js} +15 -11
- package/dist/esm/{render.mjs → render.js} +11 -9
- package/dist/esm/{sizing.mjs → sizing.js} +6 -34
- package/dist/esm/{utils.mjs → utils.js} +61 -17
- package/dist/esm/validate/SymbolTable.js +90 -0
- package/dist/esm/validate/SymbolValidatorResolveVisitor.js +10 -0
- package/dist/esm/validate/SymbolValidatorVisitor.js +163 -0
- package/dist/esm/validate.js +105 -0
- package/dist/esm/{visitor.mjs → visitor.js} +151 -35
- package/dist/fonts/Arial.ttf +0 -0
- package/dist/fonts/Inter-Bold.ttf +0 -0
- package/dist/fonts/Inter-Regular.ttf +0 -0
- package/dist/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/fonts/Roboto-Regular.ttf +0 -0
- package/dist/libs/lib.cst +423 -0
- package/dist/types/BaseVisitor.d.ts +34 -21
- package/dist/types/SemanticTokenVisitor.d.ts +6 -5
- package/dist/types/antlr/CircuitScriptParser.d.ts +4 -2
- package/dist/types/builtinMethods.d.ts +3 -2
- package/dist/types/environment.d.ts +31 -0
- package/dist/types/globals.d.ts +4 -1
- package/dist/types/helpers.d.ts +12 -14
- package/dist/types/index.d.ts +5 -0
- package/dist/types/layout.d.ts +2 -2
- package/dist/types/objects/ClassComponent.d.ts +1 -0
- package/dist/types/objects/ExecutionScope.d.ts +11 -0
- package/dist/types/objects/types.d.ts +6 -1
- package/dist/types/parser.d.ts +7 -11
- package/dist/types/sizing.d.ts +0 -3
- package/dist/types/utils.d.ts +30 -6
- package/dist/types/validate/SymbolTable.d.ts +40 -0
- package/dist/types/validate/SymbolValidatorResolveVisitor.d.ts +7 -0
- package/dist/types/validate/SymbolValidatorVisitor.d.ts +32 -0
- package/dist/types/validate.d.ts +1 -1
- package/package.json +15 -14
- package/dist/cjs/SymbolValidatorVisitor.js +0 -233
- package/dist/esm/SymbolValidatorVisitor.mjs +0 -222
- package/dist/esm/helpers.mjs +0 -364
- package/dist/esm/index.mjs +0 -15
- package/dist/esm/parser.mjs +0 -64
- package/dist/esm/validate.mjs +0 -74
- package/dist/types/SymbolValidatorVisitor.d.ts +0 -61
- /package/dist/esm/antlr/{CircuitScriptLexer.mjs → CircuitScriptLexer.js} +0 -0
- /package/dist/esm/antlr/{CircuitScriptVisitor.mjs → CircuitScriptVisitor.js} +0 -0
- /package/dist/esm/{fonts.mjs → fonts.js} +0 -0
- /package/dist/esm/{logger.mjs → logger.js} +0 -0
- /package/dist/esm/objects/{Net.mjs → Net.js} +0 -0
- /package/dist/esm/objects/{PinTypes.mjs → PinTypes.js} +0 -0
- /package/dist/esm/objects/{Wire.mjs → Wire.js} +0 -0
- /package/dist/esm/objects/{types.mjs → types.js} +0 -0
- /package/dist/esm/{server.mjs → server.js} +0 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
# Circuitscript default lib
|
|
2
|
+
|
|
3
|
+
def net(net_name):
|
|
4
|
+
return create component:
|
|
5
|
+
pins: 1
|
|
6
|
+
copy: true
|
|
7
|
+
angle: -90
|
|
8
|
+
display: create graphic (params):
|
|
9
|
+
hline: -50, 0, 100
|
|
10
|
+
vpin: 1, 0, 50, -50, display_pin_id=false
|
|
11
|
+
label: params.net_name, 0, -15, fontSize=50, anchor="middle"
|
|
12
|
+
type: "net"
|
|
13
|
+
params:
|
|
14
|
+
net_name: net_name
|
|
15
|
+
priority: 10
|
|
16
|
+
|
|
17
|
+
def supply(net_name):
|
|
18
|
+
net_obj = net(net_name)
|
|
19
|
+
return net_obj
|
|
20
|
+
|
|
21
|
+
def label(value, anchor="left"):
|
|
22
|
+
return create component:
|
|
23
|
+
pins: 1
|
|
24
|
+
copy: true
|
|
25
|
+
followWireOrientation: false
|
|
26
|
+
display: create graphic (params):
|
|
27
|
+
textColor: "#222"
|
|
28
|
+
label: params.value, 0, -10, fontSize=50, anchor=anchor
|
|
29
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
30
|
+
type: "net"
|
|
31
|
+
params:
|
|
32
|
+
net_name: value
|
|
33
|
+
value: value
|
|
34
|
+
priority: 5
|
|
35
|
+
|
|
36
|
+
def port(value, portType="input"):
|
|
37
|
+
return create component:
|
|
38
|
+
pins: 1
|
|
39
|
+
copy: true
|
|
40
|
+
display: create graphic (params):
|
|
41
|
+
textColor: "#222"
|
|
42
|
+
label: params.value, 0, 0, fontSize=40, anchor="left", vanchor="middle", portType=portType
|
|
43
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
44
|
+
type: "port"
|
|
45
|
+
params:
|
|
46
|
+
net_name: value
|
|
47
|
+
value: value
|
|
48
|
+
priority: 5
|
|
49
|
+
|
|
50
|
+
def res(value):
|
|
51
|
+
width = 140
|
|
52
|
+
height = 60
|
|
53
|
+
|
|
54
|
+
return create component:
|
|
55
|
+
pins: 2
|
|
56
|
+
display: create graphic (params):
|
|
57
|
+
crect: 0, 0, width, height
|
|
58
|
+
hpin: 1, -width/2 - 30, 0, 30
|
|
59
|
+
hpin: 2, width/2 + 30, 0, -30
|
|
60
|
+
label: params.refdes, -width/2, -height/2 - 20, fontSize=50, anchor="left"
|
|
61
|
+
label: params.value, 0, 0, fontSize=30, anchor="middle", vanchor="middle"
|
|
62
|
+
type: "res"
|
|
63
|
+
params:
|
|
64
|
+
value: value
|
|
65
|
+
size: "0402"
|
|
66
|
+
footprint: "Resistor_SMD:R_0402_1005Metric"
|
|
67
|
+
|
|
68
|
+
def cap(value):
|
|
69
|
+
width = 120
|
|
70
|
+
height = 40
|
|
71
|
+
|
|
72
|
+
return create component:
|
|
73
|
+
pins: 2
|
|
74
|
+
angle: 90
|
|
75
|
+
display: create graphic (params):
|
|
76
|
+
lineWidth: 13
|
|
77
|
+
hline: -width/2, 20, width
|
|
78
|
+
hline: -width/2, -20, width
|
|
79
|
+
vpin: 1, 0, -100, 80
|
|
80
|
+
vpin: 2, 0, 100, -80
|
|
81
|
+
label: params.refdes, 80, -30, fontSize=50, anchor="left", vanchor="middle"
|
|
82
|
+
label: params.value, 80, 30, fontSize=50, anchor = "left", vanchor="middle"
|
|
83
|
+
type: "cap"
|
|
84
|
+
params:
|
|
85
|
+
value: value
|
|
86
|
+
size: "0402"
|
|
87
|
+
footprint: "Capacitor_SMD:C_0402_1005Metric"
|
|
88
|
+
|
|
89
|
+
def ind(value):
|
|
90
|
+
width = 200
|
|
91
|
+
height = 100
|
|
92
|
+
|
|
93
|
+
return create component:
|
|
94
|
+
pins: 2
|
|
95
|
+
type: "ind"
|
|
96
|
+
display: create graphic (params):
|
|
97
|
+
arc: -75, 0, 25, 180, 360
|
|
98
|
+
arc: -25, 0, 25, 180, 360
|
|
99
|
+
arc: 25, 0, 25, 180, 360
|
|
100
|
+
arc: 75, 0, 25, 180, 360
|
|
101
|
+
hpin: 1, -width/2 - 100, 0, 100
|
|
102
|
+
hpin: 2, width/2 + 100, 0, -100
|
|
103
|
+
label: (params.refdes, -width/2, -height/2 - 25 , fontSize=50, anchor="left")
|
|
104
|
+
label: (params.value, 0, 50, fontSize=50, anchor="middle", vanchor="middle")
|
|
105
|
+
params:
|
|
106
|
+
value: value
|
|
107
|
+
|
|
108
|
+
def diode():
|
|
109
|
+
width = 100
|
|
110
|
+
height = 100
|
|
111
|
+
|
|
112
|
+
# Diode is drawn horizontally
|
|
113
|
+
# -|>|-
|
|
114
|
+
return create component:
|
|
115
|
+
pins: 2
|
|
116
|
+
type: "diode"
|
|
117
|
+
display: create graphic (params):
|
|
118
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
119
|
+
vline: width/2, -height/2, height
|
|
120
|
+
hpin: 1, -width/2-100, 0, 100 # anode
|
|
121
|
+
hpin: 2, width/2 + 100, 0, -100 # cathode
|
|
122
|
+
label: params.refdes, 0, -100, fontSize=50, anchor="middle", vanchor="top"
|
|
123
|
+
|
|
124
|
+
def led(color):
|
|
125
|
+
width = 100
|
|
126
|
+
height = 100
|
|
127
|
+
|
|
128
|
+
return create component:
|
|
129
|
+
pins:
|
|
130
|
+
1: "cathode"
|
|
131
|
+
2: "anode"
|
|
132
|
+
type: "diode"
|
|
133
|
+
display: create graphic (params):
|
|
134
|
+
triangle: -width/2, 0, width/2, 0, height
|
|
135
|
+
vline: width/2, -height/2, height
|
|
136
|
+
path: ("M", 70, 30, "L", 130, 90,
|
|
137
|
+
"M", 130, 60, "L", 130, 90, "L", 100, 90)
|
|
138
|
+
path: ("M", 120, 30, "L", 180, 90,
|
|
139
|
+
"M", 180, 60, "L", 180, 90, "L", 150, 90)
|
|
140
|
+
hpin: 1, -width/2-100, 0, 100 # anode
|
|
141
|
+
hpin: 2, width/2 + 100, 0, -100 # cathode
|
|
142
|
+
label: params.refdes, 0, -100, fontSize=50, anchor="middle", vanchor="top"
|
|
143
|
+
label: params.color, 0, 100, fontSize=40, anchor="middle", vanchor="bottom"
|
|
144
|
+
params:
|
|
145
|
+
size: "0603"
|
|
146
|
+
color: color
|
|
147
|
+
footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def cgnd():
|
|
151
|
+
net_name = "gnd"
|
|
152
|
+
return create component:
|
|
153
|
+
pins: 1
|
|
154
|
+
copy: true
|
|
155
|
+
angle: 90
|
|
156
|
+
display: create graphic (params):
|
|
157
|
+
hline: -15, 0, 30
|
|
158
|
+
hline: -10, 5, 20
|
|
159
|
+
hline: -5, 10, 10
|
|
160
|
+
vpin: 1, 0, -10, 10, display_pin_id=false
|
|
161
|
+
label: params.net_name, 0, 22, fontSize=50, anchor="middle"
|
|
162
|
+
type: "net"
|
|
163
|
+
params:
|
|
164
|
+
net_name: net_name
|
|
165
|
+
priority: 100
|
|
166
|
+
|
|
167
|
+
def dgnd(net_name="GND"):
|
|
168
|
+
height = 50
|
|
169
|
+
width = 100
|
|
170
|
+
|
|
171
|
+
return create component:
|
|
172
|
+
pins: 1
|
|
173
|
+
copy: true
|
|
174
|
+
angle: 90
|
|
175
|
+
display: create graphic (params):
|
|
176
|
+
triangle: 0, 0, 0, height, width
|
|
177
|
+
vpin: 1, 0, -50, 50, display_pin_id=false
|
|
178
|
+
label: params.net_name, 0, height + 50, fontSize=50, anchor="middle", vanchor="middle"
|
|
179
|
+
type: "net"
|
|
180
|
+
params:
|
|
181
|
+
net_name: net_name
|
|
182
|
+
priority: 100
|
|
183
|
+
|
|
184
|
+
def text(value, offsetX = 0, offsetY = 0, fontSize = 50):
|
|
185
|
+
return create component:
|
|
186
|
+
pins: 1
|
|
187
|
+
followWireOrientation: false
|
|
188
|
+
type: "graphic"
|
|
189
|
+
display: create graphic:
|
|
190
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
191
|
+
text:
|
|
192
|
+
content: value
|
|
193
|
+
offset: offsetX, offsetY
|
|
194
|
+
fontSize: fontSize
|
|
195
|
+
|
|
196
|
+
# Drawing markers
|
|
197
|
+
|
|
198
|
+
def marker_point():
|
|
199
|
+
return create component:
|
|
200
|
+
pins: 1
|
|
201
|
+
display: create graphic:
|
|
202
|
+
hline: -5, 0, 10
|
|
203
|
+
vline: 0, -5, 10
|
|
204
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
205
|
+
|
|
206
|
+
def arrow_point():
|
|
207
|
+
return create component:
|
|
208
|
+
pins: 1
|
|
209
|
+
followWireOrientation: false
|
|
210
|
+
display: create graphic:
|
|
211
|
+
lineWidth: 2
|
|
212
|
+
path: ("M", -10, -5, "L", -5, 0, "L", -10, 5)
|
|
213
|
+
path: ("M", -5, 0, "L", -20, 0)
|
|
214
|
+
hpin: 1, 0, 0, 0, display_pin_id=false
|
|
215
|
+
|
|
216
|
+
def no_connect(size=20):
|
|
217
|
+
return create component:
|
|
218
|
+
pins: 1
|
|
219
|
+
display: create graphic:
|
|
220
|
+
path: "M", -size, -size, "L", size, size
|
|
221
|
+
path: "M", -size, size, "L", size, -size
|
|
222
|
+
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
223
|
+
|
|
224
|
+
def dnc(size=20):
|
|
225
|
+
return no_connect(size)
|
|
226
|
+
|
|
227
|
+
def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin_y,
|
|
228
|
+
col_display_value, row_display_value, inner_frame_margin = 50):
|
|
229
|
+
|
|
230
|
+
horizontal_1 = margin_x - inner_frame_margin
|
|
231
|
+
horizontal_2 = paper_width - margin_x + inner_frame_margin
|
|
232
|
+
|
|
233
|
+
vertical_1 = margin_y - inner_frame_margin
|
|
234
|
+
vertical_2 = paper_height - margin_y + inner_frame_margin
|
|
235
|
+
|
|
236
|
+
inner_width = paper_width - 2 * margin_x
|
|
237
|
+
inner_height = paper_height - 2 * margin_y
|
|
238
|
+
|
|
239
|
+
tmp_height = paper_height - margin_y * 2 + inner_frame_margin * 2
|
|
240
|
+
tmp_y = margin_y - inner_frame_margin
|
|
241
|
+
|
|
242
|
+
tmp_width = paper_width - margin_x * 2 + inner_frame_margin * 2
|
|
243
|
+
tmp_x = margin_x - inner_frame_margin
|
|
244
|
+
|
|
245
|
+
fontSize = 30
|
|
246
|
+
|
|
247
|
+
num_columns = len(col_display_value)
|
|
248
|
+
num_rows = len(row_display_value)
|
|
249
|
+
|
|
250
|
+
ratio_x = 1 / num_columns
|
|
251
|
+
ratio_y = 1 / num_rows
|
|
252
|
+
|
|
253
|
+
title_block_width = 2000
|
|
254
|
+
title_block_height = 350
|
|
255
|
+
|
|
256
|
+
# center of title_block
|
|
257
|
+
title_block_x = margin_x + inner_width - title_block_width
|
|
258
|
+
title_block_y = margin_y + inner_height - title_block_height
|
|
259
|
+
|
|
260
|
+
title_block_x2 = title_block_x + title_block_width
|
|
261
|
+
title_block_y2 = title_block_y + title_block_height
|
|
262
|
+
|
|
263
|
+
return create component:
|
|
264
|
+
type: "graphic"
|
|
265
|
+
display: create graphic (params):
|
|
266
|
+
fill: "none"
|
|
267
|
+
|
|
268
|
+
# outer rect
|
|
269
|
+
lineColor: "#cccccc"
|
|
270
|
+
crect: (paper_width/2, paper_height/2,
|
|
271
|
+
paper_width, paper_height, class="paper-area")
|
|
272
|
+
|
|
273
|
+
# inner rect
|
|
274
|
+
lineColor: "#111111"
|
|
275
|
+
crect: (paper_width/2, paper_height/2,
|
|
276
|
+
inner_width, inner_height, class="plot-area")
|
|
277
|
+
|
|
278
|
+
crect: (paper_width/2, paper_height/2,
|
|
279
|
+
paper_width - 2 * margin_x + inner_frame_margin * 2,
|
|
280
|
+
paper_height - 2 * margin_y + inner_frame_margin * 2)
|
|
281
|
+
|
|
282
|
+
for i in range(1, num_rows):
|
|
283
|
+
hline: horizontal_1, (tmp_y + tmp_height * ratio_y * i), inner_frame_margin
|
|
284
|
+
hline: horizontal_2, (tmp_y + tmp_height * ratio_y * i), -inner_frame_margin
|
|
285
|
+
|
|
286
|
+
for i in range(1, num_columns):
|
|
287
|
+
vline: (tmp_x + tmp_width * ratio_x * i), vertical_1, inner_frame_margin
|
|
288
|
+
vline: (tmp_x + tmp_width * ratio_x * i), vertical_2, -inner_frame_margin
|
|
289
|
+
|
|
290
|
+
# labels on the columns
|
|
291
|
+
for i in col_display_value:
|
|
292
|
+
text:
|
|
293
|
+
content: i
|
|
294
|
+
offset: tmp_x + tmp_width * ratio_x * (0.5 + (i-1)), tmp_y + inner_frame_margin * 0.5 + 2
|
|
295
|
+
fontSize: fontSize
|
|
296
|
+
anchor: "middle"
|
|
297
|
+
vanchor: "middle"
|
|
298
|
+
|
|
299
|
+
text:
|
|
300
|
+
content: i
|
|
301
|
+
offset: tmp_x + tmp_width * ratio_x * (0.5 + (i-1)), tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
302
|
+
fontSize: fontSize
|
|
303
|
+
anchor: "middle"
|
|
304
|
+
vanchor: "middle"
|
|
305
|
+
|
|
306
|
+
for index, val in enumerate(row_display_value):
|
|
307
|
+
text:
|
|
308
|
+
content: val
|
|
309
|
+
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * (0.5 + index)
|
|
310
|
+
fontSize: fontSize
|
|
311
|
+
anchor: "middle"
|
|
312
|
+
vanchor: "middle"
|
|
313
|
+
|
|
314
|
+
text:
|
|
315
|
+
content: val
|
|
316
|
+
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * (0.5 + index)
|
|
317
|
+
fontSize: fontSize
|
|
318
|
+
anchor: "middle"
|
|
319
|
+
vanchor: "middle"
|
|
320
|
+
|
|
321
|
+
# Draw title frame
|
|
322
|
+
text:
|
|
323
|
+
content: "Size: " + paper_size_name
|
|
324
|
+
offset: title_block_x + 20, title_block_y2 - 30
|
|
325
|
+
anchor: "left"
|
|
326
|
+
vanchor: "bottom"
|
|
327
|
+
|
|
328
|
+
text:
|
|
329
|
+
content: "Sheet: " + params.sheet_number + "/" + params.sheet_total
|
|
330
|
+
anchor: "left"
|
|
331
|
+
vanchor: "bottom"
|
|
332
|
+
offset: title_block_x + title_block_width / 2 + 20, title_block_y2 - 30
|
|
333
|
+
|
|
334
|
+
hline: title_block_x, title_block_y2 - 100, title_block_width
|
|
335
|
+
vline: title_block_x + title_block_width / 2, title_block_y2, -100
|
|
336
|
+
|
|
337
|
+
text:
|
|
338
|
+
content: "Rev: " + params.revision
|
|
339
|
+
anchor: "left"
|
|
340
|
+
vanchor: "bottom"
|
|
341
|
+
offset: title_block_x + 20 , title_block_y2 - 130
|
|
342
|
+
|
|
343
|
+
hline: title_block_x, title_block_y2 - 200, title_block_width
|
|
344
|
+
|
|
345
|
+
text:
|
|
346
|
+
content: params.title
|
|
347
|
+
offset: title_block_x + 20, title_block_y2 - 240
|
|
348
|
+
bold: true
|
|
349
|
+
fontSize: 60
|
|
350
|
+
anchor: "left"
|
|
351
|
+
vanchor: "bottom"
|
|
352
|
+
|
|
353
|
+
crect: (title_block_x + title_block_width / 2,
|
|
354
|
+
title_block_y + title_block_height / 2,
|
|
355
|
+
title_block_width, title_block_height,
|
|
356
|
+
class="keepout-area")
|
|
357
|
+
|
|
358
|
+
params:
|
|
359
|
+
title: "Sheet title"
|
|
360
|
+
revision: "V1"
|
|
361
|
+
sheet_number: 1
|
|
362
|
+
sheet_total: 1
|
|
363
|
+
|
|
364
|
+
paper_size: paper_size_name
|
|
365
|
+
paper_width: paper_width
|
|
366
|
+
paper_height: paper_height
|
|
367
|
+
|
|
368
|
+
offset_x: margin_x
|
|
369
|
+
offset_y: margin_y
|
|
370
|
+
|
|
371
|
+
grid_width: paper_width - 2 * margin_x
|
|
372
|
+
grid_height: paper_height - 2 * margin_y
|
|
373
|
+
|
|
374
|
+
def sheet_A1():
|
|
375
|
+
paper_width = toMils(841)
|
|
376
|
+
paper_height = toMils(594)
|
|
377
|
+
margin = 400
|
|
378
|
+
|
|
379
|
+
return sheet_generator("A1", paper_width, paper_height, margin, margin,
|
|
380
|
+
range(1, 17), ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"])
|
|
381
|
+
|
|
382
|
+
def sheet_A2():
|
|
383
|
+
paper_width = toMils(594)
|
|
384
|
+
paper_height = toMils(420)
|
|
385
|
+
margin = 400
|
|
386
|
+
|
|
387
|
+
return sheet_generator("A2", paper_width, paper_height, margin, margin,
|
|
388
|
+
range(1, 13), ["A", "B", "C", "D", "E", "F", "G", "H"])
|
|
389
|
+
|
|
390
|
+
def sheet_A3():
|
|
391
|
+
paper_width = toMils(420)
|
|
392
|
+
paper_height = toMils(297)
|
|
393
|
+
margin = 400
|
|
394
|
+
|
|
395
|
+
return sheet_generator("A3", paper_width, paper_height, margin, margin,
|
|
396
|
+
range(1, 9), ["A", "B", "C", "D", "E", "F"])
|
|
397
|
+
|
|
398
|
+
def sheet_A4():
|
|
399
|
+
paper_width = toMils(297)
|
|
400
|
+
paper_height = toMils(210)
|
|
401
|
+
margin = 400
|
|
402
|
+
|
|
403
|
+
return sheet_generator("A4", paper_width, paper_height, margin, margin,
|
|
404
|
+
range(1, 7), ["A", "B", "C", "D"])
|
|
405
|
+
|
|
406
|
+
def sheet_A5():
|
|
407
|
+
paper_width = toMils(210)
|
|
408
|
+
paper_height = toMils(148)
|
|
409
|
+
margin = 400
|
|
410
|
+
|
|
411
|
+
return sheet_generator("A5", paper_width, paper_height, margin, margin, range(1, 5), ["A", "B", "C"])
|
|
412
|
+
|
|
413
|
+
def sheet_A6(revision="V1"):
|
|
414
|
+
paper_width = toMils(148)
|
|
415
|
+
paper_height = toMils(105)
|
|
416
|
+
margin = 400
|
|
417
|
+
|
|
418
|
+
tmp_sheet = sheet_generator("A6", paper_width, paper_height, margin, margin, range(1, 4), ["A", "B"])
|
|
419
|
+
tmp_sheet.revision = revision
|
|
420
|
+
|
|
421
|
+
return tmp_sheet
|
|
422
|
+
|
|
423
|
+
document.sheet_type = sheet_A4()
|
|
@@ -1,32 +1,37 @@
|
|
|
1
|
-
import { Array_exprContext, ArrayExprContext, Assignment_exprContext, Atom_exprContext, Break_keywordContext, Continue_keywordContext, ExpressionContext, Function_args_exprContext, Function_call_exprContext, Function_exprContext, Function_return_exprContext, FunctionCallExprContext, Import_exprContext, Operator_assignment_exprContext, ParametersContext, RoundedBracketsExprContext, ScriptContext, Value_exprContext, ValueAtomExprContext } from "./antlr/CircuitScriptParser";
|
|
2
|
-
import { CircuitScriptVisitor } from "./antlr/CircuitScriptVisitor";
|
|
3
|
-
import { ExecutionContext } from "./execute";
|
|
4
|
-
import { Logger } from "./logger";
|
|
5
|
-
import { ClassComponent } from "./objects/ClassComponent";
|
|
6
|
-
import { Net } from "./objects/Net";
|
|
7
|
-
import { CallableParameter, CFunctionOptions, ComplexType, Direction, FunctionDefinedParameter, ReferenceType } from "./objects/types";
|
|
1
|
+
import { Array_exprContext, ArrayExprContext, Assignment_exprContext, Atom_exprContext, Break_keywordContext, Continue_keywordContext, ExpressionContext, Function_args_exprContext, Function_call_exprContext, Function_exprContext, Function_return_exprContext, FunctionCallExprContext, Import_exprContext, Operator_assignment_exprContext, ParametersContext, RoundedBracketsExprContext, ScriptContext, Value_exprContext, ValueAtomExprContext } from "./antlr/CircuitScriptParser.js";
|
|
2
|
+
import { CircuitScriptVisitor } from "./antlr/CircuitScriptVisitor.js";
|
|
3
|
+
import { ExecutionContext } from "./execute.js";
|
|
4
|
+
import { Logger } from "./logger.js";
|
|
5
|
+
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
6
|
+
import { Net } from "./objects/Net.js";
|
|
7
|
+
import { CallableParameter, CFunctionOptions, ComplexType, Direction, FunctionDefinedParameter, ReferenceType } from "./objects/types.js";
|
|
8
8
|
import { ParserRuleContext } from 'antlr4ng';
|
|
9
|
+
import { BaseError } from './utils.js';
|
|
10
|
+
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
11
|
+
import { NodeScriptEnvironment } from "./environment.js";
|
|
9
12
|
export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | ReferenceType | any> {
|
|
10
13
|
indentLevel: number;
|
|
11
14
|
startingContext: ExecutionContext;
|
|
12
15
|
executionStack: ExecutionContext[];
|
|
13
16
|
silent: boolean;
|
|
14
17
|
logger: Logger;
|
|
15
|
-
currentDirectory: string;
|
|
16
|
-
defaultLibsPath: string;
|
|
17
18
|
printStream: string[];
|
|
18
19
|
printToConsole: boolean;
|
|
19
20
|
acceptedDirections: Direction[];
|
|
20
21
|
protected resultData: Map<ParserRuleContext, any>;
|
|
21
22
|
protected paramData: Map<ParserRuleContext, any>;
|
|
22
23
|
pinTypesList: string[];
|
|
23
|
-
|
|
24
|
-
|
|
24
|
+
onErrorHandler: OnErrorHandler | null;
|
|
25
|
+
environment: NodeScriptEnvironment;
|
|
26
|
+
protected importedFiles: ImportFile[];
|
|
27
|
+
onImportFile: (visitor: BaseVisitor, filePath: string, fileData: string, onErrorHandler: OnErrorHandler) => Promise<{
|
|
25
28
|
hasError: boolean;
|
|
26
29
|
hasParseError: boolean;
|
|
27
|
-
}
|
|
28
|
-
constructor(silent: boolean | undefined, onErrorHandler:
|
|
30
|
+
}>;
|
|
31
|
+
constructor(silent: boolean | undefined, onErrorHandler: OnErrorHandler | null | undefined, environment: NodeScriptEnvironment);
|
|
29
32
|
getExecutor(): ExecutionContext;
|
|
33
|
+
getScope(): ExecutionScope;
|
|
34
|
+
getRootExecutor(): ExecutionContext;
|
|
30
35
|
protected setupBuiltInFunctions(context: ExecutionContext): void;
|
|
31
36
|
createNetResolver(executionStack: ExecutionContext[]): (netName: string, netNamespace: string) => {
|
|
32
37
|
found: boolean;
|
|
@@ -35,7 +40,8 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | Refe
|
|
|
35
40
|
createComponentPinNetResolver(executionStack: ExecutionContext[]): (component: ClassComponent, pin: number) => Net | null;
|
|
36
41
|
log(...params: any[]): void;
|
|
37
42
|
log2(message: string): void;
|
|
38
|
-
|
|
43
|
+
visitAsync(ctx: ParserRuleContext): Promise<void>;
|
|
44
|
+
visitScript: (ctx: ScriptContext) => Promise<void>;
|
|
39
45
|
visitAssignment_expr: (ctx: Assignment_exprContext) => void;
|
|
40
46
|
visitOperator_assignment_expr: (ctx: Operator_assignment_exprContext) => void;
|
|
41
47
|
private getReference;
|
|
@@ -55,11 +61,7 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | Refe
|
|
|
55
61
|
protected setResult(ctx: ParserRuleContext, value: any): void;
|
|
56
62
|
protected getResult(ctx: ParserRuleContext): any;
|
|
57
63
|
protected visitResult(ctx: ParserRuleContext): any;
|
|
58
|
-
protected handleImportFile(name: string, throwErrors?: boolean, ctx?: ParserRuleContext | null):
|
|
59
|
-
hasError: boolean;
|
|
60
|
-
hasParseError: boolean;
|
|
61
|
-
pathExists: boolean;
|
|
62
|
-
};
|
|
64
|
+
protected handleImportFile(name: string, throwErrors?: boolean, ctx?: ParserRuleContext | null): Promise<ImportFile>;
|
|
63
65
|
visitRoundedBracketsExpr: (ctx: RoundedBracketsExprContext) => void;
|
|
64
66
|
protected setupDefinedParameters(funcDefinedParameters: FunctionDefinedParameter[], passedInParameters: CallableParameter[], executor: ExecutionContext): void;
|
|
65
67
|
protected runExpressions(executor: ExecutionContext, expressions: ExpressionContext[] | Function_exprContext[]): ComplexType;
|
|
@@ -68,6 +70,17 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | Refe
|
|
|
68
70
|
protected getInstanceParam<T>(object: ClassComponent, trailers: string[]): T;
|
|
69
71
|
protected enterNewChildContext(executionStack: ExecutionContext[], parentContext: ExecutionContext, executionContextName: string, options: CFunctionOptions, funcDefinedParameters: FunctionDefinedParameter[], passedInParameters: CallableParameter[]): ExecutionContext;
|
|
70
72
|
protected prepareStringValue(value: string): string;
|
|
71
|
-
protected throwWithContext(context: ParserRuleContext,
|
|
73
|
+
protected throwWithContext(context: ParserRuleContext, messageOrError: string | BaseError): void;
|
|
74
|
+
protected validateType(value: any, context: ParserRuleContext, validateFunction: (value: any) => boolean, expectedType: string): boolean;
|
|
75
|
+
protected validateString(value: any, context: ParserRuleContext): void;
|
|
76
|
+
protected validateBoolean(value: any, context: ParserRuleContext): void;
|
|
77
|
+
protected validateNumeric(value: any, context: ParserRuleContext): void;
|
|
72
78
|
}
|
|
73
|
-
export type
|
|
79
|
+
export type OnErrorHandler = (message: string, context: ParserRuleContext, e?: any) => void;
|
|
80
|
+
type ImportFile = {
|
|
81
|
+
id: string;
|
|
82
|
+
hasError: boolean;
|
|
83
|
+
hasParseError: boolean;
|
|
84
|
+
pathExists: boolean;
|
|
85
|
+
};
|
|
86
|
+
export {};
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { TerminalNode, Token } from "antlr4ng";
|
|
2
|
-
import { CircuitScriptLexer } from "./antlr/CircuitScriptLexer";
|
|
3
|
-
import { Function_def_exprContext, Create_component_exprContext, Create_graphic_exprContext, Atom_exprContext, Property_key_exprContext, ValueAtomExprContext, Assignment_exprContext, Import_exprContext, Function_args_exprContext, Function_call_exprContext,
|
|
4
|
-
import { BaseVisitor,
|
|
2
|
+
import { CircuitScriptLexer } from "./antlr/CircuitScriptLexer.js";
|
|
3
|
+
import { Function_def_exprContext, Create_component_exprContext, Create_graphic_exprContext, Atom_exprContext, Property_key_exprContext, ValueAtomExprContext, Assignment_exprContext, Import_exprContext, Function_args_exprContext, Function_call_exprContext, GraphicCommandExprContext } from "./antlr/CircuitScriptParser.js";
|
|
4
|
+
import { BaseVisitor, OnErrorHandler } from "./BaseVisitor.js";
|
|
5
|
+
import { NodeScriptEnvironment } from "./environment.js";
|
|
5
6
|
export declare class SemanticTokensVisitor extends BaseVisitor {
|
|
6
7
|
parsedTokens: IParsedToken[];
|
|
7
8
|
lexer: CircuitScriptLexer;
|
|
8
9
|
script: string;
|
|
9
10
|
semanticTokens: Map<string, IParsedToken>;
|
|
10
|
-
constructor(silent: boolean | undefined, onErrorHandler:
|
|
11
|
+
constructor(silent: boolean | undefined, onErrorHandler: OnErrorHandler | null | undefined, environment: NodeScriptEnvironment, lexer: CircuitScriptLexer, script: string);
|
|
11
12
|
visitFunction_args_expr: (ctx: Function_args_exprContext) => void;
|
|
12
13
|
visitFunction_call_expr: (ctx: Function_call_exprContext) => void;
|
|
13
14
|
visitFunction_def_expr: (ctx: Function_def_exprContext) => void;
|
|
14
15
|
visitCreate_component_expr: (ctx: Create_component_exprContext) => void;
|
|
15
16
|
visitCreate_graphic_expr: (ctx: Create_graphic_exprContext) => void;
|
|
16
17
|
visitProperty_key_expr: (ctx: Property_key_exprContext) => void;
|
|
17
|
-
|
|
18
|
+
visitGraphicCommandExpr: (ctx: GraphicCommandExprContext) => void;
|
|
18
19
|
visitValueAtomExpr: (ctx: ValueAtomExprContext) => void;
|
|
19
20
|
visitAssignment_expr: (ctx: Assignment_exprContext) => void;
|
|
20
21
|
visitAtom_expr: (ctx: Atom_exprContext) => void;
|
|
@@ -220,10 +220,12 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
220
220
|
export declare class ScriptContext extends antlr.ParserRuleContext {
|
|
221
221
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
222
222
|
EOF(): antlr.TerminalNode;
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
import_expr(): Import_exprContext[];
|
|
224
|
+
import_expr(i: number): Import_exprContext | null;
|
|
225
225
|
NEWLINE(): antlr.TerminalNode[];
|
|
226
226
|
NEWLINE(i: number): antlr.TerminalNode | null;
|
|
227
|
+
expression(): ExpressionContext[];
|
|
228
|
+
expression(i: number): ExpressionContext | null;
|
|
227
229
|
get ruleIndex(): number;
|
|
228
230
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
229
231
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { BaseVisitor } from "./BaseVisitor";
|
|
2
|
-
import { ExecutionContext } from "./execute";
|
|
1
|
+
import { BaseVisitor } from "./BaseVisitor.js";
|
|
2
|
+
import { ExecutionContext } from "./execute.js";
|
|
3
|
+
export declare const buildInMethodNamesList: string[];
|
|
3
4
|
export declare function linkBuiltInMethods(context: ExecutionContext, visitor: BaseVisitor): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
import { Dom } from "@svgdotjs/svg.js";
|
|
3
|
+
import { PathOrFileDescriptor, PathLike } from "fs";
|
|
4
|
+
import { SVGWindow } from "./helpers.js";
|
|
5
|
+
export declare class NodeScriptEnvironment {
|
|
6
|
+
static _instance: NodeScriptEnvironment | null;
|
|
7
|
+
static setInstance(instance: NodeScriptEnvironment): void;
|
|
8
|
+
static getInstance(): NodeScriptEnvironment;
|
|
9
|
+
protected useModuleDirectoryPath: string | null;
|
|
10
|
+
protected useDefaultLibsPath: string | null;
|
|
11
|
+
protected globalCreateSVGWindow: (() => SVGWindow) | null;
|
|
12
|
+
protected supportedFonts: {
|
|
13
|
+
Arial: string;
|
|
14
|
+
};
|
|
15
|
+
setModuleDirectory(path: string): void;
|
|
16
|
+
setDefaultLibsPath(path: string): void;
|
|
17
|
+
getPackageVersion(): string;
|
|
18
|
+
getModuleDirectory(): string;
|
|
19
|
+
getRelativeToModule(filePath: string): string;
|
|
20
|
+
getRelativeToDefaultLibs(filePath: string): string;
|
|
21
|
+
getToolsPath(): string;
|
|
22
|
+
getFontsPath(): string;
|
|
23
|
+
getDefaultLibsPath(): string;
|
|
24
|
+
private prepareSVGEnvironmentInternal;
|
|
25
|
+
createSVGWindow(): SVGWindow;
|
|
26
|
+
textMeasurementCanvas: Dom | undefined;
|
|
27
|
+
getCanvasWindow(): Dom;
|
|
28
|
+
prepareSVGEnvironment(): Promise<void>;
|
|
29
|
+
readFile(path: PathOrFileDescriptor, options: any): Promise<string>;
|
|
30
|
+
exists(path: PathLike): Promise<boolean>;
|
|
31
|
+
}
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export declare const TOOL_VERSION = "0.1.5";
|
|
1
2
|
export declare const Delimiter1 = "-";
|
|
2
3
|
export declare const DoubleDelimiter1 = "--";
|
|
3
4
|
export declare enum GlobalNames {
|
|
@@ -23,6 +24,7 @@ export declare enum SymbolPinSide {
|
|
|
23
24
|
Top = "top",
|
|
24
25
|
Bottom = "bottom"
|
|
25
26
|
}
|
|
27
|
+
export declare const ValidPinSides: string[];
|
|
26
28
|
export declare enum LengthUnit {
|
|
27
29
|
mm = "mm",
|
|
28
30
|
mils = "mils",
|
|
@@ -56,7 +58,7 @@ export declare const displayUnits = LengthUnit.mils;
|
|
|
56
58
|
export declare const defaultFont = "Arial";
|
|
57
59
|
export declare const defaultFontBold = "Arial";
|
|
58
60
|
export declare const defaultFontSize = 10;
|
|
59
|
-
export declare const junctionSize: import("./objects/ParamDefinition").NumericValue;
|
|
61
|
+
export declare const junctionSize: import("./objects/ParamDefinition.js").NumericValue;
|
|
60
62
|
export declare const PortArrowSize: number;
|
|
61
63
|
export declare const PortPaddingHorizontal: number;
|
|
62
64
|
export declare const PortPaddingVertical: number;
|
|
@@ -99,3 +101,4 @@ export declare const RenderFlags: {
|
|
|
99
101
|
ShowLabelBoxBounds: boolean;
|
|
100
102
|
ShowLabelOrigin: boolean;
|
|
101
103
|
};
|
|
104
|
+
export declare const SymbolValidatorContext = "_sym";
|