circuitscript 0.0.18 → 0.0.20
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/__tests__/parseScripts.ts +153 -1
- package/__tests__/renderData/script7.cst +26 -0
- package/__tests__/renderData/script7.cst.svg +1 -0
- package/__tests__/renderData/script8.cst +37 -0
- package/__tests__/renderData/script8.cst.svg +1 -0
- package/__tests__/testParse.ts +6 -2
- package/__tests__/testRender.ts +3 -1
- package/build/src/antlr/CircuitScriptLexer.js +159 -154
- package/build/src/antlr/CircuitScriptParser.js +722 -632
- package/build/src/antlr/CircuitScriptVisitor.js +2 -2
- package/build/src/execute.js +90 -45
- package/build/src/globals.js +7 -5
- package/build/src/objects/ExecutionScope.js +1 -1
- package/build/src/visitor.js +55 -32
- package/examples/example_arduino_uno.cst +312 -303
- package/package.json +1 -1
- package/src/antlr/CircuitScript.g4 +9 -8
- package/src/antlr/CircuitScriptLexer.ts +159 -154
- package/src/antlr/CircuitScriptParser.ts +719 -629
- package/src/antlr/CircuitScriptVisitor.ts +6 -6
- package/src/execute.ts +118 -56
- package/src/globals.ts +5 -3
- package/src/objects/ExecutionScope.ts +1 -1
- package/src/visitor.ts +69 -43
|
@@ -438,4 +438,156 @@ to v5v`,
|
|
|
438
438
|
[ '/NET_2', 'led_with_res_0.res_0.COMP_1_1k', 1 ],
|
|
439
439
|
[ '/NET_2', 'led_with_res_1.led_1.COMP_1_0603', 1 ],
|
|
440
440
|
[ '/NET_2', 'led_with_res_1.res_1.COMP_1_1k', 1 ]
|
|
441
|
-
]);
|
|
441
|
+
]);
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
/**
|
|
446
|
+
Tests the `point` branching keyword
|
|
447
|
+
*/
|
|
448
|
+
export const script14 = new ScriptTest(`
|
|
449
|
+
import lib
|
|
450
|
+
|
|
451
|
+
v5v = supply("5V")
|
|
452
|
+
gnd = dgnd()
|
|
453
|
+
|
|
454
|
+
at v5v
|
|
455
|
+
wire down 20
|
|
456
|
+
add res(360) down
|
|
457
|
+
wire down 20
|
|
458
|
+
|
|
459
|
+
point:
|
|
460
|
+
at v5v
|
|
461
|
+
wire down 20
|
|
462
|
+
add res(360) down
|
|
463
|
+
wire down 20
|
|
464
|
+
|
|
465
|
+
branch:
|
|
466
|
+
wire left 100
|
|
467
|
+
to point
|
|
468
|
+
|
|
469
|
+
wire down 20
|
|
470
|
+
add res(360) down
|
|
471
|
+
wire down 20
|
|
472
|
+
to gnd
|
|
473
|
+
|
|
474
|
+
at point
|
|
475
|
+
wire right 200 down 20
|
|
476
|
+
add res(360) down
|
|
477
|
+
wire down 20
|
|
478
|
+
to gnd
|
|
479
|
+
|
|
480
|
+
wire down 20
|
|
481
|
+
add led("red") down
|
|
482
|
+
wire down 40
|
|
483
|
+
to gnd`, [
|
|
484
|
+
[ '/5V', 'v5v', 1 ],
|
|
485
|
+
[ '/5V', 'v5v:0', 1 ],
|
|
486
|
+
[ '/5V', 'res_0.COMP_1_360', 1 ],
|
|
487
|
+
[ '/5V', 'v5v:1', 1 ],
|
|
488
|
+
[ '/5V', 'res_1.COMP_1_360', 1 ],
|
|
489
|
+
[ '/GND', 'gnd', 1 ],
|
|
490
|
+
[ '/GND', 'gnd:0', 1 ],
|
|
491
|
+
[ '/GND', 'res_2.COMP_1_360', 2 ],
|
|
492
|
+
[ '/GND', 'gnd:1', 1 ],
|
|
493
|
+
[ '/GND', 'res_3.COMP_1_360', 2 ],
|
|
494
|
+
[ '/GND', 'gnd:2', 1 ],
|
|
495
|
+
[ '/GND', 'led_0.COMP_1_0603', 2 ],
|
|
496
|
+
[ '/NET_1', 'res_0.COMP_1_360', 2 ],
|
|
497
|
+
[ '/NET_1', '_point.__.0', 1 ],
|
|
498
|
+
[ '/NET_1', 'res_1.COMP_1_360', 2 ],
|
|
499
|
+
[ '/NET_1', 'res_2.COMP_1_360', 1 ],
|
|
500
|
+
[ '/NET_1', 'res_3.COMP_1_360', 1 ],
|
|
501
|
+
[ '/NET_1', 'led_0.COMP_1_0603', 1 ]
|
|
502
|
+
]);
|
|
503
|
+
|
|
504
|
+
/*
|
|
505
|
+
Test with `paralell` keyword
|
|
506
|
+
*/
|
|
507
|
+
export const script15 = new ScriptTest(`
|
|
508
|
+
import lib
|
|
509
|
+
|
|
510
|
+
v5v = supply("5V")
|
|
511
|
+
gnd = dgnd()
|
|
512
|
+
|
|
513
|
+
at v5v
|
|
514
|
+
wire down 20
|
|
515
|
+
|
|
516
|
+
parallel:
|
|
517
|
+
wire down 20
|
|
518
|
+
add res(1k) down
|
|
519
|
+
wire down 20
|
|
520
|
+
|
|
521
|
+
parallel:
|
|
522
|
+
wire right 60 down 20
|
|
523
|
+
add res(1k) down
|
|
524
|
+
wire auto
|
|
525
|
+
|
|
526
|
+
parallel:
|
|
527
|
+
wire right 120 down 20
|
|
528
|
+
add res(1k) down
|
|
529
|
+
wire auto
|
|
530
|
+
|
|
531
|
+
wire down 20
|
|
532
|
+
to gnd
|
|
533
|
+
`, [
|
|
534
|
+
['/5V', 'v5v', 1],
|
|
535
|
+
['/5V', 'v5v:0', 1],
|
|
536
|
+
['/5V', '_parallel.__.0', 1],
|
|
537
|
+
['/5V', 'res_0.COMP_1_1k', 1],
|
|
538
|
+
['/5V', 'res_1.COMP_1_1k', 1],
|
|
539
|
+
['/5V', 'res_2.COMP_1_1k', 1],
|
|
540
|
+
['/GND', 'gnd', 1],
|
|
541
|
+
['/GND', 'res_0.COMP_1_1k', 2],
|
|
542
|
+
['/GND', '_parallel.__.1', 1],
|
|
543
|
+
['/GND', 'res_1.COMP_1_1k', 2],
|
|
544
|
+
['/GND', 'res_2.COMP_1_1k', 2],
|
|
545
|
+
['/GND', 'gnd:0', 1]
|
|
546
|
+
]);
|
|
547
|
+
|
|
548
|
+
/*
|
|
549
|
+
Test that consecutive blocks with different block type
|
|
550
|
+
are parsed correctly.
|
|
551
|
+
*/
|
|
552
|
+
export const script16 = new ScriptTest(`
|
|
553
|
+
import lib
|
|
554
|
+
|
|
555
|
+
v5v = supply("5V")
|
|
556
|
+
gnd = dgnd()
|
|
557
|
+
|
|
558
|
+
join:
|
|
559
|
+
at v5v
|
|
560
|
+
wire down 20
|
|
561
|
+
add res(1k) down
|
|
562
|
+
wire down 20
|
|
563
|
+
|
|
564
|
+
join:
|
|
565
|
+
at v5v
|
|
566
|
+
wire down 20
|
|
567
|
+
add res(1k) down
|
|
568
|
+
wire left 100
|
|
569
|
+
|
|
570
|
+
point:
|
|
571
|
+
at v5v
|
|
572
|
+
wire right 20
|
|
573
|
+
add res(1k) right
|
|
574
|
+
wire right 20
|
|
575
|
+
to point
|
|
576
|
+
|
|
577
|
+
wire down 20
|
|
578
|
+
to gnd`, [
|
|
579
|
+
[ '/5V', 'v5v', 1 ],
|
|
580
|
+
[ '/5V', 'v5v:0', 1 ],
|
|
581
|
+
[ '/5V', 'res_0.COMP_1_1k', 1 ],
|
|
582
|
+
[ '/5V', 'v5v:1', 1 ],
|
|
583
|
+
[ '/5V', 'res_1.COMP_1_1k', 1 ],
|
|
584
|
+
[ '/5V', 'v5v:2', 1 ],
|
|
585
|
+
[ '/5V', 'res_2.COMP_1_1k', 1 ],
|
|
586
|
+
[ '/GND', 'gnd', 1 ],
|
|
587
|
+
[ '/GND', 'res_0.COMP_1_1k', 2 ],
|
|
588
|
+
[ '/GND', '_join.__.0', 1 ],
|
|
589
|
+
[ '/GND', 'res_1.COMP_1_1k', 2 ],
|
|
590
|
+
[ '/GND', '_point.__.1', 1 ],
|
|
591
|
+
[ '/GND', 'res_2.COMP_1_1k', 2 ],
|
|
592
|
+
[ '/GND', 'gnd:0', 1 ]
|
|
593
|
+
]);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import lib
|
|
2
|
+
|
|
3
|
+
v5v = supply("5V")
|
|
4
|
+
gnd = dgnd()
|
|
5
|
+
|
|
6
|
+
# example with `parallel` keyword
|
|
7
|
+
at v5v
|
|
8
|
+
wire down 20
|
|
9
|
+
|
|
10
|
+
parallel:
|
|
11
|
+
wire down 20
|
|
12
|
+
add res(1k) down
|
|
13
|
+
wire down 20
|
|
14
|
+
|
|
15
|
+
parallel:
|
|
16
|
+
wire right 60 down 20
|
|
17
|
+
add res(1k) down
|
|
18
|
+
wire auto
|
|
19
|
+
|
|
20
|
+
parallel:
|
|
21
|
+
wire right 120 down 20
|
|
22
|
+
add res(1k) down
|
|
23
|
+
wire auto
|
|
24
|
+
|
|
25
|
+
wire down 20
|
|
26
|
+
to gnd
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="210" height="290.5" viewBox="-25 -25.5 210 290.5"><g transform="matrix(1,0,0,1,0,0)"><path d="M -20 -20.5 L -20 260 M 0 -20.5 L 0 260 M 20 -20.5 L 20 260 M 40 -20.5 L 40 260 M 60 -20.5 L 60 260 M 80 -20.5 L 80 260 M 100 -20.5 L 100 260 M 120 -20.5 L 120 260 M 140 -20.5 L 140 260 M 160 -20.5 L 160 260 M 180 -20.5 L 180 260" fill="none" stroke-dasharray="1,19" stroke-width="1" stroke="#aaaaaa"></path></g><g transform="matrix(1,0,0,1,20,30)"><g><path d="M -15 0 L 15 0" stroke-width="1" stroke="#333333" fill="none"></path><path d="M 0 10 L 0 0" stroke-width="2" stroke="#333333"></path><g transform="matrix(1,0,0,1,0,-5)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">5V</tspan></text></g></g></g><g transform="matrix(1,0,0,1,20,60)"><g><path d="M 0 0 L 0 0" stroke-width="2" stroke="#333333"></path></g></g><g transform="matrix(1,0,0,1,20,120)"><g><path d="M 9.999999999999998 -20 L 10.000000000000002 20 L -9.999999999999998 20 L -10.000000000000002 -20 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M -2.4492935982947065e-15 -40 L -1.2246467991473533e-15 -20 M 2.4492935982947065e-15 40 L 1.2246467991473533e-15 20" stroke-width="2" stroke="#333333"></path><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,1.9999999999999987,-22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="end" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,2.0000000000000013,22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">2</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-1,6.123233995736766e-17)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="middle" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1k</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,14.999999999999998,-20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">R1</tspan></text></g></g></g><g transform="matrix(1,0,0,1,20,180)"><g><path d="M 0 0 L 0 0" stroke-width="2" stroke="#333333"></path></g></g><g transform="matrix(1,0,0,1,80,120)"><g><path d="M 9.999999999999998 -20 L 10.000000000000002 20 L -9.999999999999998 20 L -10.000000000000002 -20 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M -2.4492935982947065e-15 -40 L -1.2246467991473533e-15 -20 M 2.4492935982947065e-15 40 L 1.2246467991473533e-15 20" stroke-width="2" stroke="#333333"></path><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,1.9999999999999987,-22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="end" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,2.0000000000000013,22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">2</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-1,6.123233995736766e-17)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="middle" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1k</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,14.999999999999998,-20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">R2</tspan></text></g></g></g><g transform="matrix(1,0,0,1,140,120)"><g><path d="M 9.999999999999998 -20 L 10.000000000000002 20 L -9.999999999999998 20 L -10.000000000000002 -20 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M -2.4492935982947065e-15 -40 L -1.2246467991473533e-15 -20 M 2.4492935982947065e-15 40 L 1.2246467991473533e-15 20" stroke-width="2" stroke="#333333"></path><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,1.9999999999999987,-22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="end" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,2.0000000000000013,22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">2</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-1,6.123233995736766e-17)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="middle" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1k</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,14.999999999999998,-20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">R3</tspan></text></g></g></g><g transform="matrix(1,0,0,1,20,210)"><g><path d="M -10 0 L 10 0 L 0 10 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M 0 -10 L 0 0" stroke-width="2" stroke="#333333"></path><g transform="matrix(1,0,0,1,0,20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">GND</tspan></text></g></g></g><g><line x1="20" y1="40" x2="20" y2="60" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="20" y1="60" x2="20" y2="80" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="20" y1="60" x2="80" y2="60" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="80" y1="60" x2="80" y2="80" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="80" y1="60" x2="140" y2="60" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="140" y1="60" x2="140" y2="80" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><circle r="2.5" cx="2.5" cy="2.5" transform="matrix(1,0,0,1,17.5,57.5)" fill="#008400" stroke="none"></circle><circle r="2.5" cx="2.5" cy="2.5" transform="matrix(1,0,0,1,77.5,57.5)" fill="#008400" stroke="none"></circle><line x1="20" y1="160" x2="20" y2="180" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="80" y1="160" x2="80" y2="180" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="80" y1="180" x2="20" y2="180" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="140" y1="160" x2="140" y2="180" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="140" y1="180" x2="80" y2="180" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="20" y1="180" x2="20" y2="200" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><circle r="2.5" cx="2.5" cy="2.5" transform="matrix(1,0,0,1,17.5,177.5)" fill="#008400" stroke="none"></circle><circle r="2.5" cx="2.5" cy="2.5" transform="matrix(1,0,0,1,77.5,177.5)" fill="#008400" stroke="none"></circle></g><g></g></svg>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Test `point` keyword
|
|
2
|
+
|
|
3
|
+
import lib
|
|
4
|
+
|
|
5
|
+
v5v = supply("5V")
|
|
6
|
+
gnd = dgnd()
|
|
7
|
+
|
|
8
|
+
at v5v
|
|
9
|
+
wire down 20
|
|
10
|
+
add res(360) down
|
|
11
|
+
wire down 20
|
|
12
|
+
|
|
13
|
+
point:
|
|
14
|
+
at v5v
|
|
15
|
+
wire down 20
|
|
16
|
+
add res(360) down
|
|
17
|
+
wire down 20
|
|
18
|
+
|
|
19
|
+
branch:
|
|
20
|
+
wire left 100
|
|
21
|
+
to point
|
|
22
|
+
|
|
23
|
+
wire down 20
|
|
24
|
+
add res(360) down
|
|
25
|
+
wire down 20
|
|
26
|
+
to gnd
|
|
27
|
+
|
|
28
|
+
at point
|
|
29
|
+
wire right 200 down 20
|
|
30
|
+
add res(360) down
|
|
31
|
+
wire down 20
|
|
32
|
+
to gnd
|
|
33
|
+
|
|
34
|
+
wire down 20
|
|
35
|
+
add led("red") down
|
|
36
|
+
wire down 40
|
|
37
|
+
to gnd
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.dev/svgjs" width="290" height="370.5" viewBox="-25 -25.5 290 370.5"><g transform="matrix(1,0,0,1,0,0)"><path d="M -20 -20.5 L -20 340 M 0 -20.5 L 0 340 M 20 -20.5 L 20 340 M 40 -20.5 L 40 340 M 60 -20.5 L 60 340 M 80 -20.5 L 80 340 M 100 -20.5 L 100 340 M 120 -20.5 L 120 340 M 140 -20.5 L 140 340 M 160 -20.5 L 160 340 M 180 -20.5 L 180 340 M 200 -20.5 L 200 340 M 220 -20.5 L 220 340 M 240 -20.5 L 240 340 M 260 -20.5 L 260 340" fill="none" stroke-dasharray="1,19" stroke-width="1" stroke="#aaaaaa"></path></g><g transform="matrix(1,0,0,1,20,30)"><g><path d="M -15 0 L 15 0" stroke-width="1" stroke="#333333" fill="none"></path><path d="M 0 10 L 0 0" stroke-width="2" stroke="#333333"></path><g transform="matrix(1,0,0,1,0,-5)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">5V</tspan></text></g></g></g><g transform="matrix(1,0,0,1,20,100)"><g><path d="M 9.999999999999998 -20 L 10.000000000000002 20 L -9.999999999999998 20 L -10.000000000000002 -20 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M -2.4492935982947065e-15 -40 L -1.2246467991473533e-15 -20 M 2.4492935982947065e-15 40 L 1.2246467991473533e-15 20" stroke-width="2" stroke="#333333"></path><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,1.9999999999999987,-22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="end" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,2.0000000000000013,22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">2</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-1,6.123233995736766e-17)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="middle" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">360</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,14.999999999999998,-20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">R1</tspan></text></g></g></g><g transform="matrix(1,0,0,1,20,160)"><g><path d="M 0 0 L 0 0" stroke-width="2" stroke="#333333"></path></g></g><g transform="matrix(1,0,0,1,120,30)"><g><path d="M -15 0 L 15 0" stroke-width="1" stroke="#333333" fill="none"></path><path d="M 0 10 L 0 0" stroke-width="2" stroke="#333333"></path><g transform="matrix(1,0,0,1,0,-5)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">5V</tspan></text></g></g></g><g transform="matrix(1,0,0,1,120,100)"><g><path d="M 9.999999999999998 -20 L 10.000000000000002 20 L -9.999999999999998 20 L -10.000000000000002 -20 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M -2.4492935982947065e-15 -40 L -1.2246467991473533e-15 -20 M 2.4492935982947065e-15 40 L 1.2246467991473533e-15 20" stroke-width="2" stroke="#333333"></path><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,1.9999999999999987,-22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="end" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,2.0000000000000013,22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">2</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-1,6.123233995736766e-17)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="middle" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">360</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,14.999999999999998,-20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">R2</tspan></text></g></g></g><g transform="matrix(1,0,0,1,120,220)"><g><path d="M 9.999999999999998 -20 L 10.000000000000002 20 L -9.999999999999998 20 L -10.000000000000002 -20 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M -2.4492935982947065e-15 -40 L -1.2246467991473533e-15 -20 M 2.4492935982947065e-15 40 L 1.2246467991473533e-15 20" stroke-width="2" stroke="#333333"></path><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,1.9999999999999987,-22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="end" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,2.0000000000000013,22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">2</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-1,6.123233995736766e-17)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="middle" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">360</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,14.999999999999998,-20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">R3</tspan></text></g></g></g><g transform="matrix(1,0,0,1,120,290)"><g><path d="M -10 0 L 10 0 L 0 10 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M 0 -10 L 0 0" stroke-width="2" stroke="#333333"></path><g transform="matrix(1,0,0,1,0,20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">GND</tspan></text></g></g></g><g transform="matrix(1,0,0,1,220,220)"><g><path d="M 9.999999999999998 -20 L 10.000000000000002 20 L -9.999999999999998 20 L -10.000000000000002 -20 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M -2.4492935982947065e-15 -40 L -1.2246467991473533e-15 -20 M 2.4492935982947065e-15 40 L 1.2246467991473533e-15 20" stroke-width="2" stroke="#333333"></path><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,1.9999999999999987,-22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="end" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,2.0000000000000013,22)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">2</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-1,6.123233995736766e-17)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="middle" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">360</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,14.999999999999998,-20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">R4</tspan></text></g></g></g><g transform="matrix(1,0,0,1,220,290)"><g><path d="M -10 0 L 10 0 L 0 10 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M 0 -10 L 0 0" stroke-width="2" stroke="#333333"></path><g transform="matrix(1,0,0,1,0,20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">GND</tspan></text></g></g></g><g transform="matrix(1,0,0,1,20,210)"><g><path d="M -10 -10 L 10 -10 L 6.123233995736766e-16 10 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M 10 10 L -10 10" stroke-width="1" stroke="#333333" fill="none"></path><path d="M -8 4.898587196589413e-16 L -18 5.000000000000001" stroke-width="1" stroke="#333333" fill="none"></path><path d="M -8 3.0000000000000004 L -18 8.000000000000002" stroke-width="1" stroke="#333333" fill="none"></path><path d="M -1.83697019872103e-15 -30 L -6.123233995736766e-16 -10 M 1.83697019872103e-15 30 L 6.123233995736766e-16 10" stroke-width="2" stroke="#333333"></path><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,1.9999999999999993,-12)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="end" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,2.000000000000001,12)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="8" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">2</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-4.999999999999999,15)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="hanging" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">D1</tspan></text></g><g transform="matrix(6.123233995736766e-17,1,-1,6.123233995736766e-17,-25,15.000000000000002)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="start" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">red</tspan></text></g></g></g><g transform="matrix(1,0,0,1,20,290)"><g><path d="M -10 0 L 10 0 L 0 10 Z" stroke-width="1" stroke="#333333" fill="#ffffff"></path><path d="M 0 -10 L 0 0" stroke-width="2" stroke="#333333"></path><g transform="matrix(1,0,0,1,0,20)"><text fill="#333333" font-family="Open Sans-Regular, Arial" font-size="10" text-anchor="middle" dominant-baseline="text-top" font-weight="regular" transform="matrix(1,0,0,1,0,0)" svgjs:data="{"leading":"1.3"}"><tspan dy="0" x="0" svgjs:data="{"newLined":true}">GND</tspan></text></g></g></g><g><line x1="20" y1="40" x2="20" y2="60" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="120" y1="40" x2="120" y2="60" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="20" y1="140" x2="20" y2="160" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="120" y1="140" x2="120" y2="160" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="120" y1="160" x2="20" y2="160" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="120" y1="160" x2="120" y2="180" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="120" y1="160" x2="220" y2="160" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="220" y1="160" x2="220" y2="180" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="20" y1="160" x2="20" y2="180" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><circle r="2.5" cx="2.5" cy="2.5" transform="matrix(1,0,0,1,17.5,157.5)" fill="#008400" stroke="none"></circle><circle r="2.5" cx="2.5" cy="2.5" transform="matrix(1,0,0,1,117.5,157.5)" fill="#008400" stroke="none"></circle><line x1="120" y1="260" x2="120" y2="280" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="220" y1="260" x2="220" y2="280" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line><line x1="20" y1="240" x2="20" y2="280" stroke-linecap="square" stroke-width="1" stroke="#008400" fill="none"></line></g><g></g></svg>
|
package/__tests__/testParse.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { findItem, findItemByRefDes, runScript } from './helpers.js';
|
|
3
|
-
import { script1, script10, script11, script12, script13,
|
|
3
|
+
import { script1, script10, script11, script12, script13, script14, script15, script16, script2,
|
|
4
|
+
script3, script6, script7, script8, script9 } from './parseScripts.js';
|
|
4
5
|
|
|
5
6
|
describe('test parsing', () => {
|
|
6
7
|
|
|
@@ -15,7 +16,10 @@ describe('test parsing', () => {
|
|
|
15
16
|
["assignment in at/to/add statement", script10],
|
|
16
17
|
["net namespace local and global", script11],
|
|
17
18
|
["create component with __is_net", script12],
|
|
18
|
-
["corret nets after function call", script13],
|
|
19
|
+
["corret nets after function call and also `join` keyword", script13],
|
|
20
|
+
["path with 'point' keyword", script14],
|
|
21
|
+
["path with 'parallel' keyword", script15],
|
|
22
|
+
["consecutive blocks with 'join' then 'point'", script16]
|
|
19
23
|
|
|
20
24
|
])('parse script - %s', async (description, scriptTest) => {
|
|
21
25
|
// Test only parsing, does not check the correctness of the
|
package/__tests__/testRender.ts
CHANGED
|
@@ -14,7 +14,9 @@ describe('Render tests', () => {
|
|
|
14
14
|
['simple frame', 'script3.cst'],
|
|
15
15
|
['drawing functions for graphics', 'script4.cst'],
|
|
16
16
|
['drawing 180 deg flipped components', 'script5.cst'],
|
|
17
|
-
['join command', 'script6.cst']
|
|
17
|
+
['join command', 'script6.cst'],
|
|
18
|
+
['parallel command', 'script7.cst'],
|
|
19
|
+
['point block command', 'script8.cst']
|
|
18
20
|
|
|
19
21
|
])('render - %s (%s)', async (title, scriptPath) => {
|
|
20
22
|
|