circuitscript 0.1.19 → 0.1.22
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 +22 -0
- package/dist/cjs/ComponentAnnotater.js +88 -0
- package/dist/cjs/RefdesAnnotationVisitor.js +197 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +202 -197
- package/dist/cjs/antlr/CircuitScriptParser.js +964 -831
- package/dist/cjs/environment.js +15 -1
- package/dist/cjs/execute.js +45 -2
- package/dist/cjs/graph.js +23 -2
- package/dist/cjs/helpers.js +21 -4
- package/dist/cjs/layout.js +3 -0
- package/dist/cjs/lexer.js +21 -9
- package/dist/cjs/main.js +13 -0
- package/dist/cjs/objects/ClassComponent.js +4 -1
- package/dist/cjs/objects/ExecutionScope.js +1 -0
- package/dist/cjs/parser.js +1 -0
- package/dist/cjs/visitor.js +119 -71
- package/dist/esm/BaseVisitor.js +22 -0
- package/dist/esm/ComponentAnnotater.js +84 -0
- package/dist/esm/RefdesAnnotationVisitor.js +196 -0
- package/dist/esm/antlr/CircuitScriptLexer.js +202 -197
- package/dist/esm/antlr/CircuitScriptParser.js +960 -829
- package/dist/esm/antlr/CircuitScriptVisitor.js +2 -0
- package/dist/esm/environment.js +15 -1
- package/dist/esm/execute.js +45 -2
- package/dist/esm/graph.js +23 -2
- package/dist/esm/helpers.js +21 -4
- package/dist/esm/layout.js +4 -0
- package/dist/esm/lexer.js +21 -9
- package/dist/esm/main.js +13 -0
- package/dist/esm/objects/ClassComponent.js +4 -1
- package/dist/esm/objects/ExecutionScope.js +1 -0
- package/dist/esm/parser.js +1 -0
- package/dist/esm/visitor.js +117 -69
- package/dist/types/BaseVisitor.d.ts +3 -0
- package/dist/types/ComponentAnnotater.d.ts +16 -0
- package/dist/types/RefdesAnnotationVisitor.d.ts +35 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +15 -14
- package/dist/types/antlr/CircuitScriptParser.d.ts +80 -60
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +4 -0
- package/dist/types/environment.d.ts +1 -0
- package/dist/types/execute.d.ts +8 -1
- package/dist/types/helpers.d.ts +6 -3
- package/dist/types/layout.d.ts +2 -0
- package/dist/types/lexer.d.ts +1 -1
- package/dist/types/objects/ClassComponent.d.ts +9 -0
- package/dist/types/objects/ExecutionScope.d.ts +2 -1
- package/dist/types/objects/types.d.ts +1 -0
- package/dist/types/parser.d.ts +2 -1
- package/dist/types/visitor.d.ts +8 -1
- package/package.json +1 -1
package/dist/esm/visitor.js
CHANGED
|
@@ -10,7 +10,9 @@ import { BaseVisitor } from './BaseVisitor.js';
|
|
|
10
10
|
import { getPortType, RuntimeExecutionError } from './utils.js';
|
|
11
11
|
import { UnitDimension } from './helpers.js';
|
|
12
12
|
import { FrameParamKeys } from './objects/Frame.js';
|
|
13
|
+
import { ComponentAnnotater } from './ComponentAnnotater.js';
|
|
13
14
|
export class ParserVisitor extends BaseVisitor {
|
|
15
|
+
componentCreationIndex = 0;
|
|
14
16
|
visitKeyword_assignment_expr = (ctx) => {
|
|
15
17
|
const id = ctx.ID().getText();
|
|
16
18
|
const value = this.visitResult(ctx.data_expr());
|
|
@@ -35,28 +37,53 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
35
37
|
}
|
|
36
38
|
this.setResult(ctx, pinId);
|
|
37
39
|
};
|
|
40
|
+
trackNewComponentCreated = (callback) => {
|
|
41
|
+
const preCreatedIndex = this.componentCreationIndex;
|
|
42
|
+
callback();
|
|
43
|
+
const postCreatedIndex = this.componentCreationIndex;
|
|
44
|
+
let creationFlag = false;
|
|
45
|
+
if (postCreatedIndex > preCreatedIndex) {
|
|
46
|
+
creationFlag = true;
|
|
47
|
+
}
|
|
48
|
+
return creationFlag;
|
|
49
|
+
};
|
|
38
50
|
visitAdd_component_expr = (ctx) => {
|
|
39
|
-
|
|
40
|
-
this.
|
|
51
|
+
let refComponent;
|
|
52
|
+
const creationFlag = this.trackNewComponentCreated(() => {
|
|
53
|
+
const [component, pinValue] = this.visitResult(ctx.data_expr_with_assignment());
|
|
54
|
+
this.getExecutor().addComponentExisting(component, pinValue);
|
|
55
|
+
refComponent = component;
|
|
56
|
+
});
|
|
57
|
+
this.linkComponentToCtx(ctx, refComponent, creationFlag);
|
|
41
58
|
};
|
|
42
59
|
visitAt_component_expr = (ctx) => {
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
60
|
+
let refComponent;
|
|
61
|
+
const creationFlag = this.trackNewComponentCreated(() => {
|
|
62
|
+
const [component, pin] = this.visitResult(ctx.component_select_expr());
|
|
63
|
+
this.getExecutor().atComponent(component, pin, {
|
|
64
|
+
addSequence: true
|
|
65
|
+
});
|
|
66
|
+
refComponent = component;
|
|
46
67
|
});
|
|
68
|
+
this.linkComponentToCtx(ctx, refComponent, creationFlag);
|
|
47
69
|
return this.getExecutor().getCurrentPoint();
|
|
48
70
|
};
|
|
49
71
|
visitTo_component_expr = (ctx) => {
|
|
50
72
|
ctx.component_select_expr().forEach(item => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
let refComponent;
|
|
74
|
+
const creationFlag = this.trackNewComponentCreated(() => {
|
|
75
|
+
const [component, pin] = this.visitResult(item);
|
|
76
|
+
try {
|
|
77
|
+
this.getExecutor().toComponent(component, pin, {
|
|
78
|
+
addSequence: true
|
|
79
|
+
});
|
|
80
|
+
refComponent = component;
|
|
81
|
+
}
|
|
82
|
+
catch (err) {
|
|
83
|
+
throw new RuntimeExecutionError(err.message, ctx);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
this.linkComponentToCtx(item, refComponent, creationFlag);
|
|
60
87
|
});
|
|
61
88
|
return this.getExecutor().getCurrentPoint();
|
|
62
89
|
};
|
|
@@ -327,6 +354,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
327
354
|
try {
|
|
328
355
|
const createdComponent = this.getExecutor().createComponent(instanceName, pins, params, props);
|
|
329
356
|
this.setResult(ctx, createdComponent);
|
|
357
|
+
createdComponent._creationIndex = this.componentCreationIndex++;
|
|
330
358
|
}
|
|
331
359
|
catch (error) {
|
|
332
360
|
this.throwWithContext(ctx, error.message);
|
|
@@ -867,7 +895,28 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
867
895
|
const resolveNet = this.createNetResolver(this.executionStack);
|
|
868
896
|
const resolveComponentPinNet = this.createComponentPinNetResolver(this.executionStack);
|
|
869
897
|
const __runFunc = (passedInParameters, options) => {
|
|
870
|
-
const
|
|
898
|
+
const executor = this.getExecutor();
|
|
899
|
+
const parentBreakContext = executor.getParentBreakContext();
|
|
900
|
+
executor.addBreakContext(ctx);
|
|
901
|
+
let useIndex = -1;
|
|
902
|
+
if (parentBreakContext === null) {
|
|
903
|
+
useIndex = options.functionCallIndex;
|
|
904
|
+
}
|
|
905
|
+
else {
|
|
906
|
+
const parentEntry = executor.indexedStack.get(parentBreakContext);
|
|
907
|
+
const { funcCallIndex } = parentEntry;
|
|
908
|
+
if (!funcCallIndex.has(ctx)) {
|
|
909
|
+
funcCallIndex.set(ctx, 0);
|
|
910
|
+
useIndex = 0;
|
|
911
|
+
}
|
|
912
|
+
else {
|
|
913
|
+
useIndex = funcCallIndex.get(ctx) + 1;
|
|
914
|
+
funcCallIndex.set(ctx, useIndex);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
executor.setBreakContextIndex(useIndex);
|
|
918
|
+
const functionCounterIndex = functionCounter['counter'];
|
|
919
|
+
const executionContextName = `${functionName}-${functionCounterIndex}`;
|
|
871
920
|
const newExecutor = this.enterNewChildContext(executionStack, this.getExecutor(), executionContextName, options, funcDefinedParameters, passedInParameters);
|
|
872
921
|
functionCounter['counter'] += 1;
|
|
873
922
|
newExecutor.resolveNet = resolveNet;
|
|
@@ -875,7 +924,23 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
875
924
|
const returnValue = this.runExpressions(newExecutor, ctx.function_expr());
|
|
876
925
|
const lastExecution = executionStack.pop();
|
|
877
926
|
const nextLastExecution = executionStack[executionStack.length - 1];
|
|
878
|
-
nextLastExecution.mergeScope(lastExecution.scope, executionContextName);
|
|
927
|
+
const mergedComponents = nextLastExecution.mergeScope(lastExecution.scope, executionContextName);
|
|
928
|
+
const scope = this.getScope();
|
|
929
|
+
const indexedStack = [];
|
|
930
|
+
if (scope.breakStack.length > 0) {
|
|
931
|
+
const executor = this.getExecutor();
|
|
932
|
+
scope.breakStack.forEach(stackCtx => {
|
|
933
|
+
const entry = executor.indexedStack.get(stackCtx);
|
|
934
|
+
const { index } = entry;
|
|
935
|
+
indexedStack.push([stackCtx, index]);
|
|
936
|
+
});
|
|
937
|
+
mergedComponents.forEach(component => {
|
|
938
|
+
component.ctxReferences.forEach(ref => {
|
|
939
|
+
ref.indexedStack = [...indexedStack, ...ref.indexedStack];
|
|
940
|
+
});
|
|
941
|
+
});
|
|
942
|
+
}
|
|
943
|
+
executor.popBreakContext();
|
|
879
944
|
return [lastExecution, returnValue];
|
|
880
945
|
};
|
|
881
946
|
this.getExecutor().createFunction(functionName, __runFunc, ctx, uniqueFunctionID);
|
|
@@ -919,10 +984,18 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
919
984
|
executor.log('end at block pin expressions');
|
|
920
985
|
executor.atComponent(currentComponent, currentPin);
|
|
921
986
|
};
|
|
987
|
+
visitAt_block_header = (ctx) => {
|
|
988
|
+
const ctxAtComponent = ctx.at_component_expr();
|
|
989
|
+
this.visit(ctxAtComponent);
|
|
990
|
+
const [currentComponent,] = this.getExecutor().getCurrentPoint();
|
|
991
|
+
this.componentCtxLinks.delete(ctxAtComponent);
|
|
992
|
+
this.componentCtxLinks.set(ctx, currentComponent);
|
|
993
|
+
};
|
|
922
994
|
visitAt_block = (ctx) => {
|
|
923
995
|
const executor = this.getExecutor();
|
|
924
996
|
executor.log('entering at block');
|
|
925
|
-
|
|
997
|
+
const ctxAtBlockComponent = ctx.at_block_header();
|
|
998
|
+
this.visit(ctxAtBlockComponent);
|
|
926
999
|
const [currentComponent, currentPin] = executor.getCurrentPoint();
|
|
927
1000
|
executor.scope.scopeLevel += 1;
|
|
928
1001
|
ctx.at_block_expressions().forEach(expression => {
|
|
@@ -1082,10 +1155,14 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1082
1155
|
const dataExpr = ctx.data_expr();
|
|
1083
1156
|
let keepLooping = true;
|
|
1084
1157
|
this.log('enter while loop');
|
|
1085
|
-
this.getExecutor()
|
|
1158
|
+
const executor = this.getExecutor();
|
|
1159
|
+
executor.addBreakContext(ctx);
|
|
1160
|
+
let counter = 0;
|
|
1086
1161
|
while (keepLooping) {
|
|
1087
1162
|
const result = this.visitResult(dataExpr);
|
|
1088
1163
|
if (result) {
|
|
1164
|
+
executor.setBreakContextIndex(counter);
|
|
1165
|
+
executor.resetBreakContextFunctionCalls();
|
|
1089
1166
|
this.visit(ctx.expressions_block());
|
|
1090
1167
|
keepLooping = true;
|
|
1091
1168
|
const currentResult = this.getResult(ctx) ?? {};
|
|
@@ -1100,6 +1177,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1100
1177
|
continueSignal: false
|
|
1101
1178
|
});
|
|
1102
1179
|
}
|
|
1180
|
+
counter++;
|
|
1103
1181
|
}
|
|
1104
1182
|
else {
|
|
1105
1183
|
keepLooping = false;
|
|
@@ -1113,7 +1191,8 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1113
1191
|
const forVariableNames = ctx.ID().map(item => item.getText());
|
|
1114
1192
|
let listItems = this.visitResult(ctx.data_expr());
|
|
1115
1193
|
listItems = unwrapValue(listItems);
|
|
1116
|
-
this.getExecutor()
|
|
1194
|
+
const executor = this.getExecutor();
|
|
1195
|
+
executor.addBreakContext(ctx);
|
|
1117
1196
|
let keepLooping = true;
|
|
1118
1197
|
let counter = 0;
|
|
1119
1198
|
while (keepLooping) {
|
|
@@ -1125,6 +1204,8 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1125
1204
|
useValueArray.forEach((value, index) => {
|
|
1126
1205
|
this.getScope().setVariable(forVariableNames[index], value);
|
|
1127
1206
|
});
|
|
1207
|
+
executor.setBreakContextIndex(counter);
|
|
1208
|
+
executor.resetBreakContextFunctionCalls();
|
|
1128
1209
|
this.visit(ctx.expressions_block());
|
|
1129
1210
|
keepLooping = true;
|
|
1130
1211
|
const currentResult = this.getResult(ctx) ?? {};
|
|
@@ -1146,7 +1227,19 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1146
1227
|
keepLooping = false;
|
|
1147
1228
|
}
|
|
1148
1229
|
}
|
|
1149
|
-
|
|
1230
|
+
executor.popBreakContext();
|
|
1231
|
+
};
|
|
1232
|
+
visitAnnotation_comment_expr = (ctx) => {
|
|
1233
|
+
const refdesID = ctx.ID().getText();
|
|
1234
|
+
const currentComponent = this.getScope().currentComponent;
|
|
1235
|
+
if (currentComponent !== null) {
|
|
1236
|
+
if (refdesID.indexOf('_') === -1) {
|
|
1237
|
+
currentComponent.setParam('refdes', refdesID);
|
|
1238
|
+
}
|
|
1239
|
+
else {
|
|
1240
|
+
currentComponent.placeHolderRefDes = refdesID;
|
|
1241
|
+
}
|
|
1242
|
+
}
|
|
1150
1243
|
};
|
|
1151
1244
|
resolveDataExpr(data_expr) {
|
|
1152
1245
|
const value = this.visitResult(data_expr);
|
|
@@ -1349,8 +1442,8 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1349
1442
|
continue;
|
|
1350
1443
|
}
|
|
1351
1444
|
if (instance.assignedRefDes === null) {
|
|
1352
|
-
if (instance.
|
|
1353
|
-
const refdes = instance.
|
|
1445
|
+
if (instance.hasParam('refdes')) {
|
|
1446
|
+
const refdes = instance.getParam('refdes');
|
|
1354
1447
|
if (refdes) {
|
|
1355
1448
|
instance.assignedRefDes = refdes;
|
|
1356
1449
|
annotater.trackRefDes(refdes);
|
|
@@ -1362,10 +1455,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1362
1455
|
}
|
|
1363
1456
|
}
|
|
1364
1457
|
toAnnotate.forEach(instance => {
|
|
1365
|
-
const
|
|
1366
|
-
instance.typeProp === null
|
|
1367
|
-
&& this.log('Instance has no type:', instance.instanceName, ' assuming connector');
|
|
1368
|
-
const newRefDes = annotater.getAnnotation(useTypeProp);
|
|
1458
|
+
const newRefDes = annotater.getAnnotation(instance);
|
|
1369
1459
|
if (newRefDes !== null) {
|
|
1370
1460
|
instance.assignedRefDes = newRefDes;
|
|
1371
1461
|
this.log(newRefDes, '-', instance.instanceName);
|
|
@@ -1449,7 +1539,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1449
1539
|
return this.warnings;
|
|
1450
1540
|
}
|
|
1451
1541
|
}
|
|
1452
|
-
const ComponentRefDesPrefixes = {
|
|
1542
|
+
export const ComponentRefDesPrefixes = {
|
|
1453
1543
|
res: 'R',
|
|
1454
1544
|
cap: 'C',
|
|
1455
1545
|
ind: 'L',
|
|
@@ -1460,48 +1550,6 @@ const ComponentRefDesPrefixes = {
|
|
|
1460
1550
|
ic: 'U',
|
|
1461
1551
|
'?': '?',
|
|
1462
1552
|
};
|
|
1463
|
-
class ComponentAnnotater {
|
|
1464
|
-
counter = {};
|
|
1465
|
-
existingRefDes = [];
|
|
1466
|
-
constructor() {
|
|
1467
|
-
for (const key in ComponentRefDesPrefixes) {
|
|
1468
|
-
this.counter[key] = 1;
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
getAnnotation(type) {
|
|
1472
|
-
if (this.counter[type] === undefined && type.length <= 2) {
|
|
1473
|
-
for (const [, value] of Object.entries(ComponentRefDesPrefixes)) {
|
|
1474
|
-
if (value === type) {
|
|
1475
|
-
throw "Refdes prefix is already in use!";
|
|
1476
|
-
}
|
|
1477
|
-
}
|
|
1478
|
-
if (ComponentRefDesPrefixes[type] === undefined) {
|
|
1479
|
-
ComponentRefDesPrefixes[type] = type;
|
|
1480
|
-
this.counter[type] = 1;
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
if (ComponentRefDesPrefixes[type] === undefined) {
|
|
1484
|
-
return null;
|
|
1485
|
-
}
|
|
1486
|
-
let attempts = 100;
|
|
1487
|
-
let proposedName = "";
|
|
1488
|
-
while (attempts >= 0) {
|
|
1489
|
-
proposedName = ComponentRefDesPrefixes[type] + this.counter[type];
|
|
1490
|
-
this.counter[type]++;
|
|
1491
|
-
if (this.existingRefDes.indexOf(proposedName) === -1) {
|
|
1492
|
-
break;
|
|
1493
|
-
}
|
|
1494
|
-
attempts--;
|
|
1495
|
-
}
|
|
1496
|
-
if (attempts === 0) {
|
|
1497
|
-
throw "Annotation failed!";
|
|
1498
|
-
}
|
|
1499
|
-
return proposedName;
|
|
1500
|
-
}
|
|
1501
|
-
trackRefDes(name) {
|
|
1502
|
-
this.existingRefDes.push(name);
|
|
1503
|
-
}
|
|
1504
|
-
}
|
|
1505
1553
|
export class VisitorExecutionException {
|
|
1506
1554
|
errorMessage;
|
|
1507
1555
|
context;
|
|
@@ -21,6 +21,7 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
|
|
|
21
21
|
printToConsole: boolean;
|
|
22
22
|
acceptedDirections: Direction[];
|
|
23
23
|
protected resultData: Map<ParserRuleContext, any>;
|
|
24
|
+
protected componentCtxLinks: Map<ParserRuleContext, ClassComponent>;
|
|
24
25
|
pinTypesList: string[];
|
|
25
26
|
onErrorHandler: OnErrorHandler | null;
|
|
26
27
|
environment: NodeScriptEnvironment;
|
|
@@ -64,6 +65,8 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
|
|
|
64
65
|
visitArrayIndexExpr: (ctx: ArrayIndexExprContext) => void;
|
|
65
66
|
protected setResult(ctx: ParserRuleContext, value: any): void;
|
|
66
67
|
protected getResult(ctx: ParserRuleContext): any;
|
|
68
|
+
protected linkComponentToCtx(ctx: ParserRuleContext, instance: ClassComponent, creationFlag?: boolean): void;
|
|
69
|
+
getComponentCtxLinks(): Map<ParserRuleContext, ClassComponent>;
|
|
67
70
|
visitResult(ctx: ParserRuleContext): any;
|
|
68
71
|
protected handleImportFile(name: string, throwErrors?: boolean, ctx?: ParserRuleContext | null): Promise<ImportFile>;
|
|
69
72
|
visitRoundedBracketsExpr: (ctx: RoundedBracketsExprContext) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ParserRuleContext } from 'antlr4ng';
|
|
2
|
+
import { ClassComponent } from './objects/ClassComponent.js';
|
|
3
|
+
export declare class ComponentAnnotater {
|
|
4
|
+
counter: {
|
|
5
|
+
[key: string]: number;
|
|
6
|
+
};
|
|
7
|
+
indexedContextPrefix: Map<ParserRuleContext, string>;
|
|
8
|
+
existingRefDes: string[];
|
|
9
|
+
constructor();
|
|
10
|
+
getAnnotation(instance: ClassComponent): string | null;
|
|
11
|
+
getNextRefdesCounter(prefix: string, startingIndex: number): {
|
|
12
|
+
index: number;
|
|
13
|
+
proposedName: string;
|
|
14
|
+
};
|
|
15
|
+
trackRefDes(name: string): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 './antlr/CircuitScriptParser.js';
|
|
3
|
+
import { BaseVisitor } from './BaseVisitor.js';
|
|
4
|
+
import { ClassComponent } from './objects/ClassComponent.js';
|
|
5
|
+
export declare class RefdesAnnotationVisitor extends BaseVisitor {
|
|
6
|
+
private sourceText;
|
|
7
|
+
private tokenStream;
|
|
8
|
+
private modifications;
|
|
9
|
+
resultText: string;
|
|
10
|
+
debug: boolean;
|
|
11
|
+
componentCtxLinks: Map<ParserRuleContext, ClassComponent>;
|
|
12
|
+
constructor(silent: boolean, sourceText: string, tokenStream: CommonTokenStream, componentCtxLinks: Map<ParserRuleContext, ClassComponent>);
|
|
13
|
+
private getOriginalText;
|
|
14
|
+
visitScript: (ctx: ScriptContext) => Promise<void>;
|
|
15
|
+
visitAdd_component_expr: (ctx: Add_component_exprContext) => void;
|
|
16
|
+
visitAt_component_expr: (ctx: At_component_exprContext) => void;
|
|
17
|
+
visitComponent_select_expr: (ctx: Component_select_exprContext) => void;
|
|
18
|
+
visitAt_block_header: (ctx: At_block_headerContext) => void;
|
|
19
|
+
visitAt_block: (ctx: At_blockContext) => void;
|
|
20
|
+
visitTo_component_expr: (ctx: To_component_exprContext) => void;
|
|
21
|
+
visitFunction_def_expr: (ctx: Function_def_exprContext) => void;
|
|
22
|
+
visitFunction_return_expr: (ctx: Function_return_exprContext) => void;
|
|
23
|
+
visitFrame_expr: (ctx: Frame_exprContext) => void;
|
|
24
|
+
visitFunction_call_expr: (ctx: Function_call_exprContext) => void;
|
|
25
|
+
visitParameters: (ctx: ParametersContext) => void;
|
|
26
|
+
addedRefdesAnnotations: string[];
|
|
27
|
+
private generateRefdesAnnotationComment;
|
|
28
|
+
private addRefdesAnnotationComment;
|
|
29
|
+
getOutput(): string;
|
|
30
|
+
private generateModifiedText;
|
|
31
|
+
private buildContextTokenRanges;
|
|
32
|
+
private findContextForToken;
|
|
33
|
+
private markTokensAsProcessed;
|
|
34
|
+
private log;
|
|
35
|
+
}
|
|
@@ -51,20 +51,21 @@ export declare class CircuitScriptLexer extends antlr.Lexer {
|
|
|
51
51
|
static readonly DivideAssign = 49;
|
|
52
52
|
static readonly MultiplyAssign = 50;
|
|
53
53
|
static readonly ModulusAssign = 51;
|
|
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
|
|
54
|
+
static readonly ANNOTATION_START = 52;
|
|
55
|
+
static readonly OPEN_PAREN = 53;
|
|
56
|
+
static readonly CLOSE_PAREN = 54;
|
|
57
|
+
static readonly NOT_CONNECTED = 55;
|
|
58
|
+
static readonly BOOLEAN_VALUE = 56;
|
|
59
|
+
static readonly ID = 57;
|
|
60
|
+
static readonly INTEGER_VALUE = 58;
|
|
61
|
+
static readonly DECIMAL_VALUE = 59;
|
|
62
|
+
static readonly NUMERIC_VALUE = 60;
|
|
63
|
+
static readonly STRING_VALUE = 61;
|
|
64
|
+
static readonly PERCENTAGE_VALUE = 62;
|
|
65
|
+
static readonly ALPHA_NUMERIC = 63;
|
|
66
|
+
static readonly WS = 64;
|
|
67
|
+
static readonly NEWLINE = 65;
|
|
68
|
+
static readonly COMMENT = 66;
|
|
68
69
|
static readonly channelNames: string[];
|
|
69
70
|
static readonly literalNames: (string | null)[];
|
|
70
71
|
static readonly symbolicNames: (string | null)[];
|
|
@@ -53,22 +53,23 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
53
53
|
static readonly DivideAssign = 49;
|
|
54
54
|
static readonly MultiplyAssign = 50;
|
|
55
55
|
static readonly ModulusAssign = 51;
|
|
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
|
|
71
|
-
static readonly
|
|
56
|
+
static readonly ANNOTATION_START = 52;
|
|
57
|
+
static readonly OPEN_PAREN = 53;
|
|
58
|
+
static readonly CLOSE_PAREN = 54;
|
|
59
|
+
static readonly NOT_CONNECTED = 55;
|
|
60
|
+
static readonly BOOLEAN_VALUE = 56;
|
|
61
|
+
static readonly ID = 57;
|
|
62
|
+
static readonly INTEGER_VALUE = 58;
|
|
63
|
+
static readonly DECIMAL_VALUE = 59;
|
|
64
|
+
static readonly NUMERIC_VALUE = 60;
|
|
65
|
+
static readonly STRING_VALUE = 61;
|
|
66
|
+
static readonly PERCENTAGE_VALUE = 62;
|
|
67
|
+
static readonly ALPHA_NUMERIC = 63;
|
|
68
|
+
static readonly WS = 64;
|
|
69
|
+
static readonly NEWLINE = 65;
|
|
70
|
+
static readonly COMMENT = 66;
|
|
71
|
+
static readonly INDENT = 67;
|
|
72
|
+
static readonly DEDENT = 68;
|
|
72
73
|
static readonly RULE_script = 0;
|
|
73
74
|
static readonly RULE_expression = 1;
|
|
74
75
|
static readonly RULE_flow_expressions = 2;
|
|
@@ -91,49 +92,51 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
91
92
|
static readonly RULE_at_to_multiple_line_expr_to_pin = 19;
|
|
92
93
|
static readonly RULE_at_block = 20;
|
|
93
94
|
static readonly RULE_at_block_expressions = 21;
|
|
94
|
-
static readonly
|
|
95
|
-
static readonly
|
|
96
|
-
static readonly
|
|
97
|
-
static readonly
|
|
98
|
-
static readonly
|
|
99
|
-
static readonly
|
|
100
|
-
static readonly
|
|
101
|
-
static readonly
|
|
102
|
-
static readonly
|
|
103
|
-
static readonly
|
|
104
|
-
static readonly
|
|
105
|
-
static readonly
|
|
106
|
-
static readonly
|
|
107
|
-
static readonly
|
|
108
|
-
static readonly
|
|
109
|
-
static readonly
|
|
110
|
-
static readonly
|
|
111
|
-
static readonly
|
|
112
|
-
static readonly
|
|
113
|
-
static readonly
|
|
114
|
-
static readonly
|
|
115
|
-
static readonly
|
|
116
|
-
static readonly
|
|
117
|
-
static readonly
|
|
118
|
-
static readonly
|
|
119
|
-
static readonly
|
|
120
|
-
static readonly
|
|
121
|
-
static readonly
|
|
122
|
-
static readonly
|
|
123
|
-
static readonly
|
|
124
|
-
static readonly
|
|
125
|
-
static readonly
|
|
126
|
-
static readonly
|
|
127
|
-
static readonly
|
|
128
|
-
static readonly
|
|
129
|
-
static readonly
|
|
130
|
-
static readonly
|
|
131
|
-
static readonly
|
|
132
|
-
static readonly
|
|
133
|
-
static readonly
|
|
134
|
-
static readonly
|
|
135
|
-
static readonly
|
|
136
|
-
static readonly
|
|
95
|
+
static readonly RULE_at_block_header = 22;
|
|
96
|
+
static readonly RULE_at_block_pin_expr = 23;
|
|
97
|
+
static readonly RULE_at_block_pin_expression_simple = 24;
|
|
98
|
+
static readonly RULE_at_block_pin_expression_complex = 25;
|
|
99
|
+
static readonly RULE_assignment_expr = 26;
|
|
100
|
+
static readonly RULE_operator_assignment_expr = 27;
|
|
101
|
+
static readonly RULE_keyword_assignment_expr = 28;
|
|
102
|
+
static readonly RULE_parameters = 29;
|
|
103
|
+
static readonly RULE_property_set_expr = 30;
|
|
104
|
+
static readonly RULE_double_dot_property_set_expr = 31;
|
|
105
|
+
static readonly RULE_data_expr = 32;
|
|
106
|
+
static readonly RULE_binary_operator = 33;
|
|
107
|
+
static readonly RULE_unary_operator = 34;
|
|
108
|
+
static readonly RULE_value_expr = 35;
|
|
109
|
+
static readonly RULE_function_def_expr = 36;
|
|
110
|
+
static readonly RULE_function_expr = 37;
|
|
111
|
+
static readonly RULE_function_args_expr = 38;
|
|
112
|
+
static readonly RULE_atom_expr = 39;
|
|
113
|
+
static readonly RULE_trailer_expr = 40;
|
|
114
|
+
static readonly RULE_trailer_expr2 = 41;
|
|
115
|
+
static readonly RULE_function_call_expr = 42;
|
|
116
|
+
static readonly RULE_net_namespace_expr = 43;
|
|
117
|
+
static readonly RULE_function_return_expr = 44;
|
|
118
|
+
static readonly RULE_property_block_expr = 45;
|
|
119
|
+
static readonly RULE_create_component_expr = 46;
|
|
120
|
+
static readonly RULE_graphic_expressions_block = 47;
|
|
121
|
+
static readonly RULE_create_graphic_expr = 48;
|
|
122
|
+
static readonly RULE_create_module_expr = 49;
|
|
123
|
+
static readonly RULE_nested_properties_inner = 50;
|
|
124
|
+
static readonly RULE_graphic_expr = 51;
|
|
125
|
+
static readonly RULE_property_expr = 52;
|
|
126
|
+
static readonly RULE_property_key_expr = 53;
|
|
127
|
+
static readonly RULE_property_value_expr = 54;
|
|
128
|
+
static readonly RULE_wire_atom_expr = 55;
|
|
129
|
+
static readonly RULE_wire_expr = 56;
|
|
130
|
+
static readonly RULE_array_expr = 57;
|
|
131
|
+
static readonly RULE_point_expr = 58;
|
|
132
|
+
static readonly RULE_import_expr = 59;
|
|
133
|
+
static readonly RULE_frame_expr = 60;
|
|
134
|
+
static readonly RULE_if_expr = 61;
|
|
135
|
+
static readonly RULE_if_inner_expr = 62;
|
|
136
|
+
static readonly RULE_else_expr = 63;
|
|
137
|
+
static readonly RULE_while_expr = 64;
|
|
138
|
+
static readonly RULE_for_expr = 65;
|
|
139
|
+
static readonly RULE_annotation_comment_expr = 66;
|
|
137
140
|
static readonly literalNames: (string | null)[];
|
|
138
141
|
static readonly symbolicNames: (string | null)[];
|
|
139
142
|
static readonly ruleNames: string[];
|
|
@@ -166,6 +169,7 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
166
169
|
at_to_multiple_line_expr_to_pin(): At_to_multiple_line_expr_to_pinContext;
|
|
167
170
|
at_block(): At_blockContext;
|
|
168
171
|
at_block_expressions(): At_block_expressionsContext;
|
|
172
|
+
at_block_header(): At_block_headerContext;
|
|
169
173
|
at_block_pin_expr(): At_block_pin_exprContext;
|
|
170
174
|
at_block_pin_expression_simple(): At_block_pin_expression_simpleContext;
|
|
171
175
|
at_block_pin_expression_complex(): At_block_pin_expression_complexContext;
|
|
@@ -210,6 +214,7 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
210
214
|
else_expr(): Else_exprContext;
|
|
211
215
|
while_expr(): While_exprContext;
|
|
212
216
|
for_expr(): For_exprContext;
|
|
217
|
+
annotation_comment_expr(): Annotation_comment_exprContext;
|
|
213
218
|
sempred(localContext: antlr.ParserRuleContext | null, ruleIndex: number, predIndex: number): boolean;
|
|
214
219
|
private data_expr_sempred;
|
|
215
220
|
static readonly _serializedATN: number[];
|
|
@@ -245,6 +250,7 @@ export declare class ExpressionContext extends antlr.ParserRuleContext {
|
|
|
245
250
|
atom_expr(): Atom_exprContext | null;
|
|
246
251
|
frame_expr(): Frame_exprContext | null;
|
|
247
252
|
flow_expressions(): Flow_expressionsContext | null;
|
|
253
|
+
annotation_comment_expr(): Annotation_comment_exprContext | null;
|
|
248
254
|
get ruleIndex(): number;
|
|
249
255
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
250
256
|
}
|
|
@@ -411,7 +417,7 @@ export declare class At_to_multiple_line_expr_to_pinContext extends antlr.Parser
|
|
|
411
417
|
}
|
|
412
418
|
export declare class At_blockContext extends antlr.ParserRuleContext {
|
|
413
419
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
414
|
-
|
|
420
|
+
at_block_header(): At_block_headerContext;
|
|
415
421
|
NEWLINE(): antlr.TerminalNode[];
|
|
416
422
|
NEWLINE(i: number): antlr.TerminalNode | null;
|
|
417
423
|
INDENT(): antlr.TerminalNode;
|
|
@@ -428,6 +434,13 @@ export declare class At_block_expressionsContext extends antlr.ParserRuleContext
|
|
|
428
434
|
get ruleIndex(): number;
|
|
429
435
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
430
436
|
}
|
|
437
|
+
export declare class At_block_headerContext extends antlr.ParserRuleContext {
|
|
438
|
+
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
439
|
+
at_component_expr(): At_component_exprContext;
|
|
440
|
+
annotation_comment_expr(): Annotation_comment_exprContext | null;
|
|
441
|
+
get ruleIndex(): number;
|
|
442
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
443
|
+
}
|
|
431
444
|
export declare class At_block_pin_exprContext extends antlr.ParserRuleContext {
|
|
432
445
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
433
446
|
pin_select_expr2(): Pin_select_expr2Context;
|
|
@@ -914,3 +927,10 @@ export declare class For_exprContext extends antlr.ParserRuleContext {
|
|
|
914
927
|
get ruleIndex(): number;
|
|
915
928
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
916
929
|
}
|
|
930
|
+
export declare class Annotation_comment_exprContext extends antlr.ParserRuleContext {
|
|
931
|
+
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
932
|
+
ANNOTATION_START(): antlr.TerminalNode;
|
|
933
|
+
ID(): antlr.TerminalNode;
|
|
934
|
+
get ruleIndex(): number;
|
|
935
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
936
|
+
}
|
|
@@ -21,6 +21,7 @@ import { At_to_multiple_line_exprContext } from "./CircuitScriptParser.js";
|
|
|
21
21
|
import { At_to_multiple_line_expr_to_pinContext } from "./CircuitScriptParser.js";
|
|
22
22
|
import { At_blockContext } from "./CircuitScriptParser.js";
|
|
23
23
|
import { At_block_expressionsContext } from "./CircuitScriptParser.js";
|
|
24
|
+
import { At_block_headerContext } from "./CircuitScriptParser.js";
|
|
24
25
|
import { At_block_pin_exprContext } from "./CircuitScriptParser.js";
|
|
25
26
|
import { At_block_pin_expression_simpleContext } from "./CircuitScriptParser.js";
|
|
26
27
|
import { At_block_pin_expression_complexContext } from "./CircuitScriptParser.js";
|
|
@@ -77,6 +78,7 @@ import { If_inner_exprContext } from "./CircuitScriptParser.js";
|
|
|
77
78
|
import { Else_exprContext } from "./CircuitScriptParser.js";
|
|
78
79
|
import { While_exprContext } from "./CircuitScriptParser.js";
|
|
79
80
|
import { For_exprContext } from "./CircuitScriptParser.js";
|
|
81
|
+
import { Annotation_comment_exprContext } from "./CircuitScriptParser.js";
|
|
80
82
|
export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisitor<Result> {
|
|
81
83
|
visitScript?: (ctx: ScriptContext) => Result;
|
|
82
84
|
visitExpression?: (ctx: ExpressionContext) => Result;
|
|
@@ -100,6 +102,7 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
|
|
|
100
102
|
visitAt_to_multiple_line_expr_to_pin?: (ctx: At_to_multiple_line_expr_to_pinContext) => Result;
|
|
101
103
|
visitAt_block?: (ctx: At_blockContext) => Result;
|
|
102
104
|
visitAt_block_expressions?: (ctx: At_block_expressionsContext) => Result;
|
|
105
|
+
visitAt_block_header?: (ctx: At_block_headerContext) => Result;
|
|
103
106
|
visitAt_block_pin_expr?: (ctx: At_block_pin_exprContext) => Result;
|
|
104
107
|
visitAt_block_pin_expression_simple?: (ctx: At_block_pin_expression_simpleContext) => Result;
|
|
105
108
|
visitAt_block_pin_expression_complex?: (ctx: At_block_pin_expression_complexContext) => Result;
|
|
@@ -156,4 +159,5 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
|
|
|
156
159
|
visitElse_expr?: (ctx: Else_exprContext) => Result;
|
|
157
160
|
visitWhile_expr?: (ctx: While_exprContext) => Result;
|
|
158
161
|
visitFor_expr?: (ctx: For_exprContext) => Result;
|
|
162
|
+
visitAnnotation_comment_expr?: (ctx: Annotation_comment_exprContext) => Result;
|
|
159
163
|
}
|
|
@@ -9,6 +9,7 @@ export declare class NodeScriptEnvironment {
|
|
|
9
9
|
protected useModuleDirectoryPath: string | null;
|
|
10
10
|
protected useDefaultLibsPath: string | null;
|
|
11
11
|
protected globalCreateSVGWindow: (() => SVGWindow) | null;
|
|
12
|
+
private cachedVersion;
|
|
12
13
|
protected supportedFonts: {
|
|
13
14
|
Arial: string;
|
|
14
15
|
};
|