circuitscript 0.3.1 → 0.4.0
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 +394 -262
- package/dist/cjs/LexerDiagnosticListener.js +375 -0
- package/dist/cjs/{ComponentAnnotater.js → annotate/ComponentAnnotater.js} +29 -15
- package/dist/cjs/annotate/DefaultPostAnnotationCallback.js +126 -0
- package/dist/cjs/{RefdesAnnotationVisitor.js → annotate/RefdesAnnotationVisitor.js} +10 -84
- package/dist/cjs/annotate/utils.js +70 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +279 -286
- package/dist/cjs/antlr/CircuitScriptParser.js +1954 -3535
- package/dist/cjs/antlr/CircuitScriptParserVisitor.js +7 -0
- package/dist/cjs/cache/deserializer.js +34 -0
- package/dist/cjs/cache/hash.js +8 -0
- package/dist/cjs/cache/serializer.js +122 -0
- package/dist/cjs/cache/storage.js +45 -0
- package/dist/cjs/cache/types.js +4 -0
- package/dist/cjs/{environment.js → environment/environment.js} +18 -6
- package/dist/cjs/environment/esm-environment.js +21 -0
- package/dist/cjs/environment/helpers.js +8 -0
- package/dist/cjs/execute.js +49 -15
- package/dist/cjs/globals.js +9 -1
- package/dist/cjs/helpers.js +3 -467
- package/dist/cjs/importResolver.js +102 -0
- package/dist/cjs/index.js +7 -6
- package/dist/cjs/lexer.js +48 -12
- package/dist/cjs/main.js +14 -4
- package/dist/cjs/objects/ClassComponent.js +1 -1
- package/dist/cjs/objects/ExecutionScope.js +0 -1
- package/dist/cjs/objects/types.js +17 -1
- package/dist/cjs/parser.js +18 -4
- package/dist/cjs/pipeline.js +284 -0
- package/dist/cjs/regenerate-tests.js +4 -3
- package/dist/cjs/render/KiCadNetListOutputHandler.js +30 -0
- package/dist/cjs/render/PaperSizes.js +46 -0
- package/dist/cjs/{draw_symbols.js → render/draw_symbols.js} +58 -36
- package/dist/cjs/{export.js → render/export.js} +2 -2
- package/dist/cjs/{geometry.js → render/geometry.js} +5 -5
- package/dist/cjs/{graph.js → render/graph.js} +7 -7
- package/dist/cjs/{layout.js → render/layout.js} +8 -8
- package/dist/cjs/{render.js → render/render.js} +9 -8
- package/dist/cjs/rules-check/no-connect-on-connected-pin.js +1 -1
- package/dist/cjs/rules-check/unconnected-pins.js +1 -1
- package/dist/cjs/{SemanticTokenVisitor.js → semantic-tokens/SemanticTokenVisitor.js} +12 -14
- package/dist/cjs/semantic-tokens/getSemanticTokens.js +55 -0
- package/dist/cjs/sizing.js +2 -2
- package/dist/cjs/utils.js +2 -2
- package/dist/cjs/validate/SymbolValidatorResolveVisitor.js +6 -0
- package/dist/cjs/validate/SymbolValidatorVisitor.js +34 -39
- package/dist/cjs/validate/validateScript.js +54 -0
- package/dist/cjs/validate.js +5 -4
- package/dist/cjs/visitor.js +158 -212
- package/dist/esm/BaseVisitor.js +396 -264
- package/dist/esm/LexerDiagnosticListener.js +371 -0
- package/dist/esm/{ComponentAnnotater.js → annotate/ComponentAnnotater.js} +29 -15
- package/dist/esm/annotate/DefaultPostAnnotationCallback.js +122 -0
- package/dist/esm/{RefdesAnnotationVisitor.js → annotate/RefdesAnnotationVisitor.js} +10 -84
- package/dist/esm/annotate/utils.js +66 -0
- package/dist/esm/antlr/CircuitScriptLexer.js +279 -286
- package/dist/esm/antlr/CircuitScriptParser.js +1962 -3522
- package/dist/esm/antlr/{CircuitScriptVisitor.js → CircuitScriptParserVisitor.js} +14 -35
- package/dist/esm/cache/deserializer.js +30 -0
- package/dist/esm/cache/hash.js +4 -0
- package/dist/esm/cache/serializer.js +118 -0
- package/dist/esm/cache/storage.js +39 -0
- package/dist/esm/cache/types.js +1 -0
- package/dist/esm/{environment.js → environment/environment.js} +18 -6
- package/dist/esm/environment/esm-environment.js +17 -0
- package/dist/esm/environment/helpers.js +4 -0
- package/dist/esm/execute.js +49 -15
- package/dist/esm/globals.js +8 -0
- package/dist/esm/helpers.js +5 -456
- package/dist/esm/importResolver.js +96 -0
- package/dist/esm/index.js +7 -6
- package/dist/esm/lexer.js +51 -12
- package/dist/esm/main.js +13 -3
- package/dist/esm/objects/ClassComponent.js +1 -1
- package/dist/esm/objects/ExecutionScope.js +0 -1
- package/dist/esm/objects/types.js +21 -1
- package/dist/esm/parser.js +19 -5
- package/dist/esm/pipeline.js +276 -0
- package/dist/esm/regenerate-tests.js +3 -2
- package/dist/esm/render/KiCadNetListOutputHandler.js +20 -0
- package/dist/esm/render/PaperSizes.js +41 -0
- package/dist/esm/{draw_symbols.js → render/draw_symbols.js} +58 -36
- package/dist/esm/{export.js → render/export.js} +2 -2
- package/dist/esm/{geometry.js → render/geometry.js} +5 -5
- package/dist/esm/{graph.js → render/graph.js} +7 -7
- package/dist/esm/{layout.js → render/layout.js} +8 -8
- package/dist/esm/{render.js → render/render.js} +8 -7
- package/dist/esm/rules-check/no-connect-on-connected-pin.js +1 -1
- package/dist/esm/rules-check/unconnected-pins.js +1 -1
- package/dist/esm/{SemanticTokenVisitor.js → semantic-tokens/SemanticTokenVisitor.js} +12 -14
- package/dist/esm/semantic-tokens/getSemanticTokens.js +51 -0
- package/dist/esm/sizing.js +2 -2
- package/dist/esm/utils.js +2 -2
- package/dist/esm/validate/SymbolValidatorResolveVisitor.js +3 -0
- package/dist/esm/validate/SymbolValidatorVisitor.js +36 -41
- package/dist/esm/validate/validateScript.js +50 -0
- package/dist/esm/validate.js +4 -3
- package/dist/esm/visitor.js +160 -214
- package/dist/libs/std.cst +15 -19
- package/dist/types/BaseVisitor.d.ts +25 -18
- package/dist/types/BomGeneration.d.ts +1 -1
- package/dist/types/LexerDiagnosticListener.d.ts +85 -0
- package/dist/types/{ComponentAnnotater.d.ts → annotate/ComponentAnnotater.d.ts} +1 -1
- package/dist/types/annotate/DefaultPostAnnotationCallback.d.ts +7 -0
- package/dist/types/{RefdesAnnotationVisitor.d.ts → annotate/RefdesAnnotationVisitor.d.ts} +7 -9
- package/dist/types/annotate/utils.d.ts +6 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +71 -70
- package/dist/types/antlr/CircuitScriptParser.d.ts +357 -515
- package/dist/types/antlr/{CircuitScriptVisitor.d.ts → CircuitScriptParserVisitor.d.ts} +27 -69
- package/dist/types/cache/deserializer.d.ts +5 -0
- package/dist/types/cache/hash.d.ts +1 -0
- package/dist/types/cache/serializer.d.ts +3 -0
- package/dist/types/cache/storage.d.ts +4 -0
- package/dist/types/cache/types.d.ts +20 -0
- package/dist/types/{environment.d.ts → environment/environment.d.ts} +5 -4
- package/dist/types/environment/esm-environment.d.ts +4 -0
- package/dist/types/environment/helpers.d.ts +2 -0
- package/dist/types/execute.d.ts +3 -2
- package/dist/types/globals.d.ts +1 -0
- package/dist/types/helpers.d.ts +31 -36
- package/dist/types/importResolver.d.ts +4 -0
- package/dist/types/index.d.ts +7 -6
- package/dist/types/lexer.d.ts +9 -5
- package/dist/types/objects/ClassComponent.d.ts +1 -1
- package/dist/types/objects/ExecutionScope.d.ts +1 -4
- package/dist/types/objects/types.d.ts +16 -2
- package/dist/types/parser.d.ts +9 -2
- package/dist/types/pipeline.d.ts +9 -0
- package/dist/types/render/KiCadNetListOutputHandler.d.ts +10 -0
- package/dist/types/render/PaperSizes.d.ts +12 -0
- package/dist/types/{draw_symbols.d.ts → render/draw_symbols.d.ts} +4 -4
- package/dist/types/{export.d.ts → render/export.d.ts} +1 -1
- package/dist/types/{geometry.d.ts → render/geometry.d.ts} +2 -2
- package/dist/types/{graph.d.ts → render/graph.d.ts} +6 -6
- package/dist/types/{layout.d.ts → render/layout.d.ts} +10 -10
- package/dist/types/{render.d.ts → render/render.d.ts} +1 -1
- package/dist/types/{SemanticTokenVisitor.d.ts → semantic-tokens/SemanticTokenVisitor.d.ts} +6 -6
- package/dist/types/semantic-tokens/getSemanticTokens.d.ts +6 -0
- package/dist/types/sizing.d.ts +1 -1
- package/dist/types/utils.d.ts +1 -1
- package/dist/types/validate/SymbolValidatorResolveVisitor.d.ts +3 -0
- package/dist/types/validate/SymbolValidatorVisitor.d.ts +8 -8
- package/dist/types/validate/validateScript.d.ts +3 -0
- package/dist/types/visitor.d.ts +8 -14
- package/libs/std.cst +15 -19
- package/package.json +3 -6
- package/dist/cjs/antlr/CircuitScriptVisitor.js +0 -7
package/dist/libs/std.cst
CHANGED
|
@@ -4,10 +4,9 @@ def net(net_name, net_type = "any"):
|
|
|
4
4
|
return create component:
|
|
5
5
|
pins: 1
|
|
6
6
|
copy: true
|
|
7
|
-
angle: -90
|
|
8
7
|
display: create graphic (params):
|
|
9
8
|
hline: -50, 0, 100
|
|
10
|
-
vpin: 1, 0, 50, -50,
|
|
9
|
+
vpin: 1, 0, 50, -50, display_id=false
|
|
11
10
|
label: params.net_name, 0, -15, fontSize=50, anchor="middle"
|
|
12
11
|
type: "net"
|
|
13
12
|
params:
|
|
@@ -27,7 +26,7 @@ def label(value, anchor="left"):
|
|
|
27
26
|
display: create graphic (params):
|
|
28
27
|
textColor: "#222"
|
|
29
28
|
label: params.value, 0, -10, fontSize=50, anchor=anchor
|
|
30
|
-
pin: 1, 0, 0, 0, 0,
|
|
29
|
+
pin: 1, 0, 0, 0, 0, display_id=false
|
|
31
30
|
type: "net"
|
|
32
31
|
params:
|
|
33
32
|
net_name: value
|
|
@@ -41,7 +40,7 @@ def port(value, portType="input"):
|
|
|
41
40
|
display: create graphic (params):
|
|
42
41
|
textColor: "#222"
|
|
43
42
|
label: params.value, 0, 0, fontSize=40, anchor="left", vanchor="middle", portType=portType
|
|
44
|
-
pin: 1, 0, 0, 0, 0,
|
|
43
|
+
pin: 1, 0, 0, 0, 0, display_id=false
|
|
45
44
|
type: "port"
|
|
46
45
|
params:
|
|
47
46
|
net_name: value
|
|
@@ -56,8 +55,8 @@ def res(value):
|
|
|
56
55
|
pins: 2
|
|
57
56
|
display: create graphic (params):
|
|
58
57
|
crect: 0, 0, width, height
|
|
59
|
-
hpin: 1, -width/2 - 30, 0, 30
|
|
60
|
-
hpin: 2, width/2 + 30, 0, -30
|
|
58
|
+
hpin: 1, -width/2 - 30, 0, 30, display_id=false
|
|
59
|
+
hpin: 2, width/2 + 30, 0, -30, display_id=false
|
|
61
60
|
label: params.refdes, -width/2, -height/2 - 20, fontSize=50, anchor="left"
|
|
62
61
|
label: params.value, 0, 0, fontSize=30, anchor="middle", vanchor="middle"
|
|
63
62
|
type: "res"
|
|
@@ -73,13 +72,12 @@ def cap(value):
|
|
|
73
72
|
|
|
74
73
|
return create component:
|
|
75
74
|
pins: 2
|
|
76
|
-
angle: 90
|
|
77
75
|
display: create graphic (params):
|
|
78
76
|
lineWidth: 13
|
|
79
77
|
hline: -width/2, 20, width
|
|
80
78
|
hline: -width/2, -20, width
|
|
81
|
-
vpin: 1, 0, -100, 80
|
|
82
|
-
vpin: 2, 0, 100, -80
|
|
79
|
+
vpin: 1, 0, -100, 80, display_id=false
|
|
80
|
+
vpin: 2, 0, 100, -80, display_id=false
|
|
83
81
|
label: params.refdes, 80, -30, fontSize=50, anchor="left", vanchor="middle"
|
|
84
82
|
label: params.value, 80, 30, fontSize=50, anchor = "left", vanchor="middle"
|
|
85
83
|
type: "cap"
|
|
@@ -100,8 +98,8 @@ def ind(value):
|
|
|
100
98
|
arc: -25, 0, 25, 180, 360
|
|
101
99
|
arc: 25, 0, 25, 180, 360
|
|
102
100
|
arc: 75, 0, 25, 180, 360
|
|
103
|
-
hpin: 1, -width/2 - 100, 0, 100
|
|
104
|
-
hpin: 2, width/2 + 100, 0, -100
|
|
101
|
+
hpin: 1, -width/2 - 100, 0, 100, display_id=false
|
|
102
|
+
hpin: 2, width/2 + 100, 0, -100, display_id=false
|
|
105
103
|
label: (params.refdes, -width/2, -height/2 - 25 , fontSize=50, anchor="left")
|
|
106
104
|
label: (params.value, 0, 50, fontSize=50, anchor="middle", vanchor="middle")
|
|
107
105
|
params:
|
|
@@ -156,12 +154,11 @@ def cgnd():
|
|
|
156
154
|
return create component:
|
|
157
155
|
pins: 1
|
|
158
156
|
copy: true
|
|
159
|
-
angle: 90
|
|
160
157
|
display: create graphic (params):
|
|
161
158
|
hline: -15, 0, 30
|
|
162
159
|
hline: -10, 5, 20
|
|
163
160
|
hline: -5, 10, 10
|
|
164
|
-
vpin: 1, 0, -10, 10,
|
|
161
|
+
vpin: 1, 0, -10, 10, display_id=false
|
|
165
162
|
label: params.net_name, 0, 22, fontSize=50, anchor="middle"
|
|
166
163
|
type: "net"
|
|
167
164
|
params:
|
|
@@ -175,10 +172,9 @@ def dgnd(net_name="GND"):
|
|
|
175
172
|
return create component:
|
|
176
173
|
pins: 1
|
|
177
174
|
copy: true
|
|
178
|
-
angle: 90
|
|
179
175
|
display: create graphic (params):
|
|
180
176
|
triangle: 0, 0, 0, height, width
|
|
181
|
-
vpin: 1, 0, -50, 50,
|
|
177
|
+
vpin: 1, 0, -50, 50, display_id=false
|
|
182
178
|
label: params.net_name, 0, height + 50, fontSize=50, anchor="middle", vanchor="middle"
|
|
183
179
|
type: "net"
|
|
184
180
|
params:
|
|
@@ -191,7 +187,7 @@ def text(value, offsetX = 0, offsetY = 0, fontSize = 50):
|
|
|
191
187
|
followWireOrientation: false
|
|
192
188
|
type: "graphic"
|
|
193
189
|
display: create graphic:
|
|
194
|
-
pin: 1, 0, 0, 0, 0,
|
|
190
|
+
pin: 1, 0, 0, 0, 0, display_id=false
|
|
195
191
|
text:
|
|
196
192
|
content: value
|
|
197
193
|
offset: offsetX, offsetY
|
|
@@ -205,7 +201,7 @@ def marker_point():
|
|
|
205
201
|
display: create graphic:
|
|
206
202
|
hline: -5, 0, 10
|
|
207
203
|
vline: 0, -5, 10
|
|
208
|
-
pin: 1, 0, 0, 0, 0,
|
|
204
|
+
pin: 1, 0, 0, 0, 0, display_id=false
|
|
209
205
|
|
|
210
206
|
def arrow_point():
|
|
211
207
|
return create component:
|
|
@@ -215,7 +211,7 @@ def arrow_point():
|
|
|
215
211
|
lineWidth: 2
|
|
216
212
|
path: ("M", -10, -5, "L", -5, 0, "L", -10, 5)
|
|
217
213
|
path: ("M", -5, 0, "L", -20, 0)
|
|
218
|
-
hpin: 1, 0, 0, 0,
|
|
214
|
+
hpin: 1, 0, 0, 0, display_id=false
|
|
219
215
|
|
|
220
216
|
def no_connect(size=20):
|
|
221
217
|
return create component:
|
|
@@ -224,7 +220,7 @@ def no_connect(size=20):
|
|
|
224
220
|
display: create graphic:
|
|
225
221
|
path: "M", -size, -size, "L", size, size
|
|
226
222
|
path: "M", -size, size, "L", size, -size
|
|
227
|
-
pin: 1, 0, 0, 0, 0,
|
|
223
|
+
pin: 1, 0, 0, 0, 0, display_id=false
|
|
228
224
|
params:
|
|
229
225
|
no_connect: true
|
|
230
226
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { ArrayExprContext, Assignment_exprContext, Callable_exprContext, CallableExprContext, ExpressionContext, Flow_expressionsContext, Function_args_exprContext, Function_exprContext, Function_return_exprContext, Import_exprContext, Import_simpleContext, Import_specific_or_allContext, Keyword_assignment_exprContext, ParametersContext, RoundedBracketsExprContext, ScriptContext, TrailerContext, Value_exprContext, ValueExprContext } from "./antlr/CircuitScriptParser.js";
|
|
2
|
+
import { CircuitScriptParserVisitor } from "./antlr/CircuitScriptParserVisitor.js";
|
|
3
3
|
import { ExecutionContext } from "./execute.js";
|
|
4
4
|
import { Logger } from "./logger.js";
|
|
5
5
|
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
@@ -9,9 +9,9 @@ import { CommonTokenStream, ParserRuleContext } from 'antlr4ng';
|
|
|
9
9
|
import { ExecutionWarning } from "./utils.js";
|
|
10
10
|
import { BaseError } from './utils.js';
|
|
11
11
|
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
12
|
-
import { NodeScriptEnvironment } from "./environment.js";
|
|
12
|
+
import { NodeScriptEnvironment } from "./environment/environment.js";
|
|
13
13
|
import { PinId } from './objects/PinDefinition.js';
|
|
14
|
-
export declare class BaseVisitor extends
|
|
14
|
+
export declare class BaseVisitor extends CircuitScriptParserVisitor<ComplexType | AnyReference | any> {
|
|
15
15
|
startingContext: ExecutionContext;
|
|
16
16
|
executionStack: ExecutionContext[];
|
|
17
17
|
filePathStack: string[];
|
|
@@ -23,12 +23,15 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
|
|
|
23
23
|
acceptedDirections: Direction[];
|
|
24
24
|
protected resultData: Map<ParserRuleContext, any>;
|
|
25
25
|
protected componentCtxLinks: Map<ParserRuleContext, ClassComponent>;
|
|
26
|
-
pinTypesList: string[];
|
|
27
26
|
onErrorHandler: OnErrorHandler | null;
|
|
28
27
|
environment: NodeScriptEnvironment;
|
|
29
28
|
protected importedFiles: ImportLibraryFile[];
|
|
30
29
|
protected warnings: ExecutionWarning[];
|
|
31
|
-
|
|
30
|
+
loadedFiles: Map<string, string>;
|
|
31
|
+
enableCacheImports: boolean;
|
|
32
|
+
enableCachedImportsRead: boolean;
|
|
33
|
+
enableCachedImportsWrite: boolean;
|
|
34
|
+
onImportFile: (visitor: BaseVisitor, filePath: string, fileData: string, onErrorHandler: OnErrorHandler, fileLineOffset: number) => ImportFileResult;
|
|
32
35
|
refdesFileAnnotations: Map<string, string>;
|
|
33
36
|
constructor(silent: boolean | undefined, onErrorHandler: OnErrorHandler | null | undefined, environment: NodeScriptEnvironment);
|
|
34
37
|
getExecutor(): ExecutionContext;
|
|
@@ -42,25 +45,26 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
|
|
|
42
45
|
createComponentPinNetResolver(executionStack: ExecutionContext[]): (component: ClassComponent, pin: PinId) => Net | null;
|
|
43
46
|
log(...params: any[]): void;
|
|
44
47
|
log2(message: string): void;
|
|
45
|
-
|
|
46
|
-
visitScript: (ctx: ScriptContext) =>
|
|
48
|
+
resolveImportsAndLoad(inputPath: string, scriptData: string): Promise<void>;
|
|
49
|
+
visitScript: (ctx: ScriptContext) => void;
|
|
47
50
|
private importCommon;
|
|
48
|
-
visitImport_simple: (ctx: Import_simpleContext) =>
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
visitImport_simple: (ctx: Import_simpleContext) => void;
|
|
52
|
+
visitImport_specific_or_all: (ctx: Import_specific_or_allContext) => void;
|
|
53
|
+
visitCallableExpr: (ctx: CallableExprContext) => void;
|
|
54
|
+
visitCallable_expr: (ctx: Callable_exprContext) => void;
|
|
55
|
+
visitTrailer: (ctx: TrailerContext) => void;
|
|
51
56
|
visitAssignment_expr: (ctx: Assignment_exprContext) => void;
|
|
52
|
-
visitOperator_assignment_expr: (ctx: Operator_assignment_exprContext) => void;
|
|
53
57
|
private getReference;
|
|
54
58
|
visitTrailer_expr2: (ctx: Trailer_expr2Context) => void;
|
|
55
59
|
visitAtom_expr: (ctx: Atom_exprContext) => void;
|
|
56
|
-
visitFunctionCallExpr: (ctx: FunctionCallExprContext) => void;
|
|
57
|
-
visitFunction_call_expr: (ctx: Function_call_exprContext) => void;
|
|
58
60
|
private handleFunctionCall;
|
|
59
61
|
protected handleEnterContext(executor: ExecutionContext, executionStack: ExecutionContext[], contextName: string, ctx: ParserRuleContext, options: NewContextOptions, funcDefinedParameters: FunctionDefinedParameter[], passedInParameters: CallableParameter[], isBreakContext?: boolean): ExecutionContext;
|
|
60
62
|
protected handlePopContext(executor: ExecutionContext, executionStack: ExecutionContext[], namespaceExtension: string, isBreakContext?: boolean): ExecutionContext;
|
|
61
63
|
visitValue_expr: (ctx: Value_exprContext) => void;
|
|
62
|
-
|
|
64
|
+
visitValueExpr: (ctx: ValueExprContext) => void;
|
|
65
|
+
visitAtomExpr: (ctx: AtomExprContext) => void;
|
|
63
66
|
visitFunction_args_expr: (ctx: Function_args_exprContext) => void;
|
|
67
|
+
visitKeyword_assignment_expr: (ctx: Keyword_assignment_exprContext) => void;
|
|
64
68
|
visitParameters: (ctx: ParametersContext) => void;
|
|
65
69
|
visitImport_expr: (ctx: Import_exprContext) => void;
|
|
66
70
|
visitFunction_return_expr: (ctx: Function_return_exprContext) => void;
|
|
@@ -73,9 +77,12 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
|
|
|
73
77
|
protected linkComponentToCtx(ctx: ParserRuleContext, instance: ClassComponent, creationFlag?: boolean): void;
|
|
74
78
|
getComponentCtxLinks(): Map<ParserRuleContext, ClassComponent>;
|
|
75
79
|
visitResult(ctx: ParserRuleContext): any;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
80
|
+
passResult(ctx: ParserRuleContext, innerCtx: ParserRuleContext): void;
|
|
81
|
+
protected handleImportFile(name: string, importHandling: ImportFunctionHandling, throwErrors?: boolean, ctx?: ParserRuleContext | null, specificImports?: string[]): ImportLibraryFile;
|
|
82
|
+
cacheLibraries(): void;
|
|
83
|
+
checkLibraryInRefdesFile(filePath: string): void;
|
|
84
|
+
getPathRefdesFile(filePath: string): string;
|
|
85
|
+
getRefdesFileAnnotationKey(filePath: string, startLine: number, startColumn: number, stopLine: number, stopColumn: number): string;
|
|
79
86
|
visitRoundedBracketsExpr: (ctx: RoundedBracketsExprContext) => void;
|
|
80
87
|
protected setupDefinedParameters(funcDefinedParameters: FunctionDefinedParameter[], passedInParameters: CallableParameter[], executor: ExecutionContext): void;
|
|
81
88
|
protected runExpressions(executor: ExecutionContext, expressions: ExpressionContext[] | Function_exprContext[]): ComplexType;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { Token } from "antlr4ng";
|
|
2
|
+
export interface TokenStreamEntry {
|
|
3
|
+
index: number;
|
|
4
|
+
type: string;
|
|
5
|
+
text: string;
|
|
6
|
+
line: number;
|
|
7
|
+
column: number;
|
|
8
|
+
startPos: number;
|
|
9
|
+
stopPos: number;
|
|
10
|
+
channel: number;
|
|
11
|
+
timeUs: number;
|
|
12
|
+
}
|
|
13
|
+
export interface LexerDiagnostics {
|
|
14
|
+
totalTokens: number;
|
|
15
|
+
totalCharactersProcessed: number;
|
|
16
|
+
totalTimeMicroseconds: number;
|
|
17
|
+
tokenTypeStats: Map<string, TokenTypeStats>;
|
|
18
|
+
averageTokenTimeUs: number;
|
|
19
|
+
slowestTokens: Array<{
|
|
20
|
+
type: string;
|
|
21
|
+
timeUs: number;
|
|
22
|
+
text: string;
|
|
23
|
+
line: number;
|
|
24
|
+
column: number;
|
|
25
|
+
}>;
|
|
26
|
+
peakCharacterPosition: number;
|
|
27
|
+
indentCount: number;
|
|
28
|
+
dedentCount: number;
|
|
29
|
+
newlineCount: number;
|
|
30
|
+
maxQueueSize: number;
|
|
31
|
+
averageQueueSize: number;
|
|
32
|
+
largeQueueLocations: Array<{
|
|
33
|
+
queueSize: number;
|
|
34
|
+
tokenIndex: number;
|
|
35
|
+
line: number;
|
|
36
|
+
column: number;
|
|
37
|
+
tokenType: string;
|
|
38
|
+
text: string;
|
|
39
|
+
}>;
|
|
40
|
+
tokenStream: TokenStreamEntry[];
|
|
41
|
+
}
|
|
42
|
+
export interface TokenTypeStats {
|
|
43
|
+
count: number;
|
|
44
|
+
totalTimeUs: number;
|
|
45
|
+
averageTimeUs: number;
|
|
46
|
+
totalCharacters: number;
|
|
47
|
+
}
|
|
48
|
+
export declare class LexerDiagnosticCollector {
|
|
49
|
+
private startTime;
|
|
50
|
+
private tokenStartTime;
|
|
51
|
+
private totalTokens;
|
|
52
|
+
private totalCharactersProcessed;
|
|
53
|
+
private tokenTypeStats;
|
|
54
|
+
private slowestTokens;
|
|
55
|
+
private peakCharacterPosition;
|
|
56
|
+
private indentCount;
|
|
57
|
+
private dedentCount;
|
|
58
|
+
private newlineCount;
|
|
59
|
+
private queueSizeSum;
|
|
60
|
+
private queueSizeCount;
|
|
61
|
+
private maxQueueSize;
|
|
62
|
+
private largeQueueLocations;
|
|
63
|
+
private tokenStream;
|
|
64
|
+
private verboseLogging;
|
|
65
|
+
private recordTokenStream;
|
|
66
|
+
private sourceText;
|
|
67
|
+
private tokenTypeNameCache;
|
|
68
|
+
private enabled;
|
|
69
|
+
constructor();
|
|
70
|
+
setEnabled(enabled: boolean): void;
|
|
71
|
+
setVerboseLogging(enabled: boolean): void;
|
|
72
|
+
setRecordTokenStream(enabled: boolean): void;
|
|
73
|
+
setSourceText(sourceText: string): void;
|
|
74
|
+
reset(): void;
|
|
75
|
+
onTokenStart(): void;
|
|
76
|
+
onTokenGenerated(token: Token, queueSize: number): void;
|
|
77
|
+
private getTokenTypeName;
|
|
78
|
+
private logToken;
|
|
79
|
+
getDiagnostics(): LexerDiagnostics;
|
|
80
|
+
printReport(): void;
|
|
81
|
+
printTokenStream(limit?: number): void;
|
|
82
|
+
printCharacterToTokenMapping(startLine?: number, endLine?: number): void;
|
|
83
|
+
printLexerOperationSummary(): void;
|
|
84
|
+
getRecommendations(): string[];
|
|
85
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CommonTokenStream, ParserRuleContext } from "antlr4ng";
|
|
2
|
+
import { ScriptContext } from "../antlr/CircuitScriptParser.js";
|
|
3
|
+
import { NodeScriptEnvironment } from "../environment/environment.js";
|
|
4
|
+
import { ScriptOptions } from "../helpers.js";
|
|
5
|
+
import { ClassComponent } from "../objects/ClassComponent.js";
|
|
6
|
+
import { ImportedLibrary } from "../objects/types.js";
|
|
7
|
+
export declare function DefaultPostAnnotationCallback(options: ScriptOptions, scriptData: string, tree: ScriptContext, tokens: CommonTokenStream, componentLinks: Map<ParserRuleContext, ClassComponent>, importedLibraries: ImportedLibrary[], environment: NodeScriptEnvironment): Promise<void>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ParserRuleContext, CommonTokenStream } from 'antlr4ng';
|
|
2
|
-
import { Add_component_exprContext, At_block_headerContext, At_blockContext, At_component_exprContext, Component_select_exprContext, Frame_exprContext, Function_def_exprContext, Function_return_exprContext, ScriptContext, To_component_exprContext } from '
|
|
3
|
-
import { BaseVisitor } from '
|
|
4
|
-
import { ClassComponent } from '
|
|
2
|
+
import { Add_component_exprContext, At_block_headerContext, At_blockContext, At_component_exprContext, Component_select_exprContext, Frame_exprContext, Function_def_exprContext, Function_return_exprContext, ScriptContext, To_component_exprContext, TrailerContext } from '../antlr/CircuitScriptParser.js';
|
|
3
|
+
import { BaseVisitor } from '../BaseVisitor.js';
|
|
4
|
+
import { ClassComponent } from '../objects/ClassComponent.js';
|
|
5
|
+
import { RefdesModification } from './utils.js';
|
|
5
6
|
export declare class RefdesAnnotationVisitor extends BaseVisitor {
|
|
6
7
|
private sourceText;
|
|
7
8
|
private tokenStream;
|
|
@@ -10,6 +11,7 @@ export declare class RefdesAnnotationVisitor extends BaseVisitor {
|
|
|
10
11
|
debug: boolean;
|
|
11
12
|
componentCtxLinks: Map<ParserRuleContext, ClassComponent>;
|
|
12
13
|
constructor(silent: boolean, sourceText: string, tokenStream: CommonTokenStream, componentCtxLinks: Map<ParserRuleContext, ClassComponent>);
|
|
14
|
+
getModifications(): Map<ParserRuleContext, RefdesModification>;
|
|
13
15
|
private getOriginalText;
|
|
14
16
|
visitScript: (ctx: ScriptContext) => Promise<void>;
|
|
15
17
|
visitAdd_component_expr: (ctx: Add_component_exprContext) => void;
|
|
@@ -23,15 +25,11 @@ export declare class RefdesAnnotationVisitor extends BaseVisitor {
|
|
|
23
25
|
visitFrame_expr: (ctx: Frame_exprContext) => void;
|
|
24
26
|
visitFunction_call_expr: (ctx: Function_call_exprContext) => void;
|
|
25
27
|
visitParameters: (ctx: ParametersContext) => void;
|
|
28
|
+
visitTrailer: (ctx: TrailerContext) => void;
|
|
26
29
|
addedRefdesAnnotations: string[];
|
|
27
30
|
private generateRefdesAnnotationComment;
|
|
28
31
|
private addRefdesAnnotationComment;
|
|
29
32
|
getOutput(): string;
|
|
30
|
-
getOutputForExternalRefdesFile(): string
|
|
31
|
-
private generateModifiedText;
|
|
32
|
-
private buildContextTokenRanges;
|
|
33
|
-
private findContextForToken;
|
|
34
|
-
private markTokensAsProcessed;
|
|
33
|
+
getOutputForExternalRefdesFile(): Record<string, string>;
|
|
35
34
|
private log;
|
|
36
|
-
private generateReplacementText;
|
|
37
35
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ParserRuleContext, Token } from 'antlr4ng';
|
|
2
|
+
export declare function generateModifiedSourceText(modifications: Map<ParserRuleContext, RefdesModification>, tokens: Token[], sourceText: string, tokenStartOffset?: number): string;
|
|
3
|
+
export type RefdesModification = {
|
|
4
|
+
originalText: string;
|
|
5
|
+
refdes: string[];
|
|
6
|
+
};
|
|
@@ -1,73 +1,74 @@
|
|
|
1
1
|
import * as antlr from "antlr4ng";
|
|
2
2
|
export declare class CircuitScriptLexer extends antlr.Lexer {
|
|
3
|
-
static readonly
|
|
4
|
-
static readonly
|
|
5
|
-
static readonly
|
|
6
|
-
static readonly
|
|
7
|
-
static readonly
|
|
8
|
-
static readonly
|
|
9
|
-
static readonly
|
|
10
|
-
static readonly
|
|
11
|
-
static readonly
|
|
12
|
-
static readonly
|
|
13
|
-
static readonly
|
|
14
|
-
static readonly
|
|
15
|
-
static readonly
|
|
16
|
-
static readonly
|
|
17
|
-
static readonly
|
|
18
|
-
static readonly
|
|
19
|
-
static readonly
|
|
20
|
-
static readonly
|
|
21
|
-
static readonly
|
|
22
|
-
static readonly
|
|
23
|
-
static readonly
|
|
24
|
-
static readonly
|
|
25
|
-
static readonly
|
|
26
|
-
static readonly
|
|
27
|
-
static readonly
|
|
28
|
-
static readonly
|
|
29
|
-
static readonly
|
|
30
|
-
static readonly
|
|
31
|
-
static readonly
|
|
32
|
-
static readonly
|
|
33
|
-
static readonly
|
|
34
|
-
static readonly
|
|
35
|
-
static readonly
|
|
36
|
-
static readonly
|
|
37
|
-
static readonly
|
|
38
|
-
static readonly
|
|
39
|
-
static readonly
|
|
40
|
-
static readonly
|
|
41
|
-
static readonly
|
|
42
|
-
static readonly
|
|
43
|
-
static readonly
|
|
44
|
-
static readonly
|
|
45
|
-
static readonly
|
|
46
|
-
static readonly
|
|
47
|
-
static readonly
|
|
48
|
-
static readonly
|
|
49
|
-
static readonly
|
|
50
|
-
static readonly
|
|
51
|
-
static readonly
|
|
52
|
-
static readonly
|
|
53
|
-
static readonly
|
|
54
|
-
static readonly
|
|
55
|
-
static readonly
|
|
56
|
-
static readonly
|
|
57
|
-
static readonly
|
|
58
|
-
static readonly
|
|
59
|
-
static readonly
|
|
60
|
-
static readonly
|
|
61
|
-
static readonly
|
|
62
|
-
static readonly
|
|
63
|
-
static readonly
|
|
64
|
-
static readonly
|
|
65
|
-
static readonly
|
|
66
|
-
static readonly
|
|
67
|
-
static readonly
|
|
68
|
-
static readonly
|
|
69
|
-
static readonly
|
|
70
|
-
static readonly
|
|
3
|
+
static readonly INDENT = 1;
|
|
4
|
+
static readonly DEDENT = 2;
|
|
5
|
+
static readonly Break = 3;
|
|
6
|
+
static readonly Branch = 4;
|
|
7
|
+
static readonly Create = 5;
|
|
8
|
+
static readonly Component = 6;
|
|
9
|
+
static readonly Graphic = 7;
|
|
10
|
+
static readonly Module = 8;
|
|
11
|
+
static readonly Wire = 9;
|
|
12
|
+
static readonly Pin = 10;
|
|
13
|
+
static readonly Add = 11;
|
|
14
|
+
static readonly At = 12;
|
|
15
|
+
static readonly To = 13;
|
|
16
|
+
static readonly Point = 14;
|
|
17
|
+
static readonly Join = 15;
|
|
18
|
+
static readonly Parallel = 16;
|
|
19
|
+
static readonly Return = 17;
|
|
20
|
+
static readonly Define = 18;
|
|
21
|
+
static readonly Import = 19;
|
|
22
|
+
static readonly From = 20;
|
|
23
|
+
static readonly For = 21;
|
|
24
|
+
static readonly In = 22;
|
|
25
|
+
static readonly While = 23;
|
|
26
|
+
static readonly Continue = 24;
|
|
27
|
+
static readonly If = 25;
|
|
28
|
+
static readonly Else = 26;
|
|
29
|
+
static readonly Not = 27;
|
|
30
|
+
static readonly Frame = 28;
|
|
31
|
+
static readonly Sheet = 29;
|
|
32
|
+
static readonly Set = 30;
|
|
33
|
+
static readonly Colon = 31;
|
|
34
|
+
static readonly Comma = 32;
|
|
35
|
+
static readonly Dot = 33;
|
|
36
|
+
static readonly DoubleDot = 34;
|
|
37
|
+
static readonly LSquare = 35;
|
|
38
|
+
static readonly RSquare = 36;
|
|
39
|
+
static readonly Assign = 37;
|
|
40
|
+
static readonly Equals = 38;
|
|
41
|
+
static readonly NotEquals = 39;
|
|
42
|
+
static readonly GreaterThan = 40;
|
|
43
|
+
static readonly GreatOrEqualThan = 41;
|
|
44
|
+
static readonly LessThan = 42;
|
|
45
|
+
static readonly LessOrEqualThan = 43;
|
|
46
|
+
static readonly LogicalAnd = 44;
|
|
47
|
+
static readonly LogicalOr = 45;
|
|
48
|
+
static readonly Addition = 46;
|
|
49
|
+
static readonly Minus = 47;
|
|
50
|
+
static readonly Divide = 48;
|
|
51
|
+
static readonly Multiply = 49;
|
|
52
|
+
static readonly Modulus = 50;
|
|
53
|
+
static readonly AdditionAssign = 51;
|
|
54
|
+
static readonly MinusAssign = 52;
|
|
55
|
+
static readonly DivideAssign = 53;
|
|
56
|
+
static readonly MultiplyAssign = 54;
|
|
57
|
+
static readonly ModulusAssign = 55;
|
|
58
|
+
static readonly NEWLINE = 56;
|
|
59
|
+
static readonly WS = 57;
|
|
60
|
+
static readonly COMMENT = 58;
|
|
61
|
+
static readonly LParen = 59;
|
|
62
|
+
static readonly RParen = 60;
|
|
63
|
+
static readonly NOT_CONNECTED = 61;
|
|
64
|
+
static readonly BOOLEAN_VALUE = 62;
|
|
65
|
+
static readonly ANNOTATION_START = 63;
|
|
66
|
+
static readonly INTEGER_VALUE = 64;
|
|
67
|
+
static readonly DECIMAL_VALUE = 65;
|
|
68
|
+
static readonly NUMERIC_VALUE = 66;
|
|
69
|
+
static readonly PERCENTAGE_VALUE = 67;
|
|
70
|
+
static readonly STRING_VALUE = 68;
|
|
71
|
+
static readonly ID = 69;
|
|
71
72
|
static readonly channelNames: string[];
|
|
72
73
|
static readonly literalNames: (string | null)[];
|
|
73
74
|
static readonly symbolicNames: (string | null)[];
|
|
@@ -82,9 +83,9 @@ export declare class CircuitScriptLexer extends antlr.Lexer {
|
|
|
82
83
|
get channelNames(): string[];
|
|
83
84
|
get modeNames(): string[];
|
|
84
85
|
action(localContext: antlr.ParserRuleContext | null, ruleIndex: number, actionIndex: number): void;
|
|
85
|
-
private OPEN_PAREN_action;
|
|
86
|
-
private CLOSE_PAREN_action;
|
|
87
86
|
private NEWLINE_action;
|
|
87
|
+
private LParen_action;
|
|
88
|
+
private RParen_action;
|
|
88
89
|
static readonly _serializedATN: number[];
|
|
89
90
|
private static __ATN;
|
|
90
91
|
static get _ATN(): antlr.ATN;
|