circuitscript 0.1.11 → 0.1.13
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 +147 -115
- package/dist/cjs/antlr/CircuitScriptParser.js +949 -932
- package/dist/cjs/builtinMethods.js +7 -1
- package/dist/cjs/execute.js +67 -35
- package/dist/cjs/globals.js +7 -1
- package/dist/cjs/helpers.js +11 -8
- package/dist/cjs/layout.js +50 -16
- package/dist/cjs/objects/ExecutionScope.js +3 -0
- package/dist/cjs/objects/Net.js +1 -0
- package/dist/cjs/objects/ParamDefinition.js +3 -0
- package/dist/cjs/objects/types.js +19 -10
- package/dist/cjs/parser.js +3 -1
- package/dist/cjs/render.js +48 -6
- package/dist/cjs/utils.js +16 -1
- package/dist/cjs/visitor.js +69 -52
- package/dist/esm/BaseVisitor.js +113 -81
- package/dist/esm/antlr/CircuitScriptParser.js +943 -926
- package/dist/esm/antlr/CircuitScriptVisitor.js +4 -4
- package/dist/esm/builtinMethods.js +8 -2
- package/dist/esm/execute.js +68 -36
- package/dist/esm/globals.js +6 -0
- package/dist/esm/helpers.js +11 -8
- package/dist/esm/layout.js +53 -17
- package/dist/esm/objects/ExecutionScope.js +3 -0
- package/dist/esm/objects/Net.js +1 -0
- package/dist/esm/objects/ParamDefinition.js +4 -1
- package/dist/esm/objects/types.js +21 -15
- package/dist/esm/parser.js +3 -1
- package/dist/esm/render.js +49 -7
- package/dist/esm/utils.js +13 -0
- package/dist/esm/visitor.js +57 -40
- package/dist/types/BaseVisitor.d.ts +5 -6
- package/dist/types/antlr/CircuitScriptParser.d.ts +58 -58
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +8 -8
- package/dist/types/execute.d.ts +4 -2
- package/dist/types/globals.d.ts +5 -0
- package/dist/types/layout.d.ts +16 -3
- package/dist/types/objects/ExecutionScope.d.ts +15 -3
- package/dist/types/objects/Net.d.ts +1 -0
- package/dist/types/objects/types.d.ts +25 -18
- package/dist/types/parser.d.ts +1 -0
- package/dist/types/utils.d.ts +3 -1
- package/dist/types/visitor.d.ts +3 -2
- package/package.json +1 -1
- /package/dist/libs/{lib.cst → std.cst} +0 -0
- /package/libs/{lib.cst → std.cst} +0 -0
package/dist/esm/render.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SVG, registerWindow } from '@svgdotjs/svg.js';
|
|
2
2
|
import { ExtractDrawingRects, RenderFrameType, getBounds } from "./layout.js";
|
|
3
3
|
import { applyFontsToSVG } from './sizing.js';
|
|
4
|
-
import { ColorScheme, ComponentTypes, FrameType, MMToPt, MMToPx, ParamKeys, RenderFlags, defaultGridSizeUnits, defaultPageSpacingMM, defaultWireLineWidth, fontDisplayScale, junctionSize } from './globals.js';
|
|
4
|
+
import { ColorScheme, ComponentTypes, FrameType, MMToPt, MMToPx, MilsToMM, ParamKeys, RenderFlags, defaultGridSizeUnits, defaultPageSpacingMM, defaultWireLineWidth, fontDisplayScale, junctionSize } from './globals.js';
|
|
5
5
|
import { numeric, NumericValue } from './objects/ParamDefinition.js';
|
|
6
6
|
import { combineMaps, getBoundsSize } from './utils.js';
|
|
7
7
|
import { getPaperSize, milsToMM } from './helpers.js';
|
|
@@ -169,28 +169,70 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
|
|
|
169
169
|
.translate(wire.x.add(5).toNumber(), wire.y.add(5).toNumber());
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
+
const mergedWireHighlightGroup = canvas.group();
|
|
172
173
|
const mergedWireGroup = canvas.group();
|
|
173
174
|
mergedWires.forEach(tmpItem => {
|
|
174
|
-
const { segments, intersectPoints } = tmpItem;
|
|
175
|
+
const { segments, intersectPoints, net = null } = tmpItem;
|
|
176
|
+
let useJunctionColor = ColorScheme.JunctionColor;
|
|
177
|
+
let useColor = ColorScheme.WireColor;
|
|
178
|
+
let useLineWidth = defaultWireLineWidth;
|
|
179
|
+
let displayHighlight = false;
|
|
180
|
+
let displayHighlightColor = null;
|
|
181
|
+
if (net !== null) {
|
|
182
|
+
useColor = net.color ?? ColorScheme.WireColor;
|
|
183
|
+
useJunctionColor = net.color ?? ColorScheme.JunctionColor;
|
|
184
|
+
useLineWidth = net.lineWidth ?? defaultWireLineWidth;
|
|
185
|
+
if (net.highlight !== null) {
|
|
186
|
+
displayHighlight = true;
|
|
187
|
+
displayHighlightColor = net.highlight ?? null;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const pathItems = [];
|
|
191
|
+
const highlightExtraSize = 5 * MilsToMM;
|
|
175
192
|
segments.forEach(segment => {
|
|
176
193
|
const pt1 = segment[0];
|
|
177
194
|
const pt2 = segment[1];
|
|
178
|
-
|
|
195
|
+
pathItems.push(...[
|
|
196
|
+
'M', pt1[0], pt1[1],
|
|
197
|
+
'L', pt2[0], pt2[1]
|
|
198
|
+
]);
|
|
199
|
+
});
|
|
200
|
+
if (displayHighlight) {
|
|
201
|
+
mergedWireHighlightGroup.path(pathItems)
|
|
179
202
|
.stroke({
|
|
180
|
-
width:
|
|
181
|
-
color:
|
|
203
|
+
width: useLineWidth + highlightExtraSize,
|
|
204
|
+
color: displayHighlightColor,
|
|
205
|
+
opacity: 0.3,
|
|
182
206
|
linecap: 'square'
|
|
183
207
|
})
|
|
184
208
|
.fill('none');
|
|
185
|
-
}
|
|
209
|
+
}
|
|
210
|
+
mergedWireGroup.path(pathItems)
|
|
211
|
+
.stroke({
|
|
212
|
+
width: useLineWidth,
|
|
213
|
+
color: useColor,
|
|
214
|
+
linecap: 'square'
|
|
215
|
+
})
|
|
216
|
+
.fill('none');
|
|
186
217
|
const halfJunctionSize = junctionSize.half();
|
|
218
|
+
const highlightJunctionSize = numeric(junctionSize.toNumber() + highlightExtraSize);
|
|
219
|
+
const tmpHighlightExtraSize = highlightJunctionSize.half();
|
|
187
220
|
intersectPoints.forEach(point => {
|
|
188
221
|
const [x, y,] = point;
|
|
189
222
|
const translateX = numeric(x).sub(halfJunctionSize);
|
|
190
223
|
const translateY = numeric(y).sub(halfJunctionSize);
|
|
224
|
+
if (displayHighlight && displayHighlightColor !== null) {
|
|
225
|
+
const tmpTranslateX = numeric(x).sub(tmpHighlightExtraSize);
|
|
226
|
+
const tmpTranslateY = numeric(y).sub(tmpHighlightExtraSize);
|
|
227
|
+
mergedWireHighlightGroup.circle(highlightJunctionSize.toNumber())
|
|
228
|
+
.translate(tmpTranslateX.toNumber(), tmpTranslateY.toNumber())
|
|
229
|
+
.fill(displayHighlightColor)
|
|
230
|
+
.opacity(0.3)
|
|
231
|
+
.stroke('none');
|
|
232
|
+
}
|
|
191
233
|
mergedWireGroup.circle(junctionSize.toNumber())
|
|
192
234
|
.translate(translateX.toNumber(), translateY.toNumber())
|
|
193
|
-
.fill(
|
|
235
|
+
.fill(useJunctionColor)
|
|
194
236
|
.stroke('none');
|
|
195
237
|
});
|
|
196
238
|
});
|
package/dist/esm/utils.js
CHANGED
|
@@ -4,6 +4,7 @@ import { ClassComponent } from "./objects/ClassComponent.js";
|
|
|
4
4
|
import { NumericValue } from "./objects/ParamDefinition.js";
|
|
5
5
|
import { SequenceAction } from './objects/ExecutionScope.js';
|
|
6
6
|
import { BlockTypes } from './globals.js';
|
|
7
|
+
import { DeclaredReference, AnyReference } from './objects/types.js';
|
|
7
8
|
export class SimpleStopwatch {
|
|
8
9
|
startTime;
|
|
9
10
|
constructor() {
|
|
@@ -325,3 +326,15 @@ export function printWarnings(warnings) {
|
|
|
325
326
|
console.log(`Warning: ${message}`);
|
|
326
327
|
});
|
|
327
328
|
}
|
|
329
|
+
export function unwrapValue(value) {
|
|
330
|
+
if (isReference(value)) {
|
|
331
|
+
return value.value;
|
|
332
|
+
}
|
|
333
|
+
else {
|
|
334
|
+
return value;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
export function isReference(value) {
|
|
338
|
+
return (value instanceof AnyReference ||
|
|
339
|
+
value instanceof DeclaredReference);
|
|
340
|
+
}
|
package/dist/esm/visitor.js
CHANGED
|
@@ -4,6 +4,7 @@ import { PinDefinition, PinIdType } from './objects/PinDefinition.js';
|
|
|
4
4
|
import { PinTypes } from './objects/PinTypes.js';
|
|
5
5
|
import { DeclaredReference, UndeclaredReference } from './objects/types.js';
|
|
6
6
|
import { BlockTypes, ComponentTypes, Delimiter1, FrameType, GlobalDocumentName, ModuleContainsKeyword, NoNetText, ParamKeys, ReferenceTypes, SymbolPinSide, ValidPinSides, WireAutoDirection } from './globals.js';
|
|
7
|
+
import { unwrapValue } from "./utils.js";
|
|
7
8
|
import { PlaceHolderCommands, SymbolDrawingCommands } from './draw_symbols.js';
|
|
8
9
|
import { BaseVisitor } from './BaseVisitor.js';
|
|
9
10
|
import { getPortType, RuntimeExecutionError } from './utils.js';
|
|
@@ -82,39 +83,55 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
82
83
|
}
|
|
83
84
|
this.setResult(ctx, componentPin);
|
|
84
85
|
};
|
|
85
|
-
|
|
86
|
-
const blocks = ctx.path_block_inner();
|
|
87
|
-
let blockIndex = 0;
|
|
86
|
+
visitPath_block = (ctx) => {
|
|
88
87
|
let blockType = BlockTypes.Branch;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
if (ctx.Branch()) {
|
|
89
|
+
blockType = BlockTypes.Branch;
|
|
90
|
+
}
|
|
91
|
+
else if (ctx.Join()) {
|
|
92
|
+
blockType = BlockTypes.Join;
|
|
93
|
+
}
|
|
94
|
+
else if (ctx.Parallel()) {
|
|
95
|
+
blockType = BlockTypes.Parallel;
|
|
96
|
+
}
|
|
97
|
+
else if (ctx.Point()) {
|
|
98
|
+
blockType = BlockTypes.Point;
|
|
99
|
+
}
|
|
100
|
+
const scope = this.getScope();
|
|
101
|
+
const executor = this.getExecutor();
|
|
102
|
+
const indentLevel = scope.indentLevel;
|
|
103
|
+
if (scope.blockStack.has(indentLevel)) {
|
|
104
|
+
const blockStackEntry = scope.blockStack.get(indentLevel);
|
|
105
|
+
if (blockStackEntry.type !== blockType) {
|
|
106
|
+
executor.exitBlocks();
|
|
102
107
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
}
|
|
109
|
+
if (!scope.blockStack.has(indentLevel)) {
|
|
110
|
+
executor.enterBlocks(blockType);
|
|
111
|
+
}
|
|
112
|
+
const blockStackEntry = scope.blockStack.get(indentLevel);
|
|
113
|
+
const { current_index } = blockStackEntry;
|
|
114
|
+
executor.enterBlock(current_index);
|
|
115
|
+
this.visit(ctx.expressions_block());
|
|
116
|
+
executor.exitBlock(current_index);
|
|
117
|
+
blockStackEntry.current_index++;
|
|
118
|
+
};
|
|
119
|
+
visitGraph_expressions = (ctx) => {
|
|
120
|
+
if (ctx.path_block() === null) {
|
|
121
|
+
const scope = this.getScope();
|
|
122
|
+
const indentLevel = scope.indentLevel;
|
|
123
|
+
if (scope.blockStack.has(indentLevel)) {
|
|
124
|
+
this.getExecutor().exitBlocks();
|
|
109
125
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
}
|
|
127
|
+
const ctxPathBlock = ctx.path_block();
|
|
128
|
+
const ctxNotPathBlock = ctx.graph_linear_expression();
|
|
129
|
+
if (ctxPathBlock) {
|
|
130
|
+
this.visit(ctxPathBlock);
|
|
131
|
+
}
|
|
132
|
+
if (ctxNotPathBlock) {
|
|
133
|
+
this.visit(ctxNotPathBlock);
|
|
134
|
+
}
|
|
118
135
|
};
|
|
119
136
|
visitCreate_component_expr = (ctx) => {
|
|
120
137
|
const scope = this.getScope();
|
|
@@ -293,7 +310,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
293
310
|
if (ctxId !== null) {
|
|
294
311
|
const varName = ctxId.getText();
|
|
295
312
|
paramIds.push(varName);
|
|
296
|
-
this.getScope().
|
|
313
|
+
this.getScope().setVariable(varName, {});
|
|
297
314
|
}
|
|
298
315
|
const executor = this.getExecutor();
|
|
299
316
|
const stack = [...this.executionStack];
|
|
@@ -303,7 +320,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
303
320
|
variables.forEach((value, key) => {
|
|
304
321
|
obj[key] = value;
|
|
305
322
|
});
|
|
306
|
-
executor.scope.
|
|
323
|
+
executor.scope.setVariable(paramIds[0], obj);
|
|
307
324
|
}
|
|
308
325
|
const currentStack = this.executionStack.splice(0);
|
|
309
326
|
this.executionStack.push(...stack);
|
|
@@ -384,7 +401,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
384
401
|
};
|
|
385
402
|
visitGraphicForExpr = (ctx) => {
|
|
386
403
|
const forVariableNames = ctx.ID().map(item => item.getText());
|
|
387
|
-
const listItems = this.visitResult(ctx.data_expr());
|
|
404
|
+
const listItems = unwrapValue(this.visitResult(ctx.data_expr()));
|
|
388
405
|
let keepLooping = true;
|
|
389
406
|
let counter = 0;
|
|
390
407
|
let allCommands = [];
|
|
@@ -395,7 +412,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
395
412
|
useValueArray = [useValueArray];
|
|
396
413
|
}
|
|
397
414
|
useValueArray.forEach((value, index) => {
|
|
398
|
-
this.getScope().
|
|
415
|
+
this.getScope().setVariable(forVariableNames[index], value);
|
|
399
416
|
});
|
|
400
417
|
const commands = this.visitResult(ctx.graphic_expressions_block());
|
|
401
418
|
allCommands = allCommands.concat(commands);
|
|
@@ -526,6 +543,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
526
543
|
const ctxAssignmentExpr = ctx.assignment_expr();
|
|
527
544
|
if (ctxDataExpr) {
|
|
528
545
|
component = this.visitResult(ctxDataExpr);
|
|
546
|
+
component = unwrapValue(component);
|
|
529
547
|
componentCtx = ctxDataExpr;
|
|
530
548
|
if (component === null || component === undefined) {
|
|
531
549
|
this.throwWithContext(ctxDataExpr, "Could not find component: " + ctxDataExpr.getText());
|
|
@@ -867,15 +885,13 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
867
885
|
const executor = this.getExecutor();
|
|
868
886
|
executor.log('entering at block');
|
|
869
887
|
this.visit(ctx.at_component_expr());
|
|
870
|
-
const currentComponent = executor.
|
|
871
|
-
const currentPin = executor.scope.currentPin;
|
|
888
|
+
const [currentComponent, currentPin] = executor.getCurrentPoint();
|
|
872
889
|
executor.scope.indentLevel += 1;
|
|
873
890
|
ctx.at_block_expressions().forEach(expression => {
|
|
874
891
|
this.visit(expression);
|
|
875
892
|
});
|
|
876
893
|
executor.scope.indentLevel -= 1;
|
|
877
|
-
executor.scope.currentComponent
|
|
878
|
-
executor.scope.currentPin = currentPin;
|
|
894
|
+
executor.scope.setCurrent(currentComponent, currentPin);
|
|
879
895
|
executor.log('leaving at block');
|
|
880
896
|
};
|
|
881
897
|
visitAt_block_pin_expression_simple = (ctx) => {
|
|
@@ -1057,7 +1073,8 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1057
1073
|
visitFor_expr = (ctx) => {
|
|
1058
1074
|
this.log('in for loop');
|
|
1059
1075
|
const forVariableNames = ctx.ID().map(item => item.getText());
|
|
1060
|
-
|
|
1076
|
+
let listItems = this.visitResult(ctx.data_expr());
|
|
1077
|
+
listItems = unwrapValue(listItems);
|
|
1061
1078
|
this.getExecutor().addBreakContext(ctx);
|
|
1062
1079
|
let keepLooping = true;
|
|
1063
1080
|
let counter = 0;
|
|
@@ -1068,7 +1085,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1068
1085
|
useValueArray = [useValueArray];
|
|
1069
1086
|
}
|
|
1070
1087
|
useValueArray.forEach((value, index) => {
|
|
1071
|
-
this.getScope().
|
|
1088
|
+
this.getScope().setVariable(forVariableNames[index], value);
|
|
1072
1089
|
});
|
|
1073
1090
|
this.visit(ctx.expressions_block());
|
|
1074
1091
|
keepLooping = true;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Array_exprContext, ArrayExprContext, Assignment_exprContext, Atom_exprContext,
|
|
1
|
+
import { Array_exprContext, ArrayExprContext, Assignment_exprContext, Atom_exprContext, ExpressionContext, Flow_expressionsContext, Function_args_exprContext, Function_call_exprContext, Function_exprContext, Function_return_exprContext, FunctionCallExprContext, Import_exprContext, Operator_assignment_exprContext, ParametersContext, RoundedBracketsExprContext, ScriptContext, Value_exprContext, ValueAtomExprContext } from "./antlr/CircuitScriptParser.js";
|
|
2
2
|
import { CircuitScriptVisitor } from "./antlr/CircuitScriptVisitor.js";
|
|
3
3
|
import { ExecutionContext } from "./execute.js";
|
|
4
4
|
import { Logger } from "./logger.js";
|
|
5
5
|
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
6
6
|
import { Net } from "./objects/Net.js";
|
|
7
|
-
import { CallableParameter, CFunctionOptions, ComplexType, Direction, FunctionDefinedParameter,
|
|
7
|
+
import { CallableParameter, CFunctionOptions, ComplexType, Direction, FunctionDefinedParameter, AnyReference } from "./objects/types.js";
|
|
8
8
|
import { 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
12
|
import { NodeScriptEnvironment } from "./environment.js";
|
|
13
|
-
export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType |
|
|
13
|
+
export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyReference | any> {
|
|
14
14
|
indentLevel: number;
|
|
15
15
|
startingContext: ExecutionContext;
|
|
16
16
|
executionStack: ExecutionContext[];
|
|
@@ -20,7 +20,6 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | Refe
|
|
|
20
20
|
printToConsole: boolean;
|
|
21
21
|
acceptedDirections: Direction[];
|
|
22
22
|
protected resultData: Map<ParserRuleContext, any>;
|
|
23
|
-
protected paramData: Map<ParserRuleContext, any>;
|
|
24
23
|
pinTypesList: string[];
|
|
25
24
|
onErrorHandler: OnErrorHandler | null;
|
|
26
25
|
environment: NodeScriptEnvironment;
|
|
@@ -50,14 +49,14 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | Refe
|
|
|
50
49
|
visitAtom_expr: (ctx: Atom_exprContext) => void;
|
|
51
50
|
visitFunctionCallExpr: (ctx: FunctionCallExprContext) => void;
|
|
52
51
|
visitFunction_call_expr: (ctx: Function_call_exprContext) => void;
|
|
52
|
+
private handleFunctionCall;
|
|
53
53
|
visitValue_expr: (ctx: Value_exprContext) => void;
|
|
54
54
|
visitValueAtomExpr: (ctx: ValueAtomExprContext) => void;
|
|
55
55
|
visitFunction_args_expr: (ctx: Function_args_exprContext) => void;
|
|
56
56
|
visitParameters: (ctx: ParametersContext) => void;
|
|
57
57
|
visitImport_expr: (ctx: Import_exprContext) => void;
|
|
58
58
|
visitFunction_return_expr: (ctx: Function_return_exprContext) => void;
|
|
59
|
-
|
|
60
|
-
visitContinue_keyword: (ctx: Continue_keywordContext) => void;
|
|
59
|
+
visitFlow_expressions: (ctx: Flow_expressionsContext) => void;
|
|
61
60
|
visitArray_expr: (ctx: Array_exprContext) => void;
|
|
62
61
|
visitArrayExpr: (ctx: ArrayExprContext) => void;
|
|
63
62
|
protected setResult(ctx: ParserRuleContext, value: any): void;
|
|
@@ -71,29 +71,29 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
71
71
|
static readonly DEDENT = 67;
|
|
72
72
|
static readonly RULE_script = 0;
|
|
73
73
|
static readonly RULE_expression = 1;
|
|
74
|
-
static readonly
|
|
75
|
-
static readonly
|
|
76
|
-
static readonly
|
|
77
|
-
static readonly
|
|
78
|
-
static readonly
|
|
79
|
-
static readonly
|
|
80
|
-
static readonly
|
|
81
|
-
static readonly
|
|
82
|
-
static readonly
|
|
83
|
-
static readonly
|
|
84
|
-
static readonly
|
|
85
|
-
static readonly
|
|
86
|
-
static readonly
|
|
87
|
-
static readonly
|
|
88
|
-
static readonly
|
|
89
|
-
static readonly
|
|
90
|
-
static readonly
|
|
91
|
-
static readonly
|
|
92
|
-
static readonly
|
|
93
|
-
static readonly
|
|
94
|
-
static readonly
|
|
95
|
-
static readonly
|
|
96
|
-
static readonly
|
|
74
|
+
static readonly RULE_flow_expressions = 2;
|
|
75
|
+
static readonly RULE_graph_expressions = 3;
|
|
76
|
+
static readonly RULE_graph_linear_expression = 4;
|
|
77
|
+
static readonly RULE_expressions_block = 5;
|
|
78
|
+
static readonly RULE_path_block = 6;
|
|
79
|
+
static readonly RULE_property_set_expr2 = 7;
|
|
80
|
+
static readonly RULE_assignment_expr2 = 8;
|
|
81
|
+
static readonly RULE_pin_select_expr = 9;
|
|
82
|
+
static readonly RULE_component_modifier_expr = 10;
|
|
83
|
+
static readonly RULE_data_expr_with_assignment = 11;
|
|
84
|
+
static readonly RULE_add_component_expr = 12;
|
|
85
|
+
static readonly RULE_component_select_expr = 13;
|
|
86
|
+
static readonly RULE_pin_select_expr2 = 14;
|
|
87
|
+
static readonly RULE_at_component_expr = 15;
|
|
88
|
+
static readonly RULE_to_component_expr = 16;
|
|
89
|
+
static readonly RULE_at_to_multiple_expr = 17;
|
|
90
|
+
static readonly RULE_at_to_multiple_line_expr = 18;
|
|
91
|
+
static readonly RULE_at_to_multiple_line_expr_to_pin = 19;
|
|
92
|
+
static readonly RULE_at_block = 20;
|
|
93
|
+
static readonly RULE_at_block_expressions = 21;
|
|
94
|
+
static readonly RULE_at_block_pin_expr = 22;
|
|
95
|
+
static readonly RULE_at_block_pin_expression_simple = 23;
|
|
96
|
+
static readonly RULE_at_block_pin_expression_complex = 24;
|
|
97
97
|
static readonly RULE_assignment_expr = 25;
|
|
98
98
|
static readonly RULE_operator_assignment_expr = 26;
|
|
99
99
|
static readonly RULE_keyword_assignment_expr = 27;
|
|
@@ -145,9 +145,11 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
145
145
|
constructor(input: antlr.TokenStream);
|
|
146
146
|
script(): ScriptContext;
|
|
147
147
|
expression(): ExpressionContext;
|
|
148
|
+
flow_expressions(): Flow_expressionsContext;
|
|
149
|
+
graph_expressions(): Graph_expressionsContext;
|
|
150
|
+
graph_linear_expression(): Graph_linear_expressionContext;
|
|
148
151
|
expressions_block(): Expressions_blockContext;
|
|
149
|
-
|
|
150
|
-
path_block_inner(): Path_block_innerContext;
|
|
152
|
+
path_block(): Path_blockContext;
|
|
151
153
|
property_set_expr2(): Property_set_expr2Context;
|
|
152
154
|
assignment_expr2(): Assignment_expr2Context;
|
|
153
155
|
pin_select_expr(): Pin_select_exprContext;
|
|
@@ -166,8 +168,6 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
166
168
|
at_block_pin_expr(): At_block_pin_exprContext;
|
|
167
169
|
at_block_pin_expression_simple(): At_block_pin_expression_simpleContext;
|
|
168
170
|
at_block_pin_expression_complex(): At_block_pin_expression_complexContext;
|
|
169
|
-
break_keyword(): Break_keywordContext;
|
|
170
|
-
continue_keyword(): Continue_keywordContext;
|
|
171
171
|
assignment_expr(): Assignment_exprContext;
|
|
172
172
|
operator_assignment_expr(): Operator_assignment_exprContext;
|
|
173
173
|
keyword_assignment_expr(): Keyword_assignment_exprContext;
|
|
@@ -231,28 +231,46 @@ export declare class ScriptContext extends antlr.ParserRuleContext {
|
|
|
231
231
|
}
|
|
232
232
|
export declare class ExpressionContext extends antlr.ParserRuleContext {
|
|
233
233
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
234
|
-
|
|
235
|
-
to_component_expr(): To_component_exprContext | null;
|
|
236
|
-
at_component_expr(): At_component_exprContext | null;
|
|
234
|
+
graph_expressions(): Graph_expressionsContext | null;
|
|
237
235
|
assignment_expr(): Assignment_exprContext | null;
|
|
238
236
|
operator_assignment_expr(): Operator_assignment_exprContext | null;
|
|
239
237
|
property_set_expr(): Property_set_exprContext | null;
|
|
240
238
|
property_set_expr2(): Property_set_expr2Context | null;
|
|
241
239
|
double_dot_property_set_expr(): Double_dot_property_set_exprContext | null;
|
|
242
|
-
break_keyword(): Break_keywordContext | null;
|
|
243
|
-
continue_keyword(): Continue_keywordContext | null;
|
|
244
240
|
function_def_expr(): Function_def_exprContext | null;
|
|
245
241
|
function_call_expr(): Function_call_exprContext | null;
|
|
246
|
-
wire_expr(): Wire_exprContext | null;
|
|
247
242
|
import_expr(): Import_exprContext | null;
|
|
248
|
-
frame_expr(): Frame_exprContext | null;
|
|
249
243
|
atom_expr(): Atom_exprContext | null;
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
244
|
+
frame_expr(): Frame_exprContext | null;
|
|
245
|
+
flow_expressions(): Flow_expressionsContext | null;
|
|
246
|
+
get ruleIndex(): number;
|
|
247
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
248
|
+
}
|
|
249
|
+
export declare class Flow_expressionsContext extends antlr.ParserRuleContext {
|
|
250
|
+
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
253
251
|
if_expr(): If_exprContext | null;
|
|
254
252
|
while_expr(): While_exprContext | null;
|
|
255
253
|
for_expr(): For_exprContext | null;
|
|
254
|
+
Break(): antlr.TerminalNode | null;
|
|
255
|
+
Continue(): antlr.TerminalNode | null;
|
|
256
|
+
get ruleIndex(): number;
|
|
257
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
258
|
+
}
|
|
259
|
+
export declare class Graph_expressionsContext extends antlr.ParserRuleContext {
|
|
260
|
+
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
261
|
+
graph_linear_expression(): Graph_linear_expressionContext | null;
|
|
262
|
+
path_block(): Path_blockContext | null;
|
|
263
|
+
get ruleIndex(): number;
|
|
264
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
265
|
+
}
|
|
266
|
+
export declare class Graph_linear_expressionContext extends antlr.ParserRuleContext {
|
|
267
|
+
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
268
|
+
add_component_expr(): Add_component_exprContext | null;
|
|
269
|
+
to_component_expr(): To_component_exprContext | null;
|
|
270
|
+
at_component_expr(): At_component_exprContext | null;
|
|
271
|
+
at_block(): At_blockContext | null;
|
|
272
|
+
wire_expr(): Wire_exprContext | null;
|
|
273
|
+
point_expr(): Point_exprContext | null;
|
|
256
274
|
get ruleIndex(): number;
|
|
257
275
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
258
276
|
}
|
|
@@ -267,14 +285,7 @@ export declare class Expressions_blockContext extends antlr.ParserRuleContext {
|
|
|
267
285
|
get ruleIndex(): number;
|
|
268
286
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
269
287
|
}
|
|
270
|
-
export declare class
|
|
271
|
-
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
272
|
-
path_block_inner(): Path_block_innerContext[];
|
|
273
|
-
path_block_inner(i: number): Path_block_innerContext | null;
|
|
274
|
-
get ruleIndex(): number;
|
|
275
|
-
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
276
|
-
}
|
|
277
|
-
export declare class Path_block_innerContext extends antlr.ParserRuleContext {
|
|
288
|
+
export declare class Path_blockContext extends antlr.ParserRuleContext {
|
|
278
289
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
279
290
|
expressions_block(): Expressions_blockContext;
|
|
280
291
|
Branch(): antlr.TerminalNode | null;
|
|
@@ -436,22 +447,11 @@ export declare class At_block_pin_expression_complexContext extends antlr.Parser
|
|
|
436
447
|
get ruleIndex(): number;
|
|
437
448
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
438
449
|
}
|
|
439
|
-
export declare class Break_keywordContext extends antlr.ParserRuleContext {
|
|
440
|
-
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
441
|
-
Break(): antlr.TerminalNode;
|
|
442
|
-
get ruleIndex(): number;
|
|
443
|
-
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
444
|
-
}
|
|
445
|
-
export declare class Continue_keywordContext extends antlr.ParserRuleContext {
|
|
446
|
-
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
447
|
-
Continue(): antlr.TerminalNode;
|
|
448
|
-
get ruleIndex(): number;
|
|
449
|
-
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
450
|
-
}
|
|
451
450
|
export declare class Assignment_exprContext extends antlr.ParserRuleContext {
|
|
452
451
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
453
|
-
atom_expr(): Atom_exprContext;
|
|
454
452
|
data_expr(): Data_exprContext;
|
|
453
|
+
atom_expr(): Atom_exprContext | null;
|
|
454
|
+
function_call_expr(): Function_call_exprContext | null;
|
|
455
455
|
get ruleIndex(): number;
|
|
456
456
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
457
457
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { AbstractParseTreeVisitor } from "antlr4ng";
|
|
2
2
|
import { ScriptContext } from "./CircuitScriptParser.js";
|
|
3
3
|
import { ExpressionContext } from "./CircuitScriptParser.js";
|
|
4
|
+
import { Flow_expressionsContext } from "./CircuitScriptParser.js";
|
|
5
|
+
import { Graph_expressionsContext } from "./CircuitScriptParser.js";
|
|
6
|
+
import { Graph_linear_expressionContext } from "./CircuitScriptParser.js";
|
|
4
7
|
import { Expressions_blockContext } from "./CircuitScriptParser.js";
|
|
5
|
-
import {
|
|
6
|
-
import { Path_block_innerContext } from "./CircuitScriptParser.js";
|
|
8
|
+
import { Path_blockContext } from "./CircuitScriptParser.js";
|
|
7
9
|
import { Property_set_expr2Context } from "./CircuitScriptParser.js";
|
|
8
10
|
import { Assignment_expr2Context } from "./CircuitScriptParser.js";
|
|
9
11
|
import { Pin_select_exprContext } from "./CircuitScriptParser.js";
|
|
@@ -22,8 +24,6 @@ import { At_block_expressionsContext } from "./CircuitScriptParser.js";
|
|
|
22
24
|
import { At_block_pin_exprContext } from "./CircuitScriptParser.js";
|
|
23
25
|
import { At_block_pin_expression_simpleContext } from "./CircuitScriptParser.js";
|
|
24
26
|
import { At_block_pin_expression_complexContext } from "./CircuitScriptParser.js";
|
|
25
|
-
import { Break_keywordContext } from "./CircuitScriptParser.js";
|
|
26
|
-
import { Continue_keywordContext } from "./CircuitScriptParser.js";
|
|
27
27
|
import { Assignment_exprContext } from "./CircuitScriptParser.js";
|
|
28
28
|
import { Operator_assignment_exprContext } from "./CircuitScriptParser.js";
|
|
29
29
|
import { Keyword_assignment_exprContext } from "./CircuitScriptParser.js";
|
|
@@ -78,9 +78,11 @@ import { For_exprContext } from "./CircuitScriptParser.js";
|
|
|
78
78
|
export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisitor<Result> {
|
|
79
79
|
visitScript?: (ctx: ScriptContext) => Result;
|
|
80
80
|
visitExpression?: (ctx: ExpressionContext) => Result;
|
|
81
|
+
visitFlow_expressions?: (ctx: Flow_expressionsContext) => Result;
|
|
82
|
+
visitGraph_expressions?: (ctx: Graph_expressionsContext) => Result;
|
|
83
|
+
visitGraph_linear_expression?: (ctx: Graph_linear_expressionContext) => Result;
|
|
81
84
|
visitExpressions_block?: (ctx: Expressions_blockContext) => Result;
|
|
82
|
-
|
|
83
|
-
visitPath_block_inner?: (ctx: Path_block_innerContext) => Result;
|
|
85
|
+
visitPath_block?: (ctx: Path_blockContext) => Result;
|
|
84
86
|
visitProperty_set_expr2?: (ctx: Property_set_expr2Context) => Result;
|
|
85
87
|
visitAssignment_expr2?: (ctx: Assignment_expr2Context) => Result;
|
|
86
88
|
visitPin_select_expr?: (ctx: Pin_select_exprContext) => Result;
|
|
@@ -99,8 +101,6 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
|
|
|
99
101
|
visitAt_block_pin_expr?: (ctx: At_block_pin_exprContext) => Result;
|
|
100
102
|
visitAt_block_pin_expression_simple?: (ctx: At_block_pin_expression_simpleContext) => Result;
|
|
101
103
|
visitAt_block_pin_expression_complex?: (ctx: At_block_pin_expression_complexContext) => Result;
|
|
102
|
-
visitBreak_keyword?: (ctx: Break_keywordContext) => Result;
|
|
103
|
-
visitContinue_keyword?: (ctx: Continue_keywordContext) => Result;
|
|
104
104
|
visitAssignment_expr?: (ctx: Assignment_exprContext) => Result;
|
|
105
105
|
visitOperator_assignment_expr?: (ctx: Operator_assignment_exprContext) => Result;
|
|
106
106
|
visitKeyword_assignment_expr?: (ctx: Keyword_assignment_exprContext) => Result;
|
package/dist/types/execute.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BlockTypes, FrameType } from './globals.js';
|
|
1
|
+
import { BlockTypes, FrameType, ReferenceTypes } from './globals.js';
|
|
2
2
|
import { ExecutionWarning } from "./utils.js";
|
|
3
3
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
4
4
|
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
5
5
|
import { Net } from './objects/Net.js';
|
|
6
6
|
import { NumericValue, ParamDefinition } from './objects/ParamDefinition.js';
|
|
7
7
|
import { PinDefinition } from './objects/PinDefinition.js';
|
|
8
|
-
import { CFunction, CFunctionResult, CallableParameter, ComponentPin, DeclaredReference } from './objects/types.js';
|
|
8
|
+
import { AnyReference, CFunction, CFunctionResult, CallableParameter, ComponentPin, DeclaredReference } from './objects/types.js';
|
|
9
9
|
import { Logger } from './logger.js';
|
|
10
10
|
import { UnitDimension } from './helpers.js';
|
|
11
11
|
import { ParserRuleContext } from 'antlr4ng';
|
|
@@ -62,6 +62,7 @@ export declare class ExecutionContext {
|
|
|
62
62
|
copyComponent(component: ClassComponent): ClassComponent;
|
|
63
63
|
enterBlocks(blockType: BlockTypes): void;
|
|
64
64
|
exitBlocks(): void;
|
|
65
|
+
closeAllBlocks(): void;
|
|
65
66
|
enterBlock(blockIndex: number): void;
|
|
66
67
|
exitBlock(blockIndex: number): void;
|
|
67
68
|
atPointBlock(): void;
|
|
@@ -74,6 +75,7 @@ export declare class ExecutionContext {
|
|
|
74
75
|
hasFunction(functionName: string): boolean;
|
|
75
76
|
getFunction(functionName: string): CFunction;
|
|
76
77
|
resolveVariable(executionStack: ExecutionContext[], idName: string, trailers?: string[]): DeclaredReference;
|
|
78
|
+
resolveTrailers(type: ReferenceTypes, item: any, trailers?: string[]): AnyReference;
|
|
77
79
|
callFunction(functionName: string, functionParams: CallableParameter[], executionStack: ExecutionContext[], netNamespace: string): CFunctionResult;
|
|
78
80
|
mergeScope(childScope: ExecutionScope, namespace: string): void;
|
|
79
81
|
addWire(segments: [string, (number | UnitDimension)?][]): void;
|
package/dist/types/globals.d.ts
CHANGED
package/dist/types/layout.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Net } from './objects/Net.js';
|
|
|
8
8
|
import { Logger } from './logger.js';
|
|
9
9
|
import { Frame, FramePlotDirection } from './objects/Frame.js';
|
|
10
10
|
import { BoundBox } from './utils.js';
|
|
11
|
+
import { ComponentPinNetPair } from './objects/types.js';
|
|
11
12
|
import { NumericValue } from './objects/ParamDefinition.js';
|
|
12
13
|
export declare class LayoutEngine {
|
|
13
14
|
logger: Logger;
|
|
@@ -19,7 +20,8 @@ export declare class LayoutEngine {
|
|
|
19
20
|
protected print(...params: any[]): void;
|
|
20
21
|
protected printLevel(level: number, ...params: any[]): void;
|
|
21
22
|
protected padLevel(value: number): string;
|
|
22
|
-
runLayout(sequence: SequenceItem[], nets: [
|
|
23
|
+
runLayout(sequence: SequenceItem[], nets: ComponentPinNetPair[]): SheetFrame[];
|
|
24
|
+
private collectRenderNets;
|
|
23
25
|
private flattenFrameItems;
|
|
24
26
|
private findJunctions;
|
|
25
27
|
private placeFrames;
|
|
@@ -52,6 +54,14 @@ export declare class RenderObject {
|
|
|
52
54
|
isFloating: boolean;
|
|
53
55
|
floatingRelativeTo: [selfPin: number, nodeId: string, pin: number][];
|
|
54
56
|
}
|
|
57
|
+
export type RenderNet = {
|
|
58
|
+
netName: string;
|
|
59
|
+
net: Net;
|
|
60
|
+
color?: string;
|
|
61
|
+
lineWidth?: number;
|
|
62
|
+
highlight?: string;
|
|
63
|
+
highlightOpacity?: number;
|
|
64
|
+
};
|
|
55
65
|
export declare class RenderWire extends RenderObject {
|
|
56
66
|
id: number;
|
|
57
67
|
segments: WireSegment[];
|
|
@@ -60,7 +70,8 @@ export declare class RenderWire extends RenderObject {
|
|
|
60
70
|
y: number;
|
|
61
71
|
}[];
|
|
62
72
|
netName: string;
|
|
63
|
-
|
|
73
|
+
net: Net;
|
|
74
|
+
constructor(net: Net, x: NumericValue, y: NumericValue, segments: WireSegment[]);
|
|
64
75
|
refreshPoints(): void;
|
|
65
76
|
getAutoPoints(value: [x: NumericValue, y: NumericValue], direction: WireAutoDirection): [dx: number, dy: number][];
|
|
66
77
|
getWireEnd(): {
|
|
@@ -76,6 +87,7 @@ export type MergedWire = {
|
|
|
76
87
|
netName: string;
|
|
77
88
|
segments: [x: number, y: number][][];
|
|
78
89
|
intersectPoints: [x: number, y: number, count: number][];
|
|
90
|
+
net: RenderNet;
|
|
79
91
|
};
|
|
80
92
|
export declare class RenderComponent extends RenderObject {
|
|
81
93
|
component: ClassComponent;
|
|
@@ -122,7 +134,8 @@ export declare enum RenderFrameType {
|
|
|
122
134
|
export declare class RenderJunction {
|
|
123
135
|
x: NumericValue;
|
|
124
136
|
y: NumericValue;
|
|
125
|
-
|
|
137
|
+
net: RenderNet;
|
|
138
|
+
constructor(x: NumericValue, y: NumericValue, net: RenderNet);
|
|
126
139
|
}
|
|
127
140
|
export type SheetFrame = {
|
|
128
141
|
frame: RenderFrame;
|