circuitscript 0.5.4 → 0.5.5
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 +11 -10
- package/dist/cjs/builtinMethods.js +6 -5
- package/dist/cjs/environment/environment.js +2 -2
- package/dist/cjs/errors.js +140 -0
- package/dist/cjs/execute.js +12 -5
- package/dist/cjs/main.js +3 -2
- package/dist/cjs/objects/ClassComponent.js +4 -4
- package/dist/cjs/objects/ExecutionScope.js +2 -2
- package/dist/cjs/objects/NumericValue.js +15 -0
- package/dist/cjs/objects/PinDefinition.js +2 -2
- package/dist/cjs/objects/types.js +2 -2
- package/dist/cjs/parser.js +3 -2
- package/dist/cjs/pipeline.js +21 -14
- package/dist/cjs/regenerate-tests.js +6 -6
- package/dist/cjs/render/draw_symbols.js +17 -17
- package/dist/cjs/render/geometry.js +6 -6
- package/dist/cjs/render/layout.js +325 -253
- package/dist/cjs/render/render.js +21 -18
- package/dist/cjs/semantic-tokens/getSemanticTokens.js +2 -2
- package/dist/cjs/sizing.js +2 -2
- package/dist/cjs/utils.js +13 -110
- package/dist/cjs/validate/validateScript.js +2 -2
- package/dist/cjs/visitor.js +14 -12
- package/dist/esm/BaseVisitor.js +2 -1
- package/dist/esm/builtinMethods.js +6 -5
- package/dist/esm/environment/environment.js +1 -1
- package/dist/esm/errors.js +119 -0
- package/dist/esm/execute.js +10 -3
- package/dist/esm/main.js +3 -2
- package/dist/esm/objects/ClassComponent.js +1 -1
- package/dist/esm/objects/ExecutionScope.js +1 -1
- package/dist/esm/objects/NumericValue.js +15 -0
- package/dist/esm/objects/PinDefinition.js +1 -1
- package/dist/esm/objects/types.js +1 -1
- package/dist/esm/parser.js +2 -1
- package/dist/esm/pipeline.js +10 -3
- package/dist/esm/regenerate-tests.js +6 -6
- package/dist/esm/render/draw_symbols.js +15 -15
- package/dist/esm/render/geometry.js +6 -6
- package/dist/esm/render/layout.js +325 -253
- package/dist/esm/render/render.js +22 -19
- package/dist/esm/semantic-tokens/getSemanticTokens.js +1 -1
- package/dist/esm/sizing.js +2 -2
- package/dist/esm/utils.js +10 -95
- package/dist/esm/validate/validateScript.js +1 -1
- package/dist/esm/visitor.js +4 -2
- package/dist/libs/std.cst +31 -31
- package/dist/types/BaseVisitor.d.ts +3 -1
- package/dist/types/errors.d.ts +37 -0
- package/dist/types/execute.d.ts +1 -1
- package/dist/types/helpers.d.ts +1 -1
- package/dist/types/objects/NumericValue.d.ts +5 -1
- package/dist/types/render/geometry.d.ts +4 -4
- package/dist/types/render/layout.d.ts +7 -1
- package/dist/types/utils.d.ts +2 -27
- package/dist/types/visitor.d.ts +1 -1
- package/libs/std.cst +31 -31
- package/package.json +1 -1
package/dist/types/visitor.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { NodeScriptEnvironment } from './environment/environment.js';
|
|
|
11
11
|
export declare class ParserVisitor extends BaseVisitor {
|
|
12
12
|
constructor(silent: boolean | undefined, onErrorHandler: OnErrorHandler | null | undefined, environment: NodeScriptEnvironment);
|
|
13
13
|
componentCreationIndex: number;
|
|
14
|
-
creationCtx: Map<
|
|
14
|
+
creationCtx: Map<ClassComponent | Wire, ParserRuleContext>;
|
|
15
15
|
visitPin_select_expr: (ctx: Pin_select_exprContext) => void;
|
|
16
16
|
trackNewComponentCreated: (callback: () => void) => boolean;
|
|
17
17
|
visitAdd_component_expr: (ctx: Add_component_exprContext) => void;
|
package/libs/std.cst
CHANGED
|
@@ -7,7 +7,7 @@ def net(net_name, net_type = "any"):
|
|
|
7
7
|
display: create graphic (params):
|
|
8
8
|
hline: -50, 0, 100
|
|
9
9
|
vpin: 1, 0, 50, -50, display_id=false
|
|
10
|
-
label: params.net_name, 0, -15, fontSize=50, anchor="
|
|
10
|
+
label: params.net_name, 0, -15, fontSize=50, anchor="center"
|
|
11
11
|
type: "net"
|
|
12
12
|
params:
|
|
13
13
|
net_name: net_name
|
|
@@ -39,7 +39,7 @@ def port(value, portType="input"):
|
|
|
39
39
|
copy: true
|
|
40
40
|
display: create graphic (params):
|
|
41
41
|
text_color: "#222"
|
|
42
|
-
label: params.value, 0, 0, fontSize=40, anchor="left", vanchor="
|
|
42
|
+
label: params.value, 0, 0, fontSize=40, anchor="left", vanchor="center", portType=portType
|
|
43
43
|
pin: 1, 0, 0, 0, 0, display_id=false
|
|
44
44
|
type: "port"
|
|
45
45
|
params:
|
|
@@ -58,7 +58,7 @@ def res(value):
|
|
|
58
58
|
hpin: 1, -width/2 - 30, 0, 30, display_id=false
|
|
59
59
|
hpin: 2, width/2 + 30, 0, -30, display_id=false
|
|
60
60
|
label: params.refdes, -width/2, -height/2 - 20, fontSize=50, anchor="left"
|
|
61
|
-
label: params.value, 0, 0, fontSize=30, anchor="
|
|
61
|
+
label: params.value, 0, 0, fontSize=30, anchor="center", vanchor="center"
|
|
62
62
|
type: "res"
|
|
63
63
|
params:
|
|
64
64
|
value: value
|
|
@@ -78,8 +78,8 @@ def cap(value):
|
|
|
78
78
|
hline: -width/2, -20, width
|
|
79
79
|
vpin: 1, 0, -100, 80, display_id=false
|
|
80
80
|
vpin: 2, 0, 100, -80, display_id=false
|
|
81
|
-
label: params.refdes, 80, -30, fontSize=50, anchor="left", vanchor="
|
|
82
|
-
label: params.value, 80, 30, fontSize=50, anchor = "left", vanchor="
|
|
81
|
+
label: params.refdes, 80, -30, fontSize=50, anchor="left", vanchor="center"
|
|
82
|
+
label: params.value, 80, 30, fontSize=50, anchor = "left", vanchor="center"
|
|
83
83
|
type: "cap"
|
|
84
84
|
params:
|
|
85
85
|
value: value
|
|
@@ -101,7 +101,7 @@ def ind(value):
|
|
|
101
101
|
hpin: 1, -width/2 - 100, 0, 100, display_id=false
|
|
102
102
|
hpin: 2, width/2 + 100, 0, -100, display_id=false
|
|
103
103
|
label: (params.refdes, -width/2, -height/2 - 25 , fontSize=50, anchor="left")
|
|
104
|
-
label: (params.value, 0, 50, fontSize=50, anchor="
|
|
104
|
+
label: (params.value, 0, 50, fontSize=50, anchor="center", vanchor="center")
|
|
105
105
|
params:
|
|
106
106
|
value: value
|
|
107
107
|
|
|
@@ -119,7 +119,7 @@ def diode():
|
|
|
119
119
|
vline: width/2, -height/2, height
|
|
120
120
|
hpin: 1, -width/2-100, 0, 100 # cathode
|
|
121
121
|
hpin: 2, width/2 + 100, 0, -100 # anode
|
|
122
|
-
label: params.refdes, 0, -100, fontSize=50, anchor="
|
|
122
|
+
label: params.refdes, 0, -100, fontSize=50, anchor="center", vanchor="top"
|
|
123
123
|
|
|
124
124
|
def led(color):
|
|
125
125
|
width = 100
|
|
@@ -140,8 +140,8 @@ def led(color):
|
|
|
140
140
|
"M", 180, 60, "L", 180, 90, "L", 150, 90)
|
|
141
141
|
hpin: 1, width/2 + 100, 0, -100 # cathode
|
|
142
142
|
hpin: 2, -width/2-100, 0, 100 # anode
|
|
143
|
-
label: params.refdes, 0, -100, fontSize=50, anchor="
|
|
144
|
-
label: params.color, 0, 100, fontSize=40, anchor="
|
|
143
|
+
label: params.refdes, 0, -100, fontSize=50, anchor="center", vanchor="top"
|
|
144
|
+
label: params.color, 0, 100, fontSize=40, anchor="center", vanchor="bottom"
|
|
145
145
|
params:
|
|
146
146
|
size: "0603"
|
|
147
147
|
color: color
|
|
@@ -159,7 +159,7 @@ def cgnd():
|
|
|
159
159
|
hline: -10, 5, 20
|
|
160
160
|
hline: -5, 10, 10
|
|
161
161
|
vpin: 1, 0, -10, 10, display_id=false
|
|
162
|
-
label: params.net_name, 0, 22, fontSize=50, anchor="
|
|
162
|
+
label: params.net_name, 0, 22, fontSize=50, anchor="center"
|
|
163
163
|
type: "net"
|
|
164
164
|
params:
|
|
165
165
|
net_name: net_name
|
|
@@ -175,7 +175,7 @@ def dgnd(net_name="GND"):
|
|
|
175
175
|
display: create graphic (params):
|
|
176
176
|
triangle: 0, 0, 0, height, width
|
|
177
177
|
vpin: 1, 0, -50, 50, display_id=false
|
|
178
|
-
label: params.net_name, 0, height + 50, fontSize=50, anchor="
|
|
178
|
+
label: params.net_name, 0, height + 50, fontSize=50, anchor="center", vanchor="center"
|
|
179
179
|
type: "net"
|
|
180
180
|
params:
|
|
181
181
|
net_name: net_name
|
|
@@ -296,30 +296,30 @@ def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin
|
|
|
296
296
|
content: i
|
|
297
297
|
offset: tmp_x + tmp_width * ratio_x * (0.5 + (i-1)), tmp_y + inner_frame_margin * 0.5 + 2
|
|
298
298
|
fontSize: fontSize
|
|
299
|
-
anchor: "
|
|
300
|
-
vanchor: "
|
|
299
|
+
anchor: "center"
|
|
300
|
+
vanchor: "center"
|
|
301
301
|
|
|
302
302
|
text:
|
|
303
303
|
content: i
|
|
304
304
|
offset: tmp_x + tmp_width * ratio_x * (0.5 + (i-1)), tmp_y + tmp_height - inner_frame_margin * 0.5 + 2
|
|
305
305
|
fontSize: fontSize
|
|
306
|
-
anchor: "
|
|
307
|
-
vanchor: "
|
|
306
|
+
anchor: "center"
|
|
307
|
+
vanchor: "center"
|
|
308
308
|
|
|
309
309
|
for index, val in enumerate(row_display_value):
|
|
310
310
|
text:
|
|
311
311
|
content: val
|
|
312
312
|
offset: tmp_x + inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * (0.5 + index)
|
|
313
313
|
fontSize: fontSize
|
|
314
|
-
anchor: "
|
|
315
|
-
vanchor: "
|
|
314
|
+
anchor: "center"
|
|
315
|
+
vanchor: "center"
|
|
316
316
|
|
|
317
317
|
text:
|
|
318
318
|
content: val
|
|
319
319
|
offset: tmp_x + tmp_width - inner_frame_margin * 0.5, tmp_y + tmp_height * ratio_y * (0.5 + index)
|
|
320
320
|
fontSize: fontSize
|
|
321
|
-
anchor: "
|
|
322
|
-
vanchor: "
|
|
321
|
+
anchor: "center"
|
|
322
|
+
vanchor: "center"
|
|
323
323
|
|
|
324
324
|
# Draw title frame
|
|
325
325
|
text:
|
|
@@ -375,47 +375,47 @@ def sheet_generator(paper_size_name, paper_width, paper_height, margin_x, margin
|
|
|
375
375
|
grid_height: paper_height - 2 * margin_y
|
|
376
376
|
|
|
377
377
|
def sheet_A1():
|
|
378
|
-
paper_width =
|
|
379
|
-
paper_height =
|
|
378
|
+
paper_width = to_mils(841)
|
|
379
|
+
paper_height = to_mils(594)
|
|
380
380
|
margin = 400
|
|
381
381
|
|
|
382
382
|
return sheet_generator("A1", paper_width, paper_height, margin, margin,
|
|
383
383
|
range(1, 17), ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L"])
|
|
384
384
|
|
|
385
385
|
def sheet_A2():
|
|
386
|
-
paper_width =
|
|
387
|
-
paper_height =
|
|
386
|
+
paper_width = to_mils(594)
|
|
387
|
+
paper_height = to_mils(420)
|
|
388
388
|
margin = 400
|
|
389
389
|
|
|
390
390
|
return sheet_generator("A2", paper_width, paper_height, margin, margin,
|
|
391
391
|
range(1, 13), ["A", "B", "C", "D", "E", "F", "G", "H"])
|
|
392
392
|
|
|
393
393
|
def sheet_A3():
|
|
394
|
-
paper_width =
|
|
395
|
-
paper_height =
|
|
394
|
+
paper_width = to_mils(420)
|
|
395
|
+
paper_height = to_mils(297)
|
|
396
396
|
margin = 400
|
|
397
397
|
|
|
398
398
|
return sheet_generator("A3", paper_width, paper_height, margin, margin,
|
|
399
399
|
range(1, 9), ["A", "B", "C", "D", "E", "F"])
|
|
400
400
|
|
|
401
401
|
def sheet_A4():
|
|
402
|
-
paper_width =
|
|
403
|
-
paper_height =
|
|
402
|
+
paper_width = to_mils(297)
|
|
403
|
+
paper_height = to_mils(210)
|
|
404
404
|
margin = 400
|
|
405
405
|
|
|
406
406
|
return sheet_generator("A4", paper_width, paper_height, margin, margin,
|
|
407
407
|
range(1, 7), ["A", "B", "C", "D"])
|
|
408
408
|
|
|
409
409
|
def sheet_A5():
|
|
410
|
-
paper_width =
|
|
411
|
-
paper_height =
|
|
410
|
+
paper_width = to_mils(210)
|
|
411
|
+
paper_height = to_mils(148)
|
|
412
412
|
margin = 400
|
|
413
413
|
|
|
414
414
|
return sheet_generator("A5", paper_width, paper_height, margin, margin, range(1, 5), ["A", "B", "C"])
|
|
415
415
|
|
|
416
416
|
def sheet_A6(revision="V1"):
|
|
417
|
-
paper_width =
|
|
418
|
-
paper_height =
|
|
417
|
+
paper_width = to_mils(148)
|
|
418
|
+
paper_height = to_mils(105)
|
|
419
419
|
margin = 400
|
|
420
420
|
|
|
421
421
|
tmp_sheet = sheet_generator("A6", paper_width, paper_height, margin, margin, range(1, 4), ["A", "B"])
|