circuitscript 0.0.25 → 0.0.26

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.
Files changed (41) hide show
  1. package/LICENSE +1 -1
  2. package/dist/cjs/BaseVisitor.js +9 -11
  3. package/dist/cjs/SemanticTokenVisitor.js +3 -3
  4. package/dist/cjs/antlr/CircuitScriptLexer.js +189 -166
  5. package/dist/cjs/antlr/CircuitScriptParser.js +1139 -622
  6. package/dist/cjs/draw_symbols.js +6 -0
  7. package/dist/cjs/execute.js +24 -30
  8. package/dist/cjs/export.js +91 -5
  9. package/dist/cjs/globals.js +1 -2
  10. package/dist/cjs/helpers.js +5 -2
  11. package/dist/cjs/main.js +21 -9
  12. package/dist/cjs/objects/ClassComponent.js +1 -0
  13. package/dist/cjs/render.js +1 -1
  14. package/dist/cjs/visitor.js +83 -14
  15. package/dist/esm/BaseVisitor.mjs +9 -11
  16. package/dist/esm/SemanticTokenVisitor.mjs +3 -3
  17. package/dist/esm/antlr/CircuitScriptLexer.mjs +189 -166
  18. package/dist/esm/antlr/CircuitScriptParser.mjs +1132 -619
  19. package/dist/esm/antlr/CircuitScriptVisitor.mjs +5 -1
  20. package/dist/esm/draw_symbols.mjs +7 -1
  21. package/dist/esm/execute.mjs +23 -26
  22. package/dist/esm/export.mjs +89 -6
  23. package/dist/esm/globals.mjs +1 -2
  24. package/dist/esm/helpers.mjs +6 -3
  25. package/dist/esm/main.mjs +21 -9
  26. package/dist/esm/objects/ClassComponent.mjs +1 -0
  27. package/dist/esm/render.mjs +2 -2
  28. package/dist/esm/visitor.mjs +84 -15
  29. package/dist/types/BaseVisitor.d.ts +0 -3
  30. package/dist/types/SemanticTokenVisitor.d.ts +2 -2
  31. package/dist/types/antlr/CircuitScriptLexer.d.ts +29 -22
  32. package/dist/types/antlr/CircuitScriptParser.d.ts +97 -29
  33. package/dist/types/antlr/CircuitScriptVisitor.d.ts +10 -2
  34. package/dist/types/draw_symbols.d.ts +3 -3
  35. package/dist/types/execute.d.ts +2 -4
  36. package/dist/types/export.d.ts +27 -1
  37. package/dist/types/globals.d.ts +2 -3
  38. package/dist/types/objects/ClassComponent.d.ts +1 -0
  39. package/dist/types/visitor.d.ts +5 -2
  40. package/libs/lib.cst +8 -7
  41. package/package.json +1 -1
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SymbolDrawingCommands = exports.SymbolDrawing = exports.SymbolCustom = exports.PlaceHolderCommands = exports.SymbolPlaceholder = exports.SymbolText = exports.SymbolPointHidden = exports.SymbolFactory = exports.SymbolGraphic = void 0;
4
4
  const globals_js_1 = require("./globals.js");
5
5
  const geometry_js_1 = require("./geometry.js");
6
+ const PinTypes_js_1 = require("./objects/PinTypes.js");
6
7
  const defaultSymbolLineWidth = 2;
7
8
  class SymbolGraphic {
8
9
  constructor() {
@@ -353,6 +354,11 @@ class SymbolPlaceholder extends SymbolGraphic {
353
354
  displayPinId = false;
354
355
  }
355
356
  let pinNameParam = null;
357
+ let pinType = PinTypes_js_1.PinTypes.Any;
358
+ if (positionParams[1].type && positionParams[1].type === globals_js_1.ReferenceTypes.pinType) {
359
+ pinType = positionParams[1].value;
360
+ positionParams = [positionParams[0], ...positionParams.slice(2)];
361
+ }
356
362
  if (typeof positionParams[1] === 'string') {
357
363
  pinNameParam = positionParams[1];
358
364
  positionParams = [positionParams[0], ...positionParams.slice(2)];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPortSide = exports.isNetOnlyComponent = exports.isLabelComponent = exports.isNetComponent = exports.ExecutionContext = void 0;
3
+ exports.getPortSide = exports.ExecutionContext = void 0;
4
4
  const globals_js_1 = require("./globals.js");
5
5
  const ClassComponent_js_1 = require("./objects/ClassComponent.js");
6
6
  const ExecutionScope_js_1 = require("./objects/ExecutionScope.js");
@@ -140,12 +140,18 @@ class ExecutionContext {
140
140
  pins.forEach((pin) => {
141
141
  component.pins.set(pin.id, pin);
142
142
  });
143
+ component.arrangeProps = props.arrange ?? null;
144
+ component.displayProp = props.display ?? null;
145
+ component.widthProp = props.width ?? null;
146
+ component.typeProp = props.type ?? null;
147
+ component.copyProp = props.copy ?? false;
143
148
  const paramsMap = new Map();
144
149
  params.forEach((param) => {
145
150
  component.parameters.set(param.paramName, param.paramValue);
146
151
  paramsMap.set(param.paramName, param.paramValue);
147
152
  });
148
- if (paramsMap.has(globals_js_1.ParamKeys.__is_net)) {
153
+ if (component.typeProp === globals_js_1.ComponentTypes.net
154
+ || component.typeProp === globals_js_1.ComponentTypes.label) {
149
155
  const netName = paramsMap.get(globals_js_1.ParamKeys.net_name);
150
156
  const priority = paramsMap.get(globals_js_1.ParamKeys.priority);
151
157
  const result = this.resolveNet(netName, this.netNamespace);
@@ -161,12 +167,7 @@ class ExecutionContext {
161
167
  this.scope.setNet(component, 1, tmpNet);
162
168
  this.log('set net', netName, 'component', component);
163
169
  }
164
- const { arrange = null } = props;
165
- component.arrangeProps = arrange;
166
- component.displayProp = props.display ?? null;
167
- component.widthProp = props.width ?? null;
168
- component.typeProp = props.type ?? null;
169
- const portSides = getPortSide(component.pins, arrange);
170
+ const portSides = getPortSide(component.pins, component.arrangeProps);
170
171
  portSides.forEach(({ pinId, side, position }) => {
171
172
  if (component.pins.has(pinId)) {
172
173
  const tmpPin = component.pins.get(pinId);
@@ -183,6 +184,10 @@ class ExecutionContext {
183
184
  }
184
185
  printPoint(extra = '') {
185
186
  let netName = globals_js_1.NoNetText;
187
+ if (this.scope.currentComponent === null || this.scope.currentPin === null) {
188
+ this.log((extra !== '' ? (extra + ' ') : '') + 'point is null');
189
+ return;
190
+ }
186
191
  if (this.scope.hasNet(this.scope.currentComponent, this.scope.currentPin)) {
187
192
  netName = this.scope
188
193
  .getNet(this.scope.currentComponent, this.scope.currentPin)
@@ -279,22 +284,22 @@ class ExecutionContext {
279
284
  this.printPoint();
280
285
  return this.getCurrentPoint();
281
286
  }
282
- cloneComponent(component) {
283
- let clonedComponent = null;
287
+ copyComponent(component) {
288
+ let componentCopy = null;
284
289
  if (!this.scope.copyIDs.has(component.instanceName)) {
285
290
  this.scope.copyIDs.set(component.instanceName, 0);
286
291
  }
287
292
  const idNum = this.scope.copyIDs.get(component.instanceName);
288
- clonedComponent = component.clone();
289
- clonedComponent._copyID = idNum;
290
- clonedComponent._copyFrom = component;
293
+ componentCopy = component.clone();
294
+ componentCopy._copyID = idNum;
295
+ componentCopy._copyFrom = component;
291
296
  this.scope.copyIDs.set(component.instanceName, idNum + 1);
292
297
  const cloneInstanceName = component.instanceName + ':' + idNum;
293
- this.scope.instances.set(cloneInstanceName, clonedComponent);
294
- clonedComponent.instanceName = cloneInstanceName;
295
- this.linkComponentPinNet(component, 1, clonedComponent, 1);
298
+ this.scope.instances.set(cloneInstanceName, componentCopy);
299
+ componentCopy.instanceName = cloneInstanceName;
300
+ this.linkComponentPinNet(component, 1, componentCopy, 1);
296
301
  this.log('created clone of net component:', cloneInstanceName);
297
- return clonedComponent;
302
+ return componentCopy;
298
303
  }
299
304
  enterBlocks(blockType) {
300
305
  if (blockType === globals_js_1.BlockTypes.Point) {
@@ -561,7 +566,8 @@ class ExecutionContext {
561
566
  }
562
567
  else if (action === ExecutionScope_js_1.SequenceAction.At || action === ExecutionScope_js_1.SequenceAction.To) {
563
568
  const tmpComponent = sequenceAction[1];
564
- if (isNetComponent(tmpComponent) && tmpComponent.parameters.get(globals_js_1.ParamKeys.net_name) === 'gnd') {
569
+ if (tmpComponent.typeProp === globals_js_1.ComponentTypes.net
570
+ && tmpComponent.parameters.get(globals_js_1.ParamKeys.net_name) === 'gnd') {
565
571
  tmpComponent._copyID = gndCopyIdOffset + incrementGndLinkId;
566
572
  incrementGndLinkId += 1;
567
573
  }
@@ -703,18 +709,6 @@ function isWireSegmentsEndAuto(segments) {
703
709
  }
704
710
  return false;
705
711
  }
706
- function isNetComponent(component) {
707
- return component.parameters.has(globals_js_1.ParamKeys.__is_net);
708
- }
709
- exports.isNetComponent = isNetComponent;
710
- function isLabelComponent(component) {
711
- return component.parameters.has(globals_js_1.ParamKeys.__is_label);
712
- }
713
- exports.isLabelComponent = isLabelComponent;
714
- function isNetOnlyComponent(component) {
715
- return isNetComponent(component) && !isLabelComponent(component);
716
- }
717
- exports.isNetOnlyComponent = isNetOnlyComponent;
718
712
  function getPortSide(pins, arrangeProps) {
719
713
  const result = [];
720
714
  if (arrangeProps === null) {
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateKiCADNetList = void 0;
3
+ exports.SExpObject = exports._id = exports.IdObject = exports.printTree = exports.generateKiCADNetList = void 0;
4
4
  const globals_js_1 = require("./globals.js");
5
5
  const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
6
6
  function generateKiCADNetList(netlist) {
7
7
  const componentsList = [];
8
8
  const nets = {};
9
+ const missingFootprints = [];
9
10
  netlist.forEach(entry => {
10
11
  const { instance, pins } = entry;
11
12
  if (instance.assignedRefDes !== null) {
@@ -25,7 +26,10 @@ function generateKiCADNetList(netlist) {
25
26
  instance.parameters.get('footprint')]);
26
27
  }
27
28
  else {
28
- console.log(instance.assignedRefDes, instance.instanceName, 'does not have footprint');
29
+ missingFootprints.push({
30
+ refdes: instance.assignedRefDes,
31
+ instanceName: instance.instanceName
32
+ });
29
33
  }
30
34
  componentsList.push(instanceDetails);
31
35
  for (const key in pins) {
@@ -66,18 +70,22 @@ function generateKiCADNetList(netlist) {
66
70
  ]);
67
71
  counter++;
68
72
  }
73
+ const dateString = new Date().toISOString().slice(0, 10);
69
74
  const tree = [
70
75
  Id("export"),
71
76
  [Id("version"), "E"],
72
77
  [Id("design"),
73
- [Id("source"), "/somefile"],
74
- [Id("date"), "2023-11-19"],
78
+ [Id("source"), "/unknown-file"],
79
+ [Id("date"), dateString],
75
80
  [Id("tool"), "circuitscript-to-kicad"]
76
81
  ],
77
82
  [Id('components'), ...componentsList],
78
83
  [Id('nets'), ...netItems]
79
84
  ];
80
- return printTree(tree);
85
+ return {
86
+ tree,
87
+ missingFootprints
88
+ };
81
89
  }
82
90
  exports.generateKiCADNetList = generateKiCADNetList;
83
91
  function printTree(tree, level = 0) {
@@ -99,6 +107,7 @@ function printTree(tree, level = 0) {
99
107
  }
100
108
  return "(" + output.join(" ") + ")";
101
109
  }
110
+ exports.printTree = printTree;
102
111
  function Id(name) {
103
112
  return new IdObject(name);
104
113
  }
@@ -107,3 +116,80 @@ class IdObject {
107
116
  this.keyName = keyName;
108
117
  }
109
118
  }
119
+ exports.IdObject = IdObject;
120
+ function _id(key) {
121
+ return new IdObject(key);
122
+ }
123
+ exports._id = _id;
124
+ class SExpObject {
125
+ constructor(object) {
126
+ this.object = object;
127
+ }
128
+ getKey(object = null) {
129
+ object = object ?? this.object;
130
+ return object[0];
131
+ }
132
+ getValue(object = null) {
133
+ object = object ?? this.object;
134
+ return object.slice(1);
135
+ }
136
+ getJSON(object = null) {
137
+ object = object ?? this.object;
138
+ if (!Array.isArray(object)) {
139
+ return object;
140
+ }
141
+ const properties = {};
142
+ const keyName = object[0].keyName;
143
+ if (object.length === 2) {
144
+ properties[keyName] = this.getJSON(object[1]);
145
+ }
146
+ else {
147
+ const innerProps = {};
148
+ this.getValue(object).forEach(item => {
149
+ const tmpValue = this.getJSON(item);
150
+ if (typeof tmpValue === "object") {
151
+ for (const key in tmpValue) {
152
+ if (innerProps[key]) {
153
+ if (!Array.isArray(innerProps[key])) {
154
+ innerProps[key] = [innerProps[key]];
155
+ }
156
+ innerProps[key].push(tmpValue[key]);
157
+ }
158
+ else {
159
+ innerProps[key] = tmpValue[key];
160
+ }
161
+ }
162
+ }
163
+ else {
164
+ innerProps[item[0].keyName] = tmpValue;
165
+ }
166
+ });
167
+ properties[keyName] = innerProps;
168
+ }
169
+ return properties;
170
+ }
171
+ getWithId(id, object = null) {
172
+ object = object ?? this.object;
173
+ let result = null;
174
+ const key = object[0];
175
+ if (key.keyName === id) {
176
+ return object;
177
+ }
178
+ else {
179
+ this.getValue(object).some(item => {
180
+ if (Array.isArray(item)) {
181
+ result = this.getWithId(id, item);
182
+ if (result !== null) {
183
+ return true;
184
+ }
185
+ }
186
+ return false;
187
+ });
188
+ }
189
+ return result;
190
+ }
191
+ print() {
192
+ console.log(printTree(this.object));
193
+ }
194
+ }
195
+ exports.SExpObject = SExpObject;
@@ -13,8 +13,6 @@ var GlobalNames;
13
13
  exports.NoNetText = 'NO_NET';
14
14
  var ParamKeys;
15
15
  (function (ParamKeys) {
16
- ParamKeys["__is_net"] = "__is_net";
17
- ParamKeys["__is_label"] = "__is_label";
18
16
  ParamKeys["priority"] = "priority";
19
17
  ParamKeys["net_name"] = "net_name";
20
18
  })(ParamKeys || (exports.ParamKeys = ParamKeys = {}));
@@ -50,6 +48,7 @@ var ReferenceTypes;
50
48
  ReferenceTypes["value"] = "value";
51
49
  ReferenceTypes["variable"] = "variable";
52
50
  ReferenceTypes["instance"] = "instance";
51
+ ReferenceTypes["pinType"] = "pinType";
53
52
  })(ReferenceTypes || (exports.ReferenceTypes = ReferenceTypes = {}));
54
53
  var BlockTypes;
55
54
  (function (BlockTypes) {
@@ -188,8 +188,11 @@ function renderScript(scriptData, outputPath, options) {
188
188
  console.log('Error during annotation: ', err);
189
189
  }
190
190
  if (kicadNetlistPath) {
191
- const kicadNetList = (0, export_js_1.generateKiCADNetList)(visitor.getNetList());
192
- (0, fs_1.writeFileSync)(kicadNetlistPath, kicadNetList);
191
+ const { tree: kicadNetList, missingFootprints } = (0, export_js_1.generateKiCADNetList)(visitor.getNetList());
192
+ missingFootprints.forEach(entry => {
193
+ console.log(`${entry.refdes} (${entry.instanceName}) does not have footprint`);
194
+ });
195
+ (0, fs_1.writeFileSync)(kicadNetlistPath, (0, export_js_1.printTree)(kicadNetList));
193
196
  console.log('Generated KiCad netlist file');
194
197
  }
195
198
  const { sequence, nets } = visitor.getGraph();
package/dist/cjs/main.js CHANGED
@@ -17,9 +17,9 @@ async function main() {
17
17
  commander_1.program
18
18
  .description('generate graphical output from circuitscript files')
19
19
  .version(version)
20
+ .argument('[input path]', 'Input path')
21
+ .argument('[output path]', 'Output path')
20
22
  .option('-i, --input text <input text>', 'Input text directly')
21
- .option('-f, --input-file <path>', 'Input file')
22
- .option('-o, --output <path>', 'Output path')
23
23
  .option('-c, --current-directory <path>', 'Set current directory')
24
24
  .option('-k, --kicad-netlist <filename>', 'Create KiCad netlist')
25
25
  .option('-w, --watch', 'Watch for file changes')
@@ -34,8 +34,8 @@ async function main() {
34
34
  }
35
35
  commander_1.program.parse();
36
36
  const options = commander_1.program.opts();
37
+ const args = commander_1.program.args;
37
38
  const watchFileChanges = options.watch;
38
- const outputPath = options.output ?? null;
39
39
  const dumpNets = options.dumpNets;
40
40
  const dumpData = options.dumpData;
41
41
  const kicadNetlist = options.kicadNetlist;
@@ -44,18 +44,26 @@ async function main() {
44
44
  console.log('watching for file changes...');
45
45
  }
46
46
  await (0, sizing_js_1.prepareSVGEnvironment)(fontsPath);
47
- let inputFilePath = null;
48
- let scriptData;
49
- if (options.input) {
50
- scriptData = options.input;
47
+ let inputFilePath = "";
48
+ if (args.length > 2) {
49
+ console.log("Error: Extra arguments passed");
50
+ return;
51
51
  }
52
- else {
53
- inputFilePath = options.inputFile;
52
+ let scriptData;
53
+ if (args.length > 0 && args[0]) {
54
+ inputFilePath = args[0];
54
55
  scriptData = (0, fs_1.readFileSync)(inputFilePath, { encoding: 'utf-8' });
55
56
  if (currentDirectory === null) {
56
57
  currentDirectory = path_1.default.dirname(inputFilePath);
57
58
  }
58
59
  }
60
+ else if (options.input) {
61
+ scriptData = options.input;
62
+ }
63
+ else {
64
+ console.log("Error: No input provided");
65
+ return;
66
+ }
59
67
  const scriptOptions = {
60
68
  currentDirectory,
61
69
  defaultLibsPath,
@@ -64,6 +72,10 @@ async function main() {
64
72
  kicadNetlistPath: kicadNetlist,
65
73
  showStats: options.stats,
66
74
  };
75
+ let outputPath = null;
76
+ if (args.length > 0 && args[1]) {
77
+ outputPath = args[1];
78
+ }
67
79
  const output = (0, helpers_js_1.renderScript)(scriptData, outputPath, scriptOptions);
68
80
  if (outputPath === null && output) {
69
81
  console.log(output);
@@ -16,6 +16,7 @@ class ClassComponent {
16
16
  this.displayProp = null;
17
17
  this.widthProp = null;
18
18
  this.typeProp = null;
19
+ this.copyProp = false;
19
20
  this.styles = {};
20
21
  this.assignedRefDes = null;
21
22
  this.instanceName = instanceName;
@@ -40,7 +40,7 @@ function generateSVGChild(canvas, components, wires, junctions, mergedWires, fra
40
40
  const { symbol = null } = item;
41
41
  if (symbol !== null && symbol) {
42
42
  const extra = {};
43
- if (item.component.parameters.has('__is_net')) {
43
+ if (item.component.typeProp === globals_js_1.ComponentTypes.net) {
44
44
  extra.net_name = item.component.parameters.get(globals_js_1.ParamKeys.net_name);
45
45
  }
46
46
  else if (item.component.parameters.has('value')) {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VisitorExecutionException = exports.ParserVisitor = void 0;
4
- const execute_js_1 = require("./execute.js");
5
4
  const ClassComponent_js_1 = require("./objects/ClassComponent.js");
6
5
  const ParamDefinition_js_1 = require("./objects/ParamDefinition.js");
7
6
  const PinDefinition_js_1 = require("./objects/PinDefinition.js");
@@ -34,7 +33,6 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
34
33
  };
35
34
  this.visitAdd_component_expr = (ctx) => {
36
35
  const ctxDataWithAssignmentExpr = ctx.data_expr_with_assignment();
37
- this.setParam(ctxDataWithAssignmentExpr, { clone: false });
38
36
  this.visit(ctxDataWithAssignmentExpr);
39
37
  const [component, pinValue] = this.getResult(ctxDataWithAssignmentExpr);
40
38
  return this.getExecutor().addComponentExisting(component, pinValue);
@@ -140,6 +138,8 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
140
138
  properties.get('display') : null;
141
139
  const type = properties.has('type') ?
142
140
  properties.get('type') : null;
141
+ const copy = properties.has('copy') ?
142
+ properties.get('copy') : false;
143
143
  const width = properties.has('width') ?
144
144
  properties.get('width') : null;
145
145
  const props = {
@@ -147,11 +147,12 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
147
147
  display,
148
148
  type,
149
149
  width,
150
+ copy
150
151
  };
151
152
  this.setResult(ctx, this.getExecutor().createComponent(instanceName, pins, params, props));
152
153
  };
153
154
  this.visitCreate_graphic_expr = (ctx) => {
154
- const commands = ctx.sub_expr().reduce((accum, item) => {
155
+ const commands = ctx.graphic_expr().reduce((accum, item) => {
155
156
  this.visit(item);
156
157
  const [commandName, parameters] = this.getResult(item);
157
158
  const keywordParams = new Map();
@@ -171,7 +172,7 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
171
172
  drawing.source = ctx.getText();
172
173
  this.setResult(ctx, drawing);
173
174
  };
174
- this.visitSub_expr = (ctx) => {
175
+ this.visitGraphic_expr = (ctx) => {
175
176
  let commandName = null;
176
177
  const command = ctx._command;
177
178
  if (command) {
@@ -253,14 +254,9 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
253
254
  this.visit(ctxAssignmentExpr);
254
255
  component = this.getResult(ctxAssignmentExpr);
255
256
  }
256
- let allowClone = true;
257
- if (this.hasParam(ctx)) {
258
- const { clone } = this.getParam(ctx);
259
- allowClone = clone;
260
- }
261
- if (allowClone && component instanceof ClassComponent_js_1.ClassComponent
262
- && (0, execute_js_1.isNetOnlyComponent)(component)) {
263
- component = this.getExecutor().cloneComponent(component);
257
+ if (component instanceof ClassComponent_js_1.ClassComponent
258
+ && component.copyProp) {
259
+ component = this.getExecutor().copyComponent(component);
264
260
  }
265
261
  if (component && component instanceof ClassComponent_js_1.ClassComponent) {
266
262
  const modifiers = ctx.component_modifier_expr();
@@ -358,6 +354,41 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
358
354
  else if (binaryOperatorType.NotEquals()) {
359
355
  result = value1 != value2;
360
356
  }
357
+ else if (binaryOperatorType.GreaterThan()) {
358
+ result = value1 > value2;
359
+ }
360
+ else if (binaryOperatorType.GreatOrEqualThan()) {
361
+ result = value1 >= value2;
362
+ }
363
+ else if (binaryOperatorType.LessThan()) {
364
+ result = value1 < value2;
365
+ }
366
+ else if (binaryOperatorType.LessOrEqualThan()) {
367
+ result = value1 <= value2;
368
+ }
369
+ this.setResult(ctx, result);
370
+ };
371
+ this.visitLogicalOperatorExpr = (ctx) => {
372
+ const ctx0 = ctx.data_expr(0);
373
+ const ctx1 = ctx.data_expr(1);
374
+ this.visit(ctx0);
375
+ const value1 = this.getResult(ctx0);
376
+ let value2 = false;
377
+ let skipNext = false;
378
+ if (ctx.LogicalOr() && value1) {
379
+ skipNext = true;
380
+ }
381
+ if (!skipNext) {
382
+ this.visit(ctx1);
383
+ value2 = this.getResult(ctx1);
384
+ }
385
+ let result = null;
386
+ if (ctx.LogicalAnd()) {
387
+ result = value1 && value2;
388
+ }
389
+ else if (ctx.LogicalOr()) {
390
+ result = value1 || value2;
391
+ }
361
392
  this.setResult(ctx, result);
362
393
  };
363
394
  this.visitMultiplyExpr = (ctx) => {
@@ -560,6 +591,42 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
560
591
  }
561
592
  this.setResult(ctx, (hasPlus ? "+" : "") + netNamespace);
562
593
  };
594
+ this.visitIf_expr = (ctx) => {
595
+ const ctxDataExpr = ctx.data_expr();
596
+ this.visit(ctxDataExpr);
597
+ const result = this.getResult(ctxDataExpr);
598
+ if (result) {
599
+ this.runExpressions(this.getExecutor(), ctx.expression());
600
+ }
601
+ else {
602
+ const ctxInnerIfExprs = ctx.if_inner_expr();
603
+ let innerIfWasTrue = false;
604
+ for (let i = 0; i < ctxInnerIfExprs.length; i++) {
605
+ const tmpCtx = ctxInnerIfExprs[i];
606
+ this.visit(tmpCtx);
607
+ const innerResult = this.getResult(tmpCtx);
608
+ if (innerResult) {
609
+ innerIfWasTrue = true;
610
+ break;
611
+ }
612
+ }
613
+ if (!innerIfWasTrue) {
614
+ const elseCtx = ctx.else_expr();
615
+ if (elseCtx) {
616
+ this.visit(elseCtx);
617
+ }
618
+ }
619
+ }
620
+ };
621
+ this.visitIf_inner_expr = (ctx) => {
622
+ const ctxDataExpr = ctx.data_expr();
623
+ this.visit(ctxDataExpr);
624
+ const result = this.getResult(ctxDataExpr);
625
+ if (result) {
626
+ this.runExpressions(this.getExecutor(), ctx.expression());
627
+ }
628
+ this.setResult(ctx, result);
629
+ };
563
630
  this.pinTypes = [
564
631
  PinTypes_js_1.PinTypes.Any,
565
632
  PinTypes_js_1.PinTypes.IO,
@@ -588,8 +655,10 @@ class ParserVisitor extends BaseVisitor_js_1.BaseVisitor {
588
655
  }
589
656
  if (Array.isArray(pinDef)) {
590
657
  const firstValue = pinDef[0];
591
- if (this.pinTypes.indexOf(firstValue) !== -1) {
592
- pinType = firstValue;
658
+ if (firstValue.type
659
+ && firstValue.type === globals_js_1.ReferenceTypes.pinType
660
+ && this.pinTypes.indexOf(firstValue.value) !== -1) {
661
+ pinType = firstValue.value;
593
662
  pinName = pinDef[1];
594
663
  if (pinDef.length > 2) {
595
664
  altPinNames = pinDef.slice(2);
@@ -8,6 +8,7 @@ import { ClassComponent } from "./objects/ClassComponent";
8
8
  import { NumericValue, PercentageValue, PinBlankValue } from "./objects/ParamDefinition";
9
9
  import { PinTypes } from "./objects/PinTypes";
10
10
  import { UndeclaredReference } from "./objects/types";
11
+ import { ReferenceTypes } from './globals';
11
12
  export class BaseVisitor extends CircuitScriptVisitor {
12
13
  indentLevel = 0;
13
14
  startingContext;
@@ -138,7 +139,8 @@ export class BaseVisitor extends CircuitScriptVisitor {
138
139
  if (this.pinTypesList.indexOf(atomId) !== -1) {
139
140
  currentReference = {
140
141
  found: true,
141
- value: atomId
142
+ value: atomId,
143
+ type: ReferenceTypes.pinType,
142
144
  };
143
145
  }
144
146
  else {
@@ -275,7 +277,12 @@ export class BaseVisitor extends CircuitScriptVisitor {
275
277
  value = new UndeclaredReference(reference);
276
278
  }
277
279
  else {
278
- value = reference.value;
280
+ if (reference.type && reference.type === ReferenceTypes.pinType) {
281
+ value = reference;
282
+ }
283
+ else {
284
+ value = reference.value;
285
+ }
279
286
  }
280
287
  }
281
288
  this.setResult(ctx, value);
@@ -340,15 +347,6 @@ export class BaseVisitor extends CircuitScriptVisitor {
340
347
  getResult(ctx) {
341
348
  return this.resultData.get(ctx);
342
349
  }
343
- setParam(ctx, value) {
344
- this.paramData.set(ctx, value);
345
- }
346
- getParam(ctx) {
347
- return this.paramData.get(ctx);
348
- }
349
- hasParam(ctx) {
350
- return this.paramData.has(ctx);
351
- }
352
350
  handleImportFile(name, throwErrors = true) {
353
351
  let hasError = false;
354
352
  let hasParseError = false;
@@ -39,8 +39,8 @@ export class SemanticTokensVisitor extends BaseVisitor {
39
39
  };
40
40
  visitCreate_graphic_expr = (ctx) => {
41
41
  this.addSemanticToken(ctx.Create(), ['defaultLibrary'], 'function');
42
- ctx.sub_expr().forEach(sub_expr => {
43
- this.visit(sub_expr);
42
+ ctx.graphic_expr().forEach(graphic_expr => {
43
+ this.visit(graphic_expr);
44
44
  });
45
45
  };
46
46
  visitProperty_key_expr = (ctx) => {
@@ -61,7 +61,7 @@ export class SemanticTokensVisitor extends BaseVisitor {
61
61
  this.addSemanticToken(useValue, [], 'property');
62
62
  }
63
63
  };
64
- visitSub_expr = (ctx) => {
64
+ visitGraphic_expr = (ctx) => {
65
65
  let useValue = null;
66
66
  const ctxId = ctx.ID();
67
67
  const ctxPin = ctx.Pin();