circuitscript 0.0.29 → 0.0.32
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 +6 -1
- package/dist/cjs/antlr/CircuitScriptLexer.js +204 -200
- package/dist/cjs/antlr/CircuitScriptParser.js +1066 -1173
- package/dist/cjs/draw_symbols.js +330 -87
- package/dist/cjs/execute.js +41 -14
- package/dist/cjs/geometry.js +79 -18
- package/dist/cjs/globals.js +37 -6
- package/dist/cjs/helpers.js +75 -5
- package/dist/cjs/layout.js +107 -43
- package/dist/cjs/main.js +10 -4
- package/dist/cjs/objects/ClassComponent.js +2 -0
- package/dist/cjs/objects/ExecutionScope.js +1 -1
- package/dist/cjs/objects/Frame.js +2 -0
- package/dist/cjs/objects/Net.js +3 -2
- package/dist/cjs/objects/PinTypes.js +7 -1
- package/dist/cjs/objects/types.js +11 -1
- package/dist/cjs/regenerate-tests.js +64 -3
- package/dist/cjs/render.js +29 -21
- package/dist/cjs/sizing.js +4 -6
- package/dist/cjs/utils.js +29 -5
- package/dist/cjs/visitor.js +176 -10
- package/dist/esm/BaseVisitor.mjs +6 -1
- package/dist/esm/antlr/CircuitScriptLexer.mjs +204 -200
- package/dist/esm/antlr/CircuitScriptParser.mjs +1061 -1171
- package/dist/esm/antlr/CircuitScriptVisitor.mjs +3 -0
- package/dist/esm/draw_symbols.mjs +324 -85
- package/dist/esm/execute.mjs +42 -15
- package/dist/esm/geometry.mjs +79 -17
- package/dist/esm/globals.mjs +36 -5
- package/dist/esm/helpers.mjs +74 -5
- package/dist/esm/layout.mjs +110 -46
- package/dist/esm/main.mjs +11 -5
- package/dist/esm/objects/ClassComponent.mjs +6 -0
- package/dist/esm/objects/ExecutionScope.mjs +1 -1
- package/dist/esm/objects/Frame.mjs +2 -0
- package/dist/esm/objects/Net.mjs +3 -2
- package/dist/esm/objects/PinTypes.mjs +6 -0
- package/dist/esm/objects/types.mjs +14 -0
- package/dist/esm/regenerate-tests.mjs +64 -3
- package/dist/esm/render.mjs +30 -22
- package/dist/esm/sizing.mjs +3 -4
- package/dist/esm/utils.mjs +26 -4
- package/dist/esm/visitor.mjs +179 -13
- package/dist/types/antlr/CircuitScriptLexer.d.ts +42 -41
- package/dist/types/antlr/CircuitScriptParser.d.ts +144 -133
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +6 -0
- package/dist/types/draw_symbols.d.ts +15 -2
- package/dist/types/execute.d.ts +5 -4
- package/dist/types/geometry.d.ts +4 -3
- package/dist/types/globals.d.ts +32 -3
- package/dist/types/helpers.d.ts +12 -0
- package/dist/types/layout.d.ts +8 -2
- package/dist/types/objects/ClassComponent.d.ts +8 -0
- package/dist/types/objects/Frame.d.ts +3 -1
- package/dist/types/objects/PinTypes.d.ts +1 -0
- package/dist/types/objects/Wire.d.ts +4 -2
- package/dist/types/objects/types.d.ts +8 -0
- package/dist/types/render.d.ts +5 -1
- package/dist/types/sizing.d.ts +0 -4
- package/dist/types/utils.d.ts +3 -0
- package/dist/types/visitor.d.ts +8 -1
- package/fonts/Arial.ttf +0 -0
- package/libs/lib.cst +58 -41
- package/package.json +5 -1
package/dist/esm/sizing.mjs
CHANGED
|
@@ -3,7 +3,9 @@ import { HorizontalAlign, VerticalAlign } from './geometry.mjs';
|
|
|
3
3
|
import { defaultFont } from './globals.mjs';
|
|
4
4
|
import { JSModuleType, detectJSModuleType } from './helpers.mjs';
|
|
5
5
|
let MainCanvas = null;
|
|
6
|
-
const supportedFonts = {
|
|
6
|
+
const supportedFonts = {
|
|
7
|
+
'Arial': 'Arial.ttf',
|
|
8
|
+
};
|
|
7
9
|
let globalCreateSVGWindow;
|
|
8
10
|
export async function prepareSVGEnvironment(fontsPath) {
|
|
9
11
|
const moduleType = detectJSModuleType();
|
|
@@ -25,9 +27,6 @@ export function getCreateSVGWindow() {
|
|
|
25
27
|
}
|
|
26
28
|
export function applyFontsToSVG(canvas) {
|
|
27
29
|
}
|
|
28
|
-
export async function measureTextSize(text, fontFamily, fontSize) {
|
|
29
|
-
return measureTextSize2(text, fontFamily, fontSize);
|
|
30
|
-
}
|
|
31
30
|
const measureTextSizeCache = {};
|
|
32
31
|
const measureTextSizeCacheHits = {};
|
|
33
32
|
export function measureTextSize2(text, fontFamily, fontSize, fontWeight = 'regular', anchor = HorizontalAlign.Left, vanchor = VerticalAlign.Bottom) {
|
package/dist/esm/utils.mjs
CHANGED
|
@@ -23,11 +23,17 @@ export function printBounds(bounds) {
|
|
|
23
23
|
return 'null';
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
+
function hasRemainder(value, value2) {
|
|
27
|
+
const tmpValue = Math.abs(value) / value2;
|
|
28
|
+
const flooredValue = Math.floor(tmpValue);
|
|
29
|
+
const diff = tmpValue - flooredValue;
|
|
30
|
+
return diff;
|
|
31
|
+
}
|
|
26
32
|
export function resizeToNearestGrid(bounds, gridSize = 20) {
|
|
27
|
-
const addXMin = (bounds.xmin
|
|
28
|
-
const addYMin = (bounds.ymin
|
|
29
|
-
const addXMax = (bounds.xmax
|
|
30
|
-
const addYMax = (bounds.ymax
|
|
33
|
+
const addXMin = hasRemainder(bounds.xmin, gridSize) === 0 ? -1 : 0;
|
|
34
|
+
const addYMin = hasRemainder(bounds.ymin, gridSize) === 0 ? -1 : 0;
|
|
35
|
+
const addXMax = hasRemainder(bounds.xmax, gridSize) === 0 ? 1 : 0;
|
|
36
|
+
const addYMax = hasRemainder(bounds.ymax, gridSize) === 0 ? 1 : 0;
|
|
31
37
|
return {
|
|
32
38
|
xmin: Math.floor((bounds.xmin + addXMin) / gridSize) * gridSize,
|
|
33
39
|
ymin: Math.floor((bounds.ymin + addYMin) / gridSize) * gridSize,
|
|
@@ -44,3 +50,19 @@ export function getBoundsSize(bounds) {
|
|
|
44
50
|
height: bounds.ymax - bounds.ymin,
|
|
45
51
|
};
|
|
46
52
|
}
|
|
53
|
+
export function getPortType(component) {
|
|
54
|
+
const drawingCommands = component.displayProp;
|
|
55
|
+
let foundPinType = null;
|
|
56
|
+
const commands = drawingCommands.getCommands();
|
|
57
|
+
commands.some(item => {
|
|
58
|
+
if (item[0] === 'label' && item[2].has('portType')) {
|
|
59
|
+
foundPinType = item[2].get('portType');
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
return false;
|
|
63
|
+
});
|
|
64
|
+
return foundPinType;
|
|
65
|
+
}
|
|
66
|
+
export function roundValue(value) {
|
|
67
|
+
return +value.toFixed(7);
|
|
68
|
+
}
|
package/dist/esm/visitor.mjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { ClassComponent } from './objects/ClassComponent.mjs';
|
|
2
|
-
import { NumericValue, ParamDefinition, } from './objects/ParamDefinition.mjs';
|
|
2
|
+
import { NumericValue, ParamDefinition, PinBlankValue, } from './objects/ParamDefinition.mjs';
|
|
3
3
|
import { PinDefinition, PinIdType } from './objects/PinDefinition.mjs';
|
|
4
4
|
import { PinTypes } from './objects/PinTypes.mjs';
|
|
5
|
-
import { UndeclaredReference } from './objects/types.mjs';
|
|
6
|
-
import { BlockTypes, ComponentTypes, NoNetText, ReferenceTypes } from './globals.mjs';
|
|
5
|
+
import { DeclaredReference, UndeclaredReference } from './objects/types.mjs';
|
|
6
|
+
import { BlockTypes, ComponentTypes, NoNetText, ReferenceTypes, WireAutoDirection } from './globals.mjs';
|
|
7
7
|
import { PlaceHolderCommands, SymbolDrawingCommands } from './draw_symbols.mjs';
|
|
8
8
|
import { BaseVisitor } from './BaseVisitor.mjs';
|
|
9
|
+
import { getPortType } from './utils.mjs';
|
|
10
|
+
import { UnitDimension } from './helpers.mjs';
|
|
9
11
|
export class ParserVisitor extends BaseVisitor {
|
|
10
12
|
visitKeyword_assignment_expr = (ctx) => {
|
|
11
13
|
const id = ctx.ID().getText();
|
|
@@ -145,7 +147,8 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
145
147
|
arrange, display, type, width, copy,
|
|
146
148
|
angle, followWireOrientation
|
|
147
149
|
};
|
|
148
|
-
|
|
150
|
+
const createdComponent = this.getExecutor().createComponent(instanceName, pins, params, props);
|
|
151
|
+
this.setResult(ctx, createdComponent);
|
|
149
152
|
};
|
|
150
153
|
visitCreate_graphic_expr = (ctx) => {
|
|
151
154
|
const commands = ctx.graphic_expr().reduce((accum, item) => {
|
|
@@ -191,8 +194,82 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
191
194
|
this.visit(ctxParameters);
|
|
192
195
|
parameters = this.getResult(ctxParameters);
|
|
193
196
|
}
|
|
197
|
+
if (commandName === 'label') {
|
|
198
|
+
parameters.forEach(item => {
|
|
199
|
+
if (item[0] == 'keyword' && item[1] === 'portType') {
|
|
200
|
+
if (item[2] === 'in') {
|
|
201
|
+
item[2] = 'input';
|
|
202
|
+
}
|
|
203
|
+
else if (item[2] === 'out') {
|
|
204
|
+
item[2] = 'output';
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
194
209
|
this.setResult(ctx, [commandName, parameters]);
|
|
195
210
|
};
|
|
211
|
+
visitCreate_module_expr = (ctx) => {
|
|
212
|
+
const properties = this.getPropertyExprList(ctx.property_expr());
|
|
213
|
+
const { left: leftPorts, right: rightPorts } = this.parseCreateModulePorts(properties.get('ports'));
|
|
214
|
+
const allPorts = [...leftPorts, ...rightPorts].filter(item => {
|
|
215
|
+
return !(item instanceof PinBlankValue);
|
|
216
|
+
});
|
|
217
|
+
const nameToPinId = new Map();
|
|
218
|
+
const tmpPorts = allPorts.map((portName, index) => {
|
|
219
|
+
nameToPinId.set(portName, index + 1);
|
|
220
|
+
return new PinDefinition(index + 1, PinIdType.Int, portName, PinTypes.Any);
|
|
221
|
+
});
|
|
222
|
+
const arrangeLeftItems = leftPorts.map(item => {
|
|
223
|
+
if (item instanceof PinBlankValue) {
|
|
224
|
+
return item;
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
return nameToPinId.get(item);
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
const arrangeRightItems = rightPorts.map(item => {
|
|
231
|
+
if (item instanceof PinBlankValue) {
|
|
232
|
+
return item;
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
return nameToPinId.get(item);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
const arrange = new Map();
|
|
239
|
+
if (arrangeLeftItems.length > 0) {
|
|
240
|
+
arrange.set('left', arrangeLeftItems);
|
|
241
|
+
}
|
|
242
|
+
if (arrangeRightItems.length > 0) {
|
|
243
|
+
arrange.set('right', arrangeRightItems);
|
|
244
|
+
}
|
|
245
|
+
const width = properties.has('width') ?
|
|
246
|
+
properties.get('width') : null;
|
|
247
|
+
const blankParams = [];
|
|
248
|
+
const props = {
|
|
249
|
+
arrange, width
|
|
250
|
+
};
|
|
251
|
+
const moduleInstanceName = this.getExecutor().getUniqueInstanceName('');
|
|
252
|
+
const createdComponent = this.getExecutor().createComponent(moduleInstanceName, tmpPorts, blankParams, props);
|
|
253
|
+
createdComponent.typeProp = 'module';
|
|
254
|
+
const ctxPropertyBlock = ctx.property_block_expr();
|
|
255
|
+
if (ctxPropertyBlock) {
|
|
256
|
+
const [firstBlock] = ctxPropertyBlock;
|
|
257
|
+
this.visit(firstBlock);
|
|
258
|
+
const [keyName, expressionsBlock] = this.getResult(firstBlock);
|
|
259
|
+
if (keyName === 'contains') {
|
|
260
|
+
createdComponent.moduleContainsExpressions = expressionsBlock;
|
|
261
|
+
this.expandModuleContains(createdComponent, this.getExecutor().netNamespace);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
this.setResult(ctx, createdComponent);
|
|
265
|
+
};
|
|
266
|
+
visitProperty_block_expr = (ctx) => {
|
|
267
|
+
const tmpCtx = ctx.property_key_expr();
|
|
268
|
+
this.visit(tmpCtx);
|
|
269
|
+
const keyName = this.getResult(tmpCtx);
|
|
270
|
+
const expressionsBlock = ctx.expressions_block();
|
|
271
|
+
this.setResult(ctx, [keyName, expressionsBlock]);
|
|
272
|
+
};
|
|
196
273
|
visitProperty_expr = (ctx) => {
|
|
197
274
|
const ctxPropertyKeyExpr = ctx.property_key_expr();
|
|
198
275
|
const ctxPropertyValueExpr = ctx.property_value_expr();
|
|
@@ -270,6 +347,14 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
270
347
|
&& component.copyProp) {
|
|
271
348
|
component = this.getExecutor().copyComponent(component);
|
|
272
349
|
}
|
|
350
|
+
if (component instanceof DeclaredReference
|
|
351
|
+
&& component.found
|
|
352
|
+
&& component.trailers
|
|
353
|
+
&& component.trailers.length > 0
|
|
354
|
+
&& component.trailers[0] === 'contains') {
|
|
355
|
+
component = component.value;
|
|
356
|
+
this.placeModuleContains(component);
|
|
357
|
+
}
|
|
273
358
|
if (component && component instanceof ClassComponent) {
|
|
274
359
|
const modifiers = ctx.component_modifier_expr();
|
|
275
360
|
modifiers.forEach(modifier => {
|
|
@@ -328,10 +413,65 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
328
413
|
pinValue = this.getResult(ctxPinSelectExpr);
|
|
329
414
|
}
|
|
330
415
|
else {
|
|
331
|
-
|
|
416
|
+
if (component instanceof ClassComponent) {
|
|
417
|
+
pinValue = component.getDefaultPin();
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
const undeclaredRef = component;
|
|
421
|
+
throw 'Invalid component: ' + undeclaredRef.reference.name;
|
|
422
|
+
}
|
|
332
423
|
}
|
|
333
424
|
this.setResult(ctx, [component, pinValue]);
|
|
334
425
|
};
|
|
426
|
+
expandModuleContains(component, netNamespace) {
|
|
427
|
+
this.getExecutor().log('expanding module `contains`');
|
|
428
|
+
const executionStack = this.executionStack;
|
|
429
|
+
const resolveNet = this.createNetResolver(executionStack);
|
|
430
|
+
const executionContextName = this.getExecutor().namespace + "_"
|
|
431
|
+
+ component.instanceName
|
|
432
|
+
+ '_' + component.moduleCounter;
|
|
433
|
+
const tmpNamespace = this.getNetNamespace(netNamespace, "+/" + component.instanceName + "_" + component.moduleCounter);
|
|
434
|
+
const newExecutor = this.enterNewChildContext(executionStack, this.getExecutor(), executionContextName, { netNamespace: tmpNamespace }, [], []);
|
|
435
|
+
component.moduleCounter += 1;
|
|
436
|
+
newExecutor.resolveNet = resolveNet;
|
|
437
|
+
this.visit(component.moduleContainsExpressions);
|
|
438
|
+
const executionContext = executionStack.pop();
|
|
439
|
+
component.moduleExecutionContext = executionContext;
|
|
440
|
+
component.moduleExecutionContextName = executionContextName;
|
|
441
|
+
this.linkModuleSymbolWithContains(component, executionContext);
|
|
442
|
+
}
|
|
443
|
+
linkModuleSymbolWithContains(moduleComponent, executionContext) {
|
|
444
|
+
this.log('link module symbol');
|
|
445
|
+
const modulePinMapping = new Map();
|
|
446
|
+
moduleComponent.pins.forEach(pin => {
|
|
447
|
+
const pinName = pin.name;
|
|
448
|
+
modulePinMapping.set(pinName, pin.id);
|
|
449
|
+
});
|
|
450
|
+
const pinIdToPortMap = new Map();
|
|
451
|
+
moduleComponent.modulePinIdToPortMap = pinIdToPortMap;
|
|
452
|
+
for (const [key, component] of executionContext.scope.instances) {
|
|
453
|
+
if (component._copyID !== null && component.typeProp === 'port') {
|
|
454
|
+
const portName = component.parameters.get('net_name');
|
|
455
|
+
const modulePinId = modulePinMapping.get(portName);
|
|
456
|
+
pinIdToPortMap.set(modulePinId, component);
|
|
457
|
+
const portType = getPortType(component);
|
|
458
|
+
const tmpPin = moduleComponent.pins.get(modulePinId);
|
|
459
|
+
tmpPin.pinType = portType;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
placeModuleContains(moduleComponent) {
|
|
464
|
+
if (moduleComponent.typeProp === 'module'
|
|
465
|
+
&& moduleComponent.moduleContainsExpressions) {
|
|
466
|
+
this.log('place module `contains`');
|
|
467
|
+
this.getExecutor().mergeScope(moduleComponent.moduleExecutionContext.scope, moduleComponent.moduleExecutionContextName);
|
|
468
|
+
this.log('connect module ports');
|
|
469
|
+
for (const [pinId, portComponent] of moduleComponent.modulePinIdToPortMap) {
|
|
470
|
+
this.getExecutor().atComponent(moduleComponent, pinId);
|
|
471
|
+
this.getExecutor().toComponent(portComponent, 1);
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
}
|
|
335
475
|
visitUnaryOperatorExpr = (ctx) => {
|
|
336
476
|
this.visit(ctx.data_expr());
|
|
337
477
|
let value = this.getResult(ctx.data_expr());
|
|
@@ -360,6 +500,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
360
500
|
let value;
|
|
361
501
|
const ctxCreateComponentExpr = ctx.create_component_expr();
|
|
362
502
|
const ctxCreateGraphicExpr = ctx.create_graphic_expr();
|
|
503
|
+
const ctxCreateModuleExpr = ctx.create_module_expr();
|
|
363
504
|
if (ctxCreateComponentExpr) {
|
|
364
505
|
this.visit(ctxCreateComponentExpr);
|
|
365
506
|
value = this.getResult(ctxCreateComponentExpr);
|
|
@@ -368,6 +509,10 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
368
509
|
this.visit(ctxCreateGraphicExpr);
|
|
369
510
|
value = this.getResult(ctxCreateGraphicExpr);
|
|
370
511
|
}
|
|
512
|
+
else if (ctxCreateModuleExpr) {
|
|
513
|
+
this.visit(ctxCreateModuleExpr);
|
|
514
|
+
value = this.getResult(ctxCreateModuleExpr);
|
|
515
|
+
}
|
|
371
516
|
else {
|
|
372
517
|
throw "Invalid data expression";
|
|
373
518
|
}
|
|
@@ -536,13 +681,11 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
536
681
|
}
|
|
537
682
|
};
|
|
538
683
|
visitAt_block_pin_expression_complex = (ctx) => {
|
|
539
|
-
ctx.
|
|
540
|
-
this.visit(item);
|
|
541
|
-
});
|
|
684
|
+
this.visit(ctx.expressions_block());
|
|
542
685
|
};
|
|
543
686
|
visitWire_expr_direction_only = (ctx) => {
|
|
544
687
|
const value = ctx.ID().getText();
|
|
545
|
-
if (value ===
|
|
688
|
+
if (value === WireAutoDirection.Auto || value === WireAutoDirection.Auto_) {
|
|
546
689
|
this.setResult(ctx, [value]);
|
|
547
690
|
}
|
|
548
691
|
else {
|
|
@@ -563,7 +706,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
563
706
|
useValue = this.getResult(ctxDataExpr);
|
|
564
707
|
}
|
|
565
708
|
if (useValue !== null) {
|
|
566
|
-
this.setResult(ctx, [direction, useValue]);
|
|
709
|
+
this.setResult(ctx, [direction, new UnitDimension(useValue)]);
|
|
567
710
|
return;
|
|
568
711
|
}
|
|
569
712
|
}
|
|
@@ -597,9 +740,12 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
597
740
|
const propertyName = ctx.ID().getText();
|
|
598
741
|
this.getExecutor().setProperty('..' + propertyName, result);
|
|
599
742
|
};
|
|
743
|
+
visitExpressions_block = (ctx) => {
|
|
744
|
+
this.runExpressions(this.getExecutor(), ctx.expression());
|
|
745
|
+
};
|
|
600
746
|
visitFrame_expr = (ctx) => {
|
|
601
747
|
const frameId = this.getExecutor().enterFrame();
|
|
602
|
-
this.
|
|
748
|
+
this.visit(ctx.expressions_block());
|
|
603
749
|
this.getExecutor().exitFrame(frameId);
|
|
604
750
|
};
|
|
605
751
|
visitNet_namespace_expr = (ctx) => {
|
|
@@ -630,7 +776,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
630
776
|
this.visit(ctxDataExpr);
|
|
631
777
|
const result = this.getResult(ctxDataExpr);
|
|
632
778
|
if (result) {
|
|
633
|
-
this.
|
|
779
|
+
this.visit(ctx.expressions_block());
|
|
634
780
|
}
|
|
635
781
|
else {
|
|
636
782
|
const ctxInnerIfExprs = ctx.if_inner_expr();
|
|
@@ -657,7 +803,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
657
803
|
this.visit(ctxDataExpr);
|
|
658
804
|
const result = this.getResult(ctxDataExpr);
|
|
659
805
|
if (result) {
|
|
660
|
-
this.
|
|
806
|
+
this.visit(ctx.expressions_block());
|
|
661
807
|
}
|
|
662
808
|
this.setResult(ctx, result);
|
|
663
809
|
};
|
|
@@ -712,6 +858,26 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
712
858
|
}
|
|
713
859
|
return pins;
|
|
714
860
|
}
|
|
861
|
+
parseCreateModulePorts(portsDefinition) {
|
|
862
|
+
let leftItems = [];
|
|
863
|
+
let rightItems = [];
|
|
864
|
+
if (portsDefinition.has('left')) {
|
|
865
|
+
leftItems = portsDefinition.get('left');
|
|
866
|
+
if (!Array.isArray(leftItems)) {
|
|
867
|
+
leftItems = [leftItems];
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
if (portsDefinition.has('right')) {
|
|
871
|
+
rightItems = portsDefinition.get('right');
|
|
872
|
+
if (!Array.isArray(rightItems)) {
|
|
873
|
+
rightItems = [rightItems];
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
return {
|
|
877
|
+
left: leftItems,
|
|
878
|
+
right: rightItems
|
|
879
|
+
};
|
|
880
|
+
}
|
|
715
881
|
parseCreateComponentParams(params) {
|
|
716
882
|
const result = [];
|
|
717
883
|
if (params) {
|
|
@@ -12,47 +12,48 @@ export declare class CircuitScriptLexer extends antlr.Lexer {
|
|
|
12
12
|
static readonly Create = 10;
|
|
13
13
|
static readonly Component = 11;
|
|
14
14
|
static readonly Graphic = 12;
|
|
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
|
|
15
|
+
static readonly Module = 13;
|
|
16
|
+
static readonly Wire = 14;
|
|
17
|
+
static readonly Pin = 15;
|
|
18
|
+
static readonly Add = 16;
|
|
19
|
+
static readonly At = 17;
|
|
20
|
+
static readonly To = 18;
|
|
21
|
+
static readonly Point = 19;
|
|
22
|
+
static readonly Join = 20;
|
|
23
|
+
static readonly Parallel = 21;
|
|
24
|
+
static readonly Return = 22;
|
|
25
|
+
static readonly Define = 23;
|
|
26
|
+
static readonly Import = 24;
|
|
27
|
+
static readonly If = 25;
|
|
28
|
+
static readonly Else = 26;
|
|
29
|
+
static readonly Not = 27;
|
|
30
|
+
static readonly Frame = 28;
|
|
31
|
+
static readonly Equals = 29;
|
|
32
|
+
static readonly NotEquals = 30;
|
|
33
|
+
static readonly GreaterThan = 31;
|
|
34
|
+
static readonly GreatOrEqualThan = 32;
|
|
35
|
+
static readonly LessThan = 33;
|
|
36
|
+
static readonly LessOrEqualThan = 34;
|
|
37
|
+
static readonly LogicalAnd = 35;
|
|
38
|
+
static readonly LogicalOr = 36;
|
|
39
|
+
static readonly Addition = 37;
|
|
40
|
+
static readonly Minus = 38;
|
|
41
|
+
static readonly Divide = 39;
|
|
42
|
+
static readonly Multiply = 40;
|
|
43
|
+
static readonly OPEN_PAREN = 41;
|
|
44
|
+
static readonly CLOSE_PAREN = 42;
|
|
45
|
+
static readonly NOT_CONNECTED = 43;
|
|
46
|
+
static readonly BOOLEAN_VALUE = 44;
|
|
47
|
+
static readonly ID = 45;
|
|
48
|
+
static readonly INTEGER_VALUE = 46;
|
|
49
|
+
static readonly DECIMAL_VALUE = 47;
|
|
50
|
+
static readonly NUMERIC_VALUE = 48;
|
|
51
|
+
static readonly STRING_VALUE = 49;
|
|
52
|
+
static readonly PERCENTAGE_VALUE = 50;
|
|
53
|
+
static readonly ALPHA_NUMERIC = 51;
|
|
54
|
+
static readonly WS = 52;
|
|
55
|
+
static readonly NEWLINE = 53;
|
|
56
|
+
static readonly COMMENT = 54;
|
|
56
57
|
static readonly channelNames: string[];
|
|
57
58
|
static readonly literalNames: (string | null)[];
|
|
58
59
|
static readonly symbolicNames: (string | null)[];
|