circuitscript 0.0.22 → 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/{build/src → dist/types}/antlr/CircuitScriptLexer.d.ts +23 -23
- package/{build/src → dist/types}/antlr/CircuitScriptParser.d.ts +24 -23
- package/{build/src → dist/types}/draw_symbols.d.ts +2 -2
- package/{build/src → dist/types}/execute.d.ts +2 -2
- package/{build/src → dist/types}/geometry.d.ts +1 -1
- package/dist/types/helpers.d.ts +9 -0
- package/dist/types/index.d.ts +13 -0
- package/{build/src → dist/types}/layout.d.ts +10 -10
- package/{build/src → dist/types}/objects/ClassComponent.d.ts +2 -2
- package/{build/src → dist/types}/objects/PinDefinition.d.ts +1 -1
- package/dist/types/parser.d.ts +38 -0
- package/{build/src → dist/types}/render.d.ts +1 -1
- package/{build/src → dist/types}/sizing.d.ts +3 -1
- package/{build/src → dist/types}/visitor.d.ts +5 -3
- 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/helpers.d.ts +0 -1
- 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 -27
- 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/{build/src → dist/types}/antlr/CircuitScriptVisitor.d.ts +0 -0
- /package/{build/src → dist/types}/export.d.ts +0 -0
- /package/{build/src → dist/types}/fonts.d.ts +0 -0
- /package/{build/src → dist/types}/globals.d.ts +0 -0
- /package/{build/src → dist/types}/lexer.d.ts +0 -0
- /package/{build/src → dist/types}/logger.d.ts +0 -0
- /package/{build/src → dist/types}/main.d.ts +0 -0
- /package/{build/src → dist/types}/objects/ExecutionScope.d.ts +0 -0
- /package/{build/src → dist/types}/objects/Frame.d.ts +0 -0
- /package/{build/src → dist/types}/objects/Net.d.ts +0 -0
- /package/{build/src → dist/types}/objects/ParamDefinition.d.ts +0 -0
- /package/{build/src → dist/types}/objects/PinTypes.d.ts +0 -0
- /package/{build/src → dist/types}/objects/Wire.d.ts +0 -0
- /package/{build/src → dist/types}/objects/types.d.ts +0 -0
- /package/{build/src → dist/types}/regenerate-tests.d.ts +0 -0
- /package/{build/src → dist/types}/server.d.ts +0 -0
- /package/{build/src → dist/types}/utils.d.ts +0 -0
package/documentation.md
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
# Circuitscript
|
|
2
|
-
A language to draw schematics using programming flow
|
|
3
|
-
|
|
4
|
-
## Language principles
|
|
5
|
-
1. Easy to reason, write and read. The language is heavily inspired by python to improve readability and usage.
|
|
6
|
-
2. Improved productivity: getting more done with lesser code
|
|
7
|
-
3. Generate useful schematics for PCB layouts
|
|
8
|
-
4. Testable/queryable circuits
|
|
9
|
-
5. Encourage modular designs/circuits
|
|
10
|
-
|
|
11
|
-
## Language description
|
|
12
|
-
|
|
13
|
-
### Components and pins
|
|
14
|
-
A component is defined as a point in the circuit graph. This component is created from a component definition and has a fixed number of pins.
|
|
15
|
-
|
|
16
|
-
For example: `R1 = res(10k)` creates a component with symbol class `res` and assigns it to the variable R1. The `res` symbol class defines a symbol that has 2 pins and this can be used to represent a resistor component.
|
|
17
|
-
|
|
18
|
-
### Execution state
|
|
19
|
-
The circuit are built programmatically by adding and connecting different pins of symbols. There is always a "cursor" in the execution state, this represents the current (component, pin) location the cursor is at. Commands executed will usually depend on the current cursor.
|
|
20
|
-
|
|
21
|
-
For example:
|
|
22
|
-
```
|
|
23
|
-
R1 = res(10k)
|
|
24
|
-
at R1 pin 2
|
|
25
|
-
to R2 = res(20k)
|
|
26
|
-
```
|
|
27
|
-
The first line creates a resistor R1 with a value of 10k.
|
|
28
|
-
The second line moves the "cursor" to pin 2 of R1.
|
|
29
|
-
The next line creates a resistor R2 with a value of 20k and connects the cursor to pin 1 of R2.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
### Building circuits
|
|
33
|
-
|
|
34
|
-
The `add` command is useful for combining the first line and second lines together:
|
|
35
|
-
```
|
|
36
|
-
add R1 = res(10k) # Creates 10k resistor and assign it to variable R1.
|
|
37
|
-
# The `add` commands automatically moves to the next pin of the component.
|
|
38
|
-
add R2 = res(20k) # Creates 20k resistor and assign it to variable R2.
|
|
39
|
-
# Pin 2 of R1 and Pin 1 of R2 are joined together in the same net.
|
|
40
|
-
# After this line is executed, the cursor is now at pin 2 of R2.
|
|
41
|
-
to gnd # Connect pin 2 of R2 to `gnd` net.
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
The variable names can also be omitted, if references to the component are not required:
|
|
45
|
-
```
|
|
46
|
-
add R1 = res(10k)
|
|
47
|
-
add res(20k)
|
|
48
|
-
to gnd
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
## component instance creation
|
|
53
|
-
`res()` or `R1 = res(10k)`
|
|
54
|
-
|
|
55
|
-
The first expression creates a new instance of symbol `res` and this is an unnamed component. During execution, it will be assigned a random name. Note that this is just an internal name and may be different from the name used in the BOM.
|
|
56
|
-
|
|
57
|
-
The second expression creates an instance of `res` and assigns into the variable name `R1`.
|
|
58
|
-
|
|
59
|
-
### `add` command
|
|
60
|
-
`add res()`
|
|
61
|
-
|
|
62
|
-
This creates a resistor and adds it's pin 1 to the current net.
|
|
63
|
-
The current net is moved to pin 2 of the resistor
|
|
64
|
-
|
|
65
|
-
`add R1 = res()`
|
|
66
|
-
|
|
67
|
-
Same as the `add` command, except that the newly created component is assigned to the variable `R1`
|
|
68
|
-
|
|
69
|
-
### `at` command
|
|
70
|
-
This command moves the cursor to the specified component. If no pin is specified, then the default pin, usually pin 1, is selected.
|
|
71
|
-
|
|
72
|
-
Example:
|
|
73
|
-
```
|
|
74
|
-
add res(10k)
|
|
75
|
-
add R2 = res(20k)
|
|
76
|
-
add res(20k)
|
|
77
|
-
to gnd
|
|
78
|
-
|
|
79
|
-
at R2
|
|
80
|
-
add cap(20n)
|
|
81
|
-
to gnd
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### `at` with pin definition branching
|
|
85
|
-
|
|
86
|
-
This allows multiple pins of the same component to be built without having to go to the component after each statement.
|
|
87
|
-
|
|
88
|
-
Example:
|
|
89
|
-
```
|
|
90
|
-
at U1:
|
|
91
|
-
"VCC": to V5V
|
|
92
|
-
"GND": to gnd
|
|
93
|
-
"IO1": to pin_header_1 pin 1
|
|
94
|
-
"IO2": to pin_header_2 pin 2
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
### `at <component> to <component1>, <component2>`
|
|
98
|
-
This statement allows pins from multiple components to be linked together.
|
|
99
|
-
|
|
100
|
-
Example:
|
|
101
|
-
```
|
|
102
|
-
at U1 to conn1, conn2:
|
|
103
|
-
1: 1, 4
|
|
104
|
-
2: 2, 3
|
|
105
|
-
3: 3, 2
|
|
106
|
-
4: 4, 1
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### `to` command
|
|
110
|
-
This command connects the cursor to the specified component. If no pin is specified, then the default pin of the specified component is connected.
|
|
111
|
-
|
|
112
|
-
Example:
|
|
113
|
-
```
|
|
114
|
-
R1 = res(10k)
|
|
115
|
-
V5V = net('5V')
|
|
116
|
-
at V5V
|
|
117
|
-
to R1 # goes to pin 1 of R1 by default
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
### `section` command
|
|
121
|
-
Provides a logical grouping of components and nets
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
### Selecting (component, pin) pairs:
|
|
125
|
-
Possible options:
|
|
126
|
-
- `at component pin 1` / `at component pin "IO1"`
|
|
127
|
-
- `at component 1`/ `at component "IO1"`
|
|
128
|
-
- `at component.1` / `at component."IO1"` / `at component.IO1`
|
|
129
|
-
- `at component:1` / `at component:"IO1"` / `at component:IO1`
|
|
130
|
-
- `at component-1` / `at compoennt-"IO1"` / `at component-IO1`
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
### Definitions
|
|
134
|
-
| Term | Description |
|
|
135
|
-
|------------|-------------------------------------------------|
|
|
136
|
-
| Symbol | Defines the pins and parameters in a component
|
|
137
|
-
| Component | A single instance of a symbol that is placed in a circuit
|
|
138
|
-
| Pins | Physical pins or connection points on a device
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
### Defining components
|
|
142
|
-
A new symbol is defined by:
|
|
143
|
-
```
|
|
144
|
-
new_comp create symbol:
|
|
145
|
-
pins: 2
|
|
146
|
-
```
|
|
147
|
-
The code above creates a symbol object with 2 pins. The pins are automatically generated with a pin ID of 1 and 2 respectively.
|
|
148
|
-
|
|
149
|
-
Pin names can also be defined in the symbol object:
|
|
150
|
-
```
|
|
151
|
-
new_comp = create symbol:
|
|
152
|
-
pins:
|
|
153
|
-
1: "anode"
|
|
154
|
-
2: "cathode"
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
If a pin type is specified, it has to be the first item in the pin definition. The following pin types are currently supported: `Any, Input, Output, IO, Power`
|
|
158
|
-
```
|
|
159
|
-
new_comp = create symbol:
|
|
160
|
-
pins:
|
|
161
|
-
1: power, "VCC"
|
|
162
|
-
2: power, "GND"
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
### Functions and symbols
|
|
168
|
-
New symbols are created with the `create symbol` command. Functions can create circuit blocks and return them.
|
|
169
|
-
|
|
170
|
-
Using functions to contain circuit blocks allows them to be reused.
|
|
171
|
-
|
|
172
|
-
Example:
|
|
173
|
-
```
|
|
174
|
-
# Define a new function that is a resistor component
|
|
175
|
-
def res(value):
|
|
176
|
-
return create component:
|
|
177
|
-
pins: 2
|
|
178
|
-
params:
|
|
179
|
-
value: value
|
|
180
|
-
|
|
181
|
-
add res(10k)
|
|
182
|
-
to gnd
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### To expand: Multi-cursor constructions:
|
|
186
|
-
Example:
|
|
187
|
-
```
|
|
188
|
-
foreach connector1 pin 2,3,4,5 to connector2 pin 2,3,4,5:
|
|
189
|
-
add res(22)
|
|
190
|
-
add cap(10n)
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
### To expand: Branching
|
|
195
|
-
This defines parallel branches of circuits that start at the same net/component
|
|
196
|
-
|
|
197
|
-
`branch`
|
|
198
|
-
|
|
199
|
-
Starts the branch point at the current net/component. Branch blocks must be specified immediately after each other so that the branch point will be the same.
|
|
200
|
-
When all branching is done within the branch sequence, then any hanging nets will be joined together and used as the current insertion point.
|
|
201
|
-
|
|
202
|
-
`break`
|
|
203
|
-
|
|
204
|
-
This keyword will stop further processing of expressions in a branch. When the branching ends, the hanging net in this branch will not be joined with the others.
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
### Component definitions
|
|
209
|
-
TDB
|
|
210
|
-
|
|
211
|
-
### Variables
|
|
212
|
-
TBD
|
|
213
|
-
|
|
214
|
-
### Conditions
|
|
215
|
-
TDB
|
|
216
|
-
|
|
217
|
-
### Do not place/fit
|
|
218
|
-
TDB
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
### Tests/Unit tests
|
|
222
|
-
|
|
223
|
-
### Outputs
|
|
224
|
-
- SPICE nets for testing/verifyings
|
|
225
|
-
|
|
226
|
-
### Drawing/graphics
|
|
227
|
-
- KiCAD output?
|
|
228
|
-
|
|
229
|
-
# New ideas:
|
|
230
|
-
- object for bundle/harnesses
|
|
231
|
-
### `before` command
|
|
232
|
-
|
|
233
|
-
Example:
|
|
234
|
-
```
|
|
235
|
-
add res(10k)
|
|
236
|
-
before to gnd:
|
|
237
|
-
add res(10k)
|
|
238
|
-
add res(20k)
|