circuitscript 0.0.21 → 0.0.24
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/antlr/CircuitScriptLexer.js +288 -0
- package/dist/cjs/antlr/CircuitScriptParser.js +4905 -0
- package/dist/cjs/antlr/CircuitScriptVisitor.js +6 -0
- package/{src/draw_symbols.ts → dist/cjs/draw_symbols.js} +303 -614
- package/dist/cjs/execute.js +780 -0
- package/{src/export.ts → dist/cjs/export.js} +34 -56
- package/dist/cjs/fonts.js +4 -0
- package/dist/cjs/geometry.js +430 -0
- package/dist/cjs/globals.js +60 -0
- package/dist/cjs/helpers.js +99 -0
- package/dist/cjs/index.js +29 -0
- package/{src/layout.ts → dist/cjs/layout.js} +413 -1002
- package/dist/cjs/lexer.js +114 -0
- package/dist/cjs/logger.js +17 -0
- package/dist/cjs/main.js +87 -0
- package/dist/cjs/objects/ClassComponent.js +142 -0
- package/dist/cjs/objects/ExecutionScope.js +134 -0
- package/dist/cjs/objects/Frame.js +22 -0
- package/{src/objects/Net.ts → dist/cjs/objects/Net.js} +9 -24
- package/dist/cjs/objects/ParamDefinition.js +42 -0
- package/dist/cjs/objects/PinDefinition.js +31 -0
- package/dist/cjs/objects/PinTypes.js +11 -0
- package/dist/cjs/objects/Wire.js +9 -0
- package/dist/cjs/objects/types.js +9 -0
- package/dist/cjs/parser.js +299 -0
- package/dist/cjs/regenerate-tests.js +23 -0
- package/dist/cjs/render.js +155 -0
- package/{src/server.ts → dist/cjs/server.js} +15 -21
- package/dist/cjs/sizing.js +105 -0
- package/{src/utils.ts → dist/cjs/utils.js} +25 -35
- package/{src/visitor.ts → dist/cjs/visitor.js} +392 -948
- package/{build/src/antlr/CircuitScriptLexer.js → dist/esm/antlr/CircuitScriptLexer.mjs} +90 -91
- package/{build/src/antlr/CircuitScriptParser.js → dist/esm/antlr/CircuitScriptParser.mjs} +138 -136
- package/{build/src/draw_symbols.js → dist/esm/draw_symbols.mjs} +11 -11
- package/{build/src/execute.js → dist/esm/execute.mjs} +9 -8
- package/{build/src/export.js → dist/esm/export.mjs} +2 -2
- package/{build/src/geometry.js → dist/esm/geometry.mjs} +3 -7
- package/{build/src/helpers.js → dist/esm/helpers.mjs} +27 -7
- package/dist/esm/index.mjs +13 -0
- package/{build/src/layout.js → dist/esm/layout.mjs} +11 -11
- package/{build/src/lexer.js → dist/esm/lexer.mjs} +2 -2
- package/{build/src/main.js → dist/esm/main.mjs} +5 -5
- package/{build/src/objects/ClassComponent.js → dist/esm/objects/ClassComponent.mjs} +3 -3
- package/{build/src/objects/PinDefinition.js → dist/esm/objects/PinDefinition.mjs} +1 -1
- package/dist/esm/parser.mjs +269 -0
- package/{build/src/regenerate-tests.js → dist/esm/regenerate-tests.mjs} +1 -1
- package/{build/src/render.js → dist/esm/render.mjs} +7 -24
- package/{build/src/sizing.js → dist/esm/sizing.mjs} +22 -8
- package/{build/src/visitor.js → dist/esm/visitor.mjs} +10 -29
- package/dist/types/antlr/CircuitScriptLexer.d.ts +71 -0
- package/dist/types/antlr/CircuitScriptParser.d.ts +675 -0
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +115 -0
- package/dist/types/draw_symbols.d.ts +162 -0
- package/dist/types/execute.d.ts +85 -0
- package/dist/types/export.d.ts +2 -0
- package/dist/types/fonts.d.ts +1 -0
- package/dist/types/geometry.d.ts +84 -0
- package/dist/types/globals.d.ts +50 -0
- package/dist/types/helpers.d.ts +9 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/layout.d.ts +147 -0
- package/dist/types/lexer.d.ts +19 -0
- package/dist/types/logger.d.ts +6 -0
- package/dist/types/main.d.ts +2 -0
- package/dist/types/objects/ClassComponent.d.ts +40 -0
- package/dist/types/objects/ExecutionScope.d.ts +64 -0
- package/dist/types/objects/Frame.d.ts +15 -0
- package/dist/types/objects/Net.d.ts +10 -0
- package/dist/types/objects/ParamDefinition.d.ts +20 -0
- package/dist/types/objects/PinDefinition.d.ts +24 -0
- package/dist/types/objects/PinTypes.d.ts +7 -0
- package/dist/types/objects/Wire.d.ts +11 -0
- package/dist/types/objects/types.d.ts +49 -0
- package/dist/types/parser.d.ts +38 -0
- package/dist/types/regenerate-tests.d.ts +1 -0
- package/dist/types/render.d.ts +10 -0
- package/dist/types/server.d.ts +1 -0
- package/dist/types/sizing.d.ts +15 -0
- package/dist/types/utils.d.ts +19 -0
- package/dist/types/visitor.d.ts +135 -0
- package/package.json +30 -12
- package/.editorconfig +0 -15
- package/.eslintignore +0 -1
- package/.eslintrc.json +0 -27
- package/.gitlab-ci.yml +0 -81
- package/.prettierignore +0 -8
- package/.prettierrc +0 -16
- package/__tests__/expectedResults.ts +0 -657
- package/__tests__/helpers.ts +0 -82
- package/__tests__/parseScripts.ts +0 -593
- package/__tests__/renderData/script1.cst +0 -58
- package/__tests__/renderData/script1.cst.svg +0 -1
- package/__tests__/renderData/script2.cst +0 -16
- package/__tests__/renderData/script2.cst.svg +0 -1
- package/__tests__/renderData/script3.cst +0 -30
- package/__tests__/renderData/script3.cst.svg +0 -1
- package/__tests__/renderData/script4.cst +0 -54
- package/__tests__/renderData/script4.cst.svg +0 -1
- package/__tests__/renderData/script5.cst +0 -23
- package/__tests__/renderData/script5.cst.svg +0 -1
- package/__tests__/renderData/script6.cst +0 -28
- package/__tests__/renderData/script6.cst.svg +0 -1
- package/__tests__/renderData/script7.cst +0 -26
- package/__tests__/renderData/script7.cst.svg +0 -1
- package/__tests__/renderData/script8.cst +0 -37
- package/__tests__/renderData/script8.cst.svg +0 -1
- package/__tests__/testCLI.ts +0 -68
- package/__tests__/testMathOps.ts +0 -36
- package/__tests__/testMergeWires.ts +0 -141
- package/__tests__/testParse.ts +0 -263
- package/__tests__/testRender.ts +0 -38
- package/build/src/parser.js +0 -69
- package/documentation.md +0 -238
- package/examples/example_arduino_uno.cst +0 -1146
- package/examples/example_garden_pump.cst +0 -567
- package/examples/lib.cst +0 -185
- package/fonts/Inter-Bold.ttf +0 -0
- package/fonts/Inter-Regular.ttf +0 -0
- package/fonts/OpenSans-Regular.ttf +0 -0
- package/fonts/Roboto-Regular.ttf +0 -0
- package/jest.config.js +0 -23
- package/libs/lib.cst +0 -185
- package/refresh.html +0 -42
- package/server.cjs +0 -50
- package/src/antlr/CircuitScript.g4 +0 -209
- package/src/antlr/CircuitScriptLexer.ts +0 -317
- package/src/antlr/CircuitScriptParser.ts +0 -4979
- package/src/antlr/CircuitScriptVisitor.ts +0 -420
- package/src/execute.ts +0 -1227
- package/src/fonts.ts +0 -1
- package/src/geometry.ts +0 -638
- package/src/globals.ts +0 -67
- package/src/helpers.ts +0 -114
- package/src/lexer.ts +0 -151
- package/src/logger.ts +0 -17
- package/src/main.ts +0 -105
- package/src/objects/ClassComponent.ts +0 -223
- package/src/objects/ExecutionScope.ts +0 -201
- package/src/objects/Frame.ts +0 -20
- package/src/objects/ParamDefinition.ts +0 -49
- package/src/objects/PinDefinition.ts +0 -49
- package/src/objects/PinTypes.ts +0 -7
- package/src/objects/Wire.ts +0 -19
- package/src/objects/types.ts +0 -66
- package/src/parser.ts +0 -106
- package/src/regenerate-tests.ts +0 -25
- package/src/render.ts +0 -260
- package/src/sizing.ts +0 -96
- package/tsconfig.json +0 -26
- package/tsconfig.release.json +0 -8
- /package/{build/src/antlr/CircuitScriptVisitor.js → dist/esm/antlr/CircuitScriptVisitor.mjs} +0 -0
- /package/{build/src/fonts.js → dist/esm/fonts.mjs} +0 -0
- /package/{build/src/globals.js → dist/esm/globals.mjs} +0 -0
- /package/{build/src/logger.js → dist/esm/logger.mjs} +0 -0
- /package/{build/src/objects/ExecutionScope.js → dist/esm/objects/ExecutionScope.mjs} +0 -0
- /package/{build/src/objects/Frame.js → dist/esm/objects/Frame.mjs} +0 -0
- /package/{build/src/objects/Net.js → dist/esm/objects/Net.mjs} +0 -0
- /package/{build/src/objects/ParamDefinition.js → dist/esm/objects/ParamDefinition.mjs} +0 -0
- /package/{build/src/objects/PinTypes.js → dist/esm/objects/PinTypes.mjs} +0 -0
- /package/{build/src/objects/Wire.js → dist/esm/objects/Wire.mjs} +0 -0
- /package/{build/src/objects/types.js → dist/esm/objects/types.mjs} +0 -0
- /package/{build/src/server.js → dist/esm/server.mjs} +0 -0
- /package/{build/src/utils.js → dist/esm/utils.mjs} +0 -0
package/examples/lib.cst
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
// Circuitscript default lib
|
|
2
|
-
|
|
3
|
-
def net(net_name):
|
|
4
|
-
return create component:
|
|
5
|
-
pins: 1
|
|
6
|
-
display: create graphic:
|
|
7
|
-
hline: -15, 0, 30
|
|
8
|
-
vpin: 1, 0, 10, -10, display_pin_id=0
|
|
9
|
-
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
10
|
-
type: "net"
|
|
11
|
-
params:
|
|
12
|
-
__is_net: 1
|
|
13
|
-
net_name: net_name
|
|
14
|
-
priority: 10
|
|
15
|
-
|
|
16
|
-
def supply(net_name):
|
|
17
|
-
return create component:
|
|
18
|
-
pins: 1
|
|
19
|
-
display: create graphic:
|
|
20
|
-
hline: -15, 0, 30
|
|
21
|
-
vpin: 1, 0, 10, -10, display_pin_id=0
|
|
22
|
-
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
23
|
-
type: "net"
|
|
24
|
-
params:
|
|
25
|
-
__is_net: 1
|
|
26
|
-
net_name: net_name
|
|
27
|
-
priority: 20
|
|
28
|
-
|
|
29
|
-
def label(value):
|
|
30
|
-
return create component:
|
|
31
|
-
pins: 1
|
|
32
|
-
display: create graphic:
|
|
33
|
-
label: "value", 0, -2, "?", fontSize=10, anchor="left"
|
|
34
|
-
pin: 1, 0, 0, 0, 0, display_pin_id=0
|
|
35
|
-
type: "label"
|
|
36
|
-
params:
|
|
37
|
-
__is_net: 1
|
|
38
|
-
net_name: value
|
|
39
|
-
value: value
|
|
40
|
-
priority: 5
|
|
41
|
-
|
|
42
|
-
def res(value):
|
|
43
|
-
width = 40
|
|
44
|
-
height = 20
|
|
45
|
-
|
|
46
|
-
return create component:
|
|
47
|
-
pins: 2
|
|
48
|
-
display: create graphic:
|
|
49
|
-
rect: 0, 0, width, height
|
|
50
|
-
hpin: 1, -width/2 - 20, 0, 20
|
|
51
|
-
hpin: 2, width/2 + 20, 0, -20
|
|
52
|
-
label: ("value", 0, 1, value, fontSize=10, anchor="middle", vanchor="middle")
|
|
53
|
-
label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
|
|
54
|
-
type: "res"
|
|
55
|
-
params:
|
|
56
|
-
value: value
|
|
57
|
-
size: "0402"
|
|
58
|
-
footprint: "Resistor_SMD:R_0402_1005Metric"
|
|
59
|
-
|
|
60
|
-
def cap(value):
|
|
61
|
-
width = 20
|
|
62
|
-
height = 40
|
|
63
|
-
|
|
64
|
-
return create component:
|
|
65
|
-
pins: 2
|
|
66
|
-
display: create graphic:
|
|
67
|
-
hline: -width/2, -3, width
|
|
68
|
-
hline: -width/2, 3, width
|
|
69
|
-
vpin: 1, 0, -height/2, 20-3
|
|
70
|
-
vpin: 2, 0, height/2, -20+3
|
|
71
|
-
label: "refdes", width/2+2, 0, "?", fontSize = 10, anchor="left"
|
|
72
|
-
label: "value", width/2+2, 5, value, fontSize = 10, anchor = "left", vanchor="top"
|
|
73
|
-
type: "cap"
|
|
74
|
-
params:
|
|
75
|
-
value: value
|
|
76
|
-
size: "0402"
|
|
77
|
-
footprint: "Capacitor_SMD:C_0402_1005Metric"
|
|
78
|
-
|
|
79
|
-
def ind(value):
|
|
80
|
-
width = 40
|
|
81
|
-
height = 20
|
|
82
|
-
|
|
83
|
-
return create component:
|
|
84
|
-
pins: 2
|
|
85
|
-
type: "ind"
|
|
86
|
-
display: create graphic:
|
|
87
|
-
arc: -15, 0, 5, 180, 360
|
|
88
|
-
arc: -5, 0, 5, 180, 360
|
|
89
|
-
arc: 5, 0, 5, 180, 360
|
|
90
|
-
arc: 15, 0, 5, 180, 360
|
|
91
|
-
hpin: 1, -width/2 - 20, 0, 20
|
|
92
|
-
hpin: 2, width/2 + 20, 0, -20
|
|
93
|
-
label: ("value", 0, 10, value, fontSize=10, anchor="middle", vanchor="middle")
|
|
94
|
-
label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
|
|
95
|
-
params:
|
|
96
|
-
value: value
|
|
97
|
-
|
|
98
|
-
def diode():
|
|
99
|
-
width = 20
|
|
100
|
-
height = 20
|
|
101
|
-
|
|
102
|
-
# Diode is drawn horizontally
|
|
103
|
-
# -|>|-
|
|
104
|
-
return create component:
|
|
105
|
-
pins: 2
|
|
106
|
-
type: "diode"
|
|
107
|
-
display: create graphic:
|
|
108
|
-
triangle: -width/2, 0, width/2, 0, height
|
|
109
|
-
vline: width/2, -height/2, height
|
|
110
|
-
hpin: 1, -width/2-20, 0, 20 # anode
|
|
111
|
-
hpin: 2, width/2 + 20, 0, -20 # cathode
|
|
112
|
-
label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
|
|
113
|
-
|
|
114
|
-
def led(color):
|
|
115
|
-
width = 20
|
|
116
|
-
height = 20
|
|
117
|
-
|
|
118
|
-
return create component:
|
|
119
|
-
pins:
|
|
120
|
-
1: "cathode"
|
|
121
|
-
2: "anode"
|
|
122
|
-
type: "diode"
|
|
123
|
-
display: create graphic:
|
|
124
|
-
triangle: -width/2, 0, width/2, 0, height
|
|
125
|
-
vline: width/2, -height/2, height
|
|
126
|
-
path: ("M", 0, 8, "L", 5, 18,
|
|
127
|
-
"M", 3, 8, "L", 8, 18)
|
|
128
|
-
hpin: 1, -width/2-20, 0, 20 # anode
|
|
129
|
-
hpin: 2, width/2 + 20, 0, -20 # cathode
|
|
130
|
-
label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
|
|
131
|
-
label: "color", width/2 + 5, 25, color
|
|
132
|
-
params:
|
|
133
|
-
size: "0603"
|
|
134
|
-
footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def cgnd():
|
|
138
|
-
net_name = "gnd"
|
|
139
|
-
return create component:
|
|
140
|
-
pins: 1
|
|
141
|
-
display: create graphic:
|
|
142
|
-
hline: -15, 0, 30
|
|
143
|
-
hline: -10, 5, 20
|
|
144
|
-
hline: -5, 10, 10
|
|
145
|
-
vpin: 1, 0, -10, 10, display_pin_id=0
|
|
146
|
-
label: "net_name", 0, 22, net_name, fontSize=10, anchor="middle"
|
|
147
|
-
type: "net"
|
|
148
|
-
params:
|
|
149
|
-
__is_net: 1
|
|
150
|
-
net_name: net_name
|
|
151
|
-
priority: 100
|
|
152
|
-
|
|
153
|
-
def dgnd():
|
|
154
|
-
height = 10
|
|
155
|
-
width = 20
|
|
156
|
-
|
|
157
|
-
net_name = "GND"
|
|
158
|
-
return create component:
|
|
159
|
-
pins: 1
|
|
160
|
-
display: create graphic:
|
|
161
|
-
triangle: 0, 0, 0, height, width
|
|
162
|
-
vpin: 1, 0, -10, 10, display_pin_id=0
|
|
163
|
-
label: "net_name", 0, height + 10, net_name, fontSize=10, anchor="middle"
|
|
164
|
-
type: "net"
|
|
165
|
-
params:
|
|
166
|
-
__is_net: 1
|
|
167
|
-
net_name: net_name
|
|
168
|
-
priority: 100
|
|
169
|
-
|
|
170
|
-
def marker_point():
|
|
171
|
-
return create component:
|
|
172
|
-
pins: 1
|
|
173
|
-
display: create graphic:
|
|
174
|
-
hline: -5, 0, 10
|
|
175
|
-
vline: 0, -5, 10
|
|
176
|
-
pin: 1, 0, 0, 0, 0, display_pin_id=0
|
|
177
|
-
type: "net"
|
|
178
|
-
|
|
179
|
-
def arrow_point():
|
|
180
|
-
return create component:
|
|
181
|
-
pins: 1
|
|
182
|
-
display: create graphic:
|
|
183
|
-
path: ("M", 15, -5, "L", 20, 0, "L", 15, 5)
|
|
184
|
-
hpin: 1, 0, 0, 20
|
|
185
|
-
type: "net"
|
package/fonts/Inter-Bold.ttf
DELETED
|
Binary file
|
package/fonts/Inter-Regular.ttf
DELETED
|
Binary file
|
|
Binary file
|
package/fonts/Roboto-Regular.ttf
DELETED
|
Binary file
|
package/jest.config.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
testEnvironment: 'node',
|
|
3
|
-
preset: 'ts-jest/presets/default-esm',
|
|
4
|
-
transform: {
|
|
5
|
-
'^.+\\.m?[tj]s?$': ['ts-jest', {
|
|
6
|
-
useESM: true,
|
|
7
|
-
diagnostics: false
|
|
8
|
-
}],
|
|
9
|
-
},
|
|
10
|
-
moduleNameMapper: {
|
|
11
|
-
'^(\\.{1,2}/.*)\\.(m)?js$': '$1',
|
|
12
|
-
},
|
|
13
|
-
testMatch: [
|
|
14
|
-
"<rootDir>/__tests__/test**.(ts|tsx)",
|
|
15
|
-
],
|
|
16
|
-
coverageDirectory: 'coverage',
|
|
17
|
-
collectCoverageFrom: [
|
|
18
|
-
'src/**/*.ts',
|
|
19
|
-
'src/**/*.mts',
|
|
20
|
-
'!src/**/*.d.ts',
|
|
21
|
-
'!src/**/*.d.mts',
|
|
22
|
-
],
|
|
23
|
-
};
|
package/libs/lib.cst
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
// Circuitscript default lib
|
|
2
|
-
|
|
3
|
-
def net(net_name):
|
|
4
|
-
return create component:
|
|
5
|
-
pins: 1
|
|
6
|
-
display: create graphic:
|
|
7
|
-
hline: -15, 0, 30
|
|
8
|
-
vpin: 1, 0, 10, -10, display_pin_id=0
|
|
9
|
-
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
10
|
-
type: "net"
|
|
11
|
-
params:
|
|
12
|
-
__is_net: 1
|
|
13
|
-
net_name: net_name
|
|
14
|
-
priority: 10
|
|
15
|
-
|
|
16
|
-
def supply(net_name):
|
|
17
|
-
return create component:
|
|
18
|
-
pins: 1
|
|
19
|
-
display: create graphic:
|
|
20
|
-
hline: -15, 0, 30
|
|
21
|
-
vpin: 1, 0, 10, -10, display_pin_id=0
|
|
22
|
-
label: "net_name", 0, -5, net_name, fontSize=10, anchor="middle"
|
|
23
|
-
type: "net"
|
|
24
|
-
params:
|
|
25
|
-
__is_net: 1
|
|
26
|
-
net_name: net_name
|
|
27
|
-
priority: 20
|
|
28
|
-
|
|
29
|
-
def label(value):
|
|
30
|
-
return create component:
|
|
31
|
-
pins: 1
|
|
32
|
-
display: create graphic:
|
|
33
|
-
label: "value", 0, -2, "?", fontSize=10, anchor="left"
|
|
34
|
-
pin: 1, 0, 0, 0, 0, display_pin_id=0
|
|
35
|
-
type: "label"
|
|
36
|
-
params:
|
|
37
|
-
__is_net: 1
|
|
38
|
-
net_name: value
|
|
39
|
-
value: value
|
|
40
|
-
priority: 5
|
|
41
|
-
|
|
42
|
-
def res(value):
|
|
43
|
-
width = 40
|
|
44
|
-
height = 20
|
|
45
|
-
|
|
46
|
-
return create component:
|
|
47
|
-
pins: 2
|
|
48
|
-
display: create graphic:
|
|
49
|
-
rect: 0, 0, width, height
|
|
50
|
-
hpin: 1, -width/2 - 20, 0, 20
|
|
51
|
-
hpin: 2, width/2 + 20, 0, -20
|
|
52
|
-
label: ("value", 0, 1, value, fontSize=10, anchor="middle", vanchor="middle")
|
|
53
|
-
label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
|
|
54
|
-
type: "res"
|
|
55
|
-
params:
|
|
56
|
-
value: value
|
|
57
|
-
size: "0402"
|
|
58
|
-
footprint: "Resistor_SMD:R_0402_1005Metric"
|
|
59
|
-
|
|
60
|
-
def cap(value):
|
|
61
|
-
width = 20
|
|
62
|
-
height = 40
|
|
63
|
-
|
|
64
|
-
return create component:
|
|
65
|
-
pins: 2
|
|
66
|
-
display: create graphic:
|
|
67
|
-
hline: -width/2, -3, width
|
|
68
|
-
hline: -width/2, 3, width
|
|
69
|
-
vpin: 1, 0, -height/2, 20-3
|
|
70
|
-
vpin: 2, 0, height/2, -20+3
|
|
71
|
-
label: "refdes", width/2+2, 0, "?", fontSize = 10, anchor="left"
|
|
72
|
-
label: "value", width/2+2, 5, value, fontSize = 10, anchor = "left", vanchor="top"
|
|
73
|
-
type: "cap"
|
|
74
|
-
params:
|
|
75
|
-
value: value
|
|
76
|
-
size: "0402"
|
|
77
|
-
footprint: "Capacitor_SMD:C_0402_1005Metric"
|
|
78
|
-
|
|
79
|
-
def ind(value):
|
|
80
|
-
width = 40
|
|
81
|
-
height = 20
|
|
82
|
-
|
|
83
|
-
return create component:
|
|
84
|
-
pins: 2
|
|
85
|
-
type: "ind"
|
|
86
|
-
display: create graphic:
|
|
87
|
-
arc: -15, 0, 5, 180, 360
|
|
88
|
-
arc: -5, 0, 5, 180, 360
|
|
89
|
-
arc: 5, 0, 5, 180, 360
|
|
90
|
-
arc: 15, 0, 5, 180, 360
|
|
91
|
-
hpin: 1, -width/2 - 20, 0, 20
|
|
92
|
-
hpin: 2, width/2 + 20, 0, -20
|
|
93
|
-
label: ("value", 0, 10, value, fontSize=10, anchor="middle", vanchor="middle")
|
|
94
|
-
label: ("refdes", -width/2, -height/2 -5 , "?", fontSize=10, anchor="left")
|
|
95
|
-
params:
|
|
96
|
-
value: value
|
|
97
|
-
|
|
98
|
-
def diode():
|
|
99
|
-
width = 20
|
|
100
|
-
height = 20
|
|
101
|
-
|
|
102
|
-
# Diode is drawn horizontally
|
|
103
|
-
# -|>|-
|
|
104
|
-
return create component:
|
|
105
|
-
pins: 2
|
|
106
|
-
type: "diode"
|
|
107
|
-
display: create graphic:
|
|
108
|
-
triangle: -width/2, 0, width/2, 0, height
|
|
109
|
-
vline: width/2, -height/2, height
|
|
110
|
-
hpin: 1, -width/2-20, 0, 20 # anode
|
|
111
|
-
hpin: 2, width/2 + 20, 0, -20 # cathode
|
|
112
|
-
label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
|
|
113
|
-
|
|
114
|
-
def led(color):
|
|
115
|
-
width = 20
|
|
116
|
-
height = 20
|
|
117
|
-
|
|
118
|
-
return create component:
|
|
119
|
-
pins:
|
|
120
|
-
1: "cathode"
|
|
121
|
-
2: "anode"
|
|
122
|
-
type: "diode"
|
|
123
|
-
display: create graphic:
|
|
124
|
-
triangle: -width/2, 0, width/2, 0, height
|
|
125
|
-
vline: width/2, -height/2, height
|
|
126
|
-
path: ("M", 0, 8, "L", 5, 18,
|
|
127
|
-
"M", 3, 8, "L", 8, 18)
|
|
128
|
-
hpin: 1, -width/2-20, 0, 20 # anode
|
|
129
|
-
hpin: 2, width/2 + 20, 0, -20 # cathode
|
|
130
|
-
label: "refdes", width/2 + 5, 5, "?", fontSize=10, anchor="left", vanchor="top"
|
|
131
|
-
label: "color", width/2 + 5, 25, color
|
|
132
|
-
params:
|
|
133
|
-
size: "0603"
|
|
134
|
-
footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
def cgnd():
|
|
138
|
-
net_name = "gnd"
|
|
139
|
-
return create component:
|
|
140
|
-
pins: 1
|
|
141
|
-
display: create graphic:
|
|
142
|
-
hline: -15, 0, 30
|
|
143
|
-
hline: -10, 5, 20
|
|
144
|
-
hline: -5, 10, 10
|
|
145
|
-
vpin: 1, 0, -10, 10, display_pin_id=0
|
|
146
|
-
label: "net_name", 0, 22, net_name, fontSize=10, anchor="middle"
|
|
147
|
-
type: "net"
|
|
148
|
-
params:
|
|
149
|
-
__is_net: 1
|
|
150
|
-
net_name: net_name
|
|
151
|
-
priority: 100
|
|
152
|
-
|
|
153
|
-
def dgnd():
|
|
154
|
-
height = 10
|
|
155
|
-
width = 20
|
|
156
|
-
|
|
157
|
-
net_name = "GND"
|
|
158
|
-
return create component:
|
|
159
|
-
pins: 1
|
|
160
|
-
display: create graphic:
|
|
161
|
-
triangle: 0, 0, 0, height, width
|
|
162
|
-
vpin: 1, 0, -10, 10, display_pin_id=0
|
|
163
|
-
label: "net_name", 0, height + 10, net_name, fontSize=10, anchor="middle"
|
|
164
|
-
type: "net"
|
|
165
|
-
params:
|
|
166
|
-
__is_net: 1
|
|
167
|
-
net_name: net_name
|
|
168
|
-
priority: 100
|
|
169
|
-
|
|
170
|
-
def marker_point():
|
|
171
|
-
return create component:
|
|
172
|
-
pins: 1
|
|
173
|
-
display: create graphic:
|
|
174
|
-
hline: -5, 0, 10
|
|
175
|
-
vline: 0, -5, 10
|
|
176
|
-
pin: 1, 0, 0, 0, 0, display_pin_id=0
|
|
177
|
-
type: "net"
|
|
178
|
-
|
|
179
|
-
def arrow_point():
|
|
180
|
-
return create component:
|
|
181
|
-
pins: 1
|
|
182
|
-
display: create graphic:
|
|
183
|
-
path: ("M", 15, -5, "L", 20, 0, "L", 15, 5)
|
|
184
|
-
hpin: 1, 0, 0, 20
|
|
185
|
-
type: "net"
|
package/refresh.html
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
|
|
3
|
-
<head>
|
|
4
|
-
<title>Circuitscript - Refresh</title>
|
|
5
|
-
<style>
|
|
6
|
-
@font-face{
|
|
7
|
-
font-family: Inter;
|
|
8
|
-
src: url('fonts/Inter-Regular.ttf');
|
|
9
|
-
}
|
|
10
|
-
@font-face {
|
|
11
|
-
font-family: Inter-Bold;
|
|
12
|
-
src: url('fonts/Inter-Bold.ttf');
|
|
13
|
-
}
|
|
14
|
-
body {
|
|
15
|
-
padding: 0;
|
|
16
|
-
margin: 0;
|
|
17
|
-
font-family: Arial;
|
|
18
|
-
}
|
|
19
|
-
</style>
|
|
20
|
-
</head>
|
|
21
|
-
|
|
22
|
-
<body>
|
|
23
|
-
<div id="main"/>
|
|
24
|
-
</body>
|
|
25
|
-
|
|
26
|
-
<script>
|
|
27
|
-
|
|
28
|
-
const socket = new WebSocket("ws://localhost:3000");
|
|
29
|
-
socket.addEventListener("open", (event) => {
|
|
30
|
-
socket.send("hello");
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
socket.addEventListener("message", (event) => {
|
|
34
|
-
console.log((new Date()).toISOString(), 'got update', event.data.length);
|
|
35
|
-
|
|
36
|
-
if (event.data.length > 0){
|
|
37
|
-
document.getElementById('main').innerHTML = event.data;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
</script>
|
|
42
|
-
</html>
|
package/server.cjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const express = require('express')
|
|
2
|
-
const ws = require('ws');
|
|
3
|
-
const fs = require('fs');
|
|
4
|
-
|
|
5
|
-
const app = express()
|
|
6
|
-
|
|
7
|
-
const wsServer = new ws.Server({ noServer: true });
|
|
8
|
-
wsServer.on('connection', socket => {
|
|
9
|
-
|
|
10
|
-
const fileName = 'output.svg';
|
|
11
|
-
|
|
12
|
-
function emitFile(){
|
|
13
|
-
fs.readFile(fileName, 'utf8', (err, data) => {
|
|
14
|
-
if (err) {
|
|
15
|
-
throw err;
|
|
16
|
-
}
|
|
17
|
-
console.log((new Date()).toISOString(), 'send data');
|
|
18
|
-
socket.send(data);
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
let emitTimeout = null;
|
|
23
|
-
fs.watch(fileName, (event, targetFile) => {
|
|
24
|
-
if (event === 'change') {
|
|
25
|
-
console.log((new Date()).toISOString(), 'file changed!');
|
|
26
|
-
|
|
27
|
-
// emit the change
|
|
28
|
-
clearInterval(emitTimeout);
|
|
29
|
-
emitTimeout = setTimeout(() => {
|
|
30
|
-
emitFile();
|
|
31
|
-
}, 200);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
socket.on('message', message => {
|
|
36
|
-
console.log(message.toString());
|
|
37
|
-
emitFile();
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
app.use(express.static('./'))
|
|
42
|
-
|
|
43
|
-
const server = app.listen(3000);
|
|
44
|
-
server.on('upgrade', (request, socket, head) => {
|
|
45
|
-
wsServer.handleUpgrade(request, socket, head, socket => {
|
|
46
|
-
wsServer.emit('connection', socket, request);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
console.log('server started at port 3000');
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
grammar CircuitScript;
|
|
2
|
-
|
|
3
|
-
// Generate with: antlr4 -Dlanguage=Python3 CircuitScript.g4 -no-listener -visitor
|
|
4
|
-
// Generate with: antlr4 -Dlanguage=TypeScript CircuitScript.g4 -no-listener -visitor
|
|
5
|
-
|
|
6
|
-
tokens { INDENT, DEDENT }
|
|
7
|
-
|
|
8
|
-
// Keywords
|
|
9
|
-
Break: 'break';
|
|
10
|
-
Branch: 'branch';
|
|
11
|
-
Create: 'create';
|
|
12
|
-
Component: 'component';
|
|
13
|
-
Graphic: 'graphic';
|
|
14
|
-
Wire: 'wire';
|
|
15
|
-
Pin: 'pin';
|
|
16
|
-
Add: 'add';
|
|
17
|
-
At: 'at';
|
|
18
|
-
To: 'to';
|
|
19
|
-
Point: 'point';
|
|
20
|
-
Join: 'join';
|
|
21
|
-
Parallel: 'parallel';
|
|
22
|
-
|
|
23
|
-
Return: 'return';
|
|
24
|
-
Define: 'def';
|
|
25
|
-
Import: 'import';
|
|
26
|
-
|
|
27
|
-
If: 'if';
|
|
28
|
-
Not: '!';
|
|
29
|
-
|
|
30
|
-
Equals: '==';
|
|
31
|
-
NotEquals: '!=';
|
|
32
|
-
Addition: '+';
|
|
33
|
-
Minus: '-';
|
|
34
|
-
Divide: '/';
|
|
35
|
-
Multiply: '*';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
script: (expression | NEWLINE)+ EOF;
|
|
39
|
-
|
|
40
|
-
// These expressions are related to circuit building only
|
|
41
|
-
expression: add_component_expr
|
|
42
|
-
| to_component_expr
|
|
43
|
-
| at_component_expr
|
|
44
|
-
| assignment_expr
|
|
45
|
-
| property_set_expr
|
|
46
|
-
| property_set_expr2
|
|
47
|
-
| double_dot_property_set_expr
|
|
48
|
-
| break_keyword
|
|
49
|
-
| function_def_expr
|
|
50
|
-
| wire_expr
|
|
51
|
-
| import_expr
|
|
52
|
-
| frame_expr
|
|
53
|
-
| atom_expr
|
|
54
|
-
|
|
55
|
-
| at_block
|
|
56
|
-
| path_blocks
|
|
57
|
-
| point_expr
|
|
58
|
-
;
|
|
59
|
-
|
|
60
|
-
path_blocks: path_block_inner+;
|
|
61
|
-
path_block_inner:
|
|
62
|
-
(Branch | Join | Parallel | Point) ':' NEWLINE INDENT (NEWLINE | expression)+ DEDENT;
|
|
63
|
-
|
|
64
|
-
property_set_expr2:
|
|
65
|
-
atom_expr ':' NEWLINE INDENT ( NEWLINE | assignment_expr2)+ DEDENT;
|
|
66
|
-
assignment_expr2: (ID | INTEGER_VALUE) ':' value_expr;
|
|
67
|
-
|
|
68
|
-
data_expr_with_assignment: (data_expr | assignment_expr) pin_select_expr?;
|
|
69
|
-
|
|
70
|
-
add_component_expr: Add data_expr_with_assignment ID?;
|
|
71
|
-
|
|
72
|
-
component_select_expr: data_expr_with_assignment | pin_select_expr;
|
|
73
|
-
pin_select_expr: Pin (INTEGER_VALUE | STRING_VALUE);
|
|
74
|
-
// This does not have the 'pin' word
|
|
75
|
-
pin_select_expr2: INTEGER_VALUE | STRING_VALUE;
|
|
76
|
-
|
|
77
|
-
at_component_expr: At ((component_select_expr ID?) | Point); // ID? is for orientation
|
|
78
|
-
// at_component_expr_next: 'at' component_select_expr (',' component_select_expr)*;
|
|
79
|
-
|
|
80
|
-
to_component_expr: To ((component_select_expr (',' component_select_expr)* ID?) | Point); // ID? is for orientation
|
|
81
|
-
// pin_select_expr_next: 'pin' INTEGER_VALUE (',' INTEGER_VALUE)?;
|
|
82
|
-
|
|
83
|
-
at_to_multiple_expr: At component_select_expr To component_select_expr (',' component_select_expr)* ':' NEWLINE INDENT (NEWLINE | at_to_multiple_line_expr) + DEDENT;
|
|
84
|
-
at_to_multiple_line_expr: pin_select_expr2 ':' at_to_multiple_line_expr_to_pin (',' at_to_multiple_line_expr_to_pin)*;
|
|
85
|
-
|
|
86
|
-
at_to_multiple_line_expr_to_pin: (INTEGER_VALUE | NOT_CONNECTED);
|
|
87
|
-
|
|
88
|
-
at_block: at_component_expr ':' NEWLINE INDENT (NEWLINE | at_block_expressions) + DEDENT;
|
|
89
|
-
at_block_expressions: expression | at_block_pin_expr;
|
|
90
|
-
|
|
91
|
-
// Expression to allow direct pin assignment
|
|
92
|
-
at_block_pin_expr: pin_select_expr2 ':' (at_block_pin_expression_simple | at_block_pin_expression_complex);
|
|
93
|
-
|
|
94
|
-
at_block_pin_expression_simple: (expression | NOT_CONNECTED);
|
|
95
|
-
at_block_pin_expression_complex: NEWLINE INDENT ( NEWLINE | expression)+ DEDENT;
|
|
96
|
-
|
|
97
|
-
break_keyword: Break;
|
|
98
|
-
|
|
99
|
-
assignment_expr: atom_expr '=' data_expr;
|
|
100
|
-
keyword_assignment_expr: ID '=' data_expr;
|
|
101
|
-
|
|
102
|
-
parameters: (data_expr (',' data_expr)* (',' keyword_assignment_expr)*)
|
|
103
|
-
| (keyword_assignment_expr (',' keyword_assignment_expr)*);
|
|
104
|
-
|
|
105
|
-
property_set_expr: atom_expr '=' data_expr;
|
|
106
|
-
double_dot_property_set_expr: '..' ID '=' data_expr;
|
|
107
|
-
|
|
108
|
-
data_expr:
|
|
109
|
-
'(' data_expr ')' #RoundedBracketsExpr
|
|
110
|
-
| (value_expr | atom_expr) #ValueAtomExpr
|
|
111
|
-
| unary_operator data_expr #UnaryOperatorExpr
|
|
112
|
-
| data_expr (Multiply | Divide) data_expr #MultiplyExpr
|
|
113
|
-
| data_expr (Addition | Minus) data_expr #AdditionExpr
|
|
114
|
-
| data_expr binary_operator data_expr #BinaryOperatorExpr
|
|
115
|
-
| create_component_expr #DataExpr
|
|
116
|
-
| create_graphic_expr #DataExpr
|
|
117
|
-
;
|
|
118
|
-
|
|
119
|
-
binary_operator: Equals
|
|
120
|
-
| NotEquals
|
|
121
|
-
;
|
|
122
|
-
|
|
123
|
-
unary_operator: Not | Minus;
|
|
124
|
-
|
|
125
|
-
value_expr: ('-'?
|
|
126
|
-
(NUMERIC_VALUE
|
|
127
|
-
| DECIMAL_VALUE
|
|
128
|
-
| INTEGER_VALUE
|
|
129
|
-
| STRING_VALUE
|
|
130
|
-
| PERCENTAGE_VALUE
|
|
131
|
-
| BOOLEAN_VALUE))
|
|
132
|
-
| blank_expr;
|
|
133
|
-
|
|
134
|
-
function_def_expr: Define ID '(' function_args_expr? ')' ':' NEWLINE INDENT (NEWLINE | function_expr)+ DEDENT;
|
|
135
|
-
function_expr: expression | function_return_expr;
|
|
136
|
-
|
|
137
|
-
function_args_expr:
|
|
138
|
-
ID (',' ID)* (',' ID '=' value_expr)*
|
|
139
|
-
| ID '=' value_expr (',' ID '=' value_expr)*
|
|
140
|
-
;
|
|
141
|
-
|
|
142
|
-
atom_expr: net_namespace_expr? ID trailer_expr*;
|
|
143
|
-
trailer_expr: '(' parameters? ')'
|
|
144
|
-
| '.' ID;
|
|
145
|
-
|
|
146
|
-
net_namespace_expr: '+'? '/' data_expr?;
|
|
147
|
-
|
|
148
|
-
function_return_expr: Return data_expr ;
|
|
149
|
-
|
|
150
|
-
create_component_expr: Create Component ':' NEWLINE INDENT (NEWLINE | property_expr)+ DEDENT;
|
|
151
|
-
create_graphic_expr: Create Graphic ':' NEWLINE INDENT (NEWLINE | sub_expr)+ DEDENT;
|
|
152
|
-
|
|
153
|
-
sub_expr: (ID | Pin) ':' (parameters | '(' parameters ')');
|
|
154
|
-
|
|
155
|
-
property_expr: property_key_expr ':' property_value_expr;
|
|
156
|
-
property_key_expr: ID | INTEGER_VALUE | STRING_VALUE;
|
|
157
|
-
property_value_expr: NEWLINE INDENT (NEWLINE | property_expr)+ DEDENT # nested_properties
|
|
158
|
-
| data_expr (',' data_expr)* # single_line_property
|
|
159
|
-
;
|
|
160
|
-
|
|
161
|
-
blank_expr: '[' INTEGER_VALUE ']';
|
|
162
|
-
|
|
163
|
-
wire_expr: Wire ID (INTEGER_VALUE | ID)*;
|
|
164
|
-
point_expr: Point ID;
|
|
165
|
-
import_expr: Import ID;
|
|
166
|
-
|
|
167
|
-
frame_expr: 'frame' ':' NEWLINE INDENT (NEWLINE | expression)+ DEDENT;
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
OPEN_PAREN : '(' {this.openBrace();};
|
|
171
|
-
CLOSE_PAREN : ')' {this.closeBrace();};
|
|
172
|
-
|
|
173
|
-
// A place holder to indicate that a pin is not connected
|
|
174
|
-
NOT_CONNECTED: 'nc' | 'NC';
|
|
175
|
-
|
|
176
|
-
BOOLEAN_VALUE: 'true' | 'false';
|
|
177
|
-
|
|
178
|
-
ID: [_a-zA-Z][_a-zA-Z0-9]*;
|
|
179
|
-
|
|
180
|
-
// This value takes a number with an alphabet at the end to indicate
|
|
181
|
-
// the multipler to the number
|
|
182
|
-
|
|
183
|
-
fragment DecimalIntegerLiteral
|
|
184
|
-
: '0'
|
|
185
|
-
| [1-9] [0-9_]*
|
|
186
|
-
;
|
|
187
|
-
|
|
188
|
-
INTEGER_VALUE: ([1-9]+ [0-9]*) | [0];
|
|
189
|
-
DECIMAL_VALUE: DecimalIntegerLiteral '.' [0-9][0-9_]*;
|
|
190
|
-
NUMERIC_VALUE: (INTEGER_VALUE | DECIMAL_VALUE) [kmMunp]?;
|
|
191
|
-
|
|
192
|
-
STRING_VALUE: '"' (.)*? '"';
|
|
193
|
-
PERCENTAGE_VALUE: [1-9]+[0-9]* '%';
|
|
194
|
-
ALPHA_NUMERIC: [a-zA-Z0-9]+;
|
|
195
|
-
|
|
196
|
-
WS: [ \t]+ -> skip;
|
|
197
|
-
|
|
198
|
-
NEWLINE
|
|
199
|
-
: ( '\r'? '\n' | '\r' | '\f' ) SPACES? {this.onNewLine();}
|
|
200
|
-
;
|
|
201
|
-
|
|
202
|
-
fragment SPACES
|
|
203
|
-
: [ \t]+
|
|
204
|
-
;
|
|
205
|
-
|
|
206
|
-
// Follow python's comment symbol for now
|
|
207
|
-
fragment COMMENT: '#' ~[\r\n\f]*;
|
|
208
|
-
|
|
209
|
-
SKIP_: (WS | COMMENT) -> skip;
|