circuitscript 0.1.10 → 0.1.12

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 (52) hide show
  1. package/dist/cjs/BaseVisitor.js +78 -51
  2. package/dist/cjs/SemanticTokenVisitor.js +6 -1
  3. package/dist/cjs/antlr/CircuitScriptParser.js +1062 -963
  4. package/dist/cjs/builtinMethods.js +5 -1
  5. package/dist/cjs/draw_symbols.js +2 -1
  6. package/dist/cjs/execute.js +43 -22
  7. package/dist/cjs/geometry.js +3 -9
  8. package/dist/cjs/globals.js +7 -1
  9. package/dist/cjs/layout.js +50 -16
  10. package/dist/cjs/objects/ExecutionScope.js +3 -0
  11. package/dist/cjs/objects/Net.js +1 -0
  12. package/dist/cjs/objects/ParamDefinition.js +3 -0
  13. package/dist/cjs/objects/types.js +19 -10
  14. package/dist/cjs/render.js +48 -6
  15. package/dist/cjs/utils.js +16 -1
  16. package/dist/cjs/validate/SymbolValidatorVisitor.js +5 -0
  17. package/dist/cjs/visitor.js +77 -57
  18. package/dist/esm/BaseVisitor.js +72 -45
  19. package/dist/esm/SemanticTokenVisitor.js +6 -1
  20. package/dist/esm/antlr/CircuitScriptParser.js +1055 -958
  21. package/dist/esm/antlr/CircuitScriptVisitor.js +4 -2
  22. package/dist/esm/builtinMethods.js +6 -2
  23. package/dist/esm/draw_symbols.js +2 -1
  24. package/dist/esm/execute.js +43 -22
  25. package/dist/esm/geometry.js +3 -9
  26. package/dist/esm/globals.js +6 -0
  27. package/dist/esm/layout.js +53 -17
  28. package/dist/esm/objects/ExecutionScope.js +3 -0
  29. package/dist/esm/objects/Net.js +1 -0
  30. package/dist/esm/objects/ParamDefinition.js +4 -1
  31. package/dist/esm/objects/types.js +21 -15
  32. package/dist/esm/render.js +49 -7
  33. package/dist/esm/utils.js +13 -0
  34. package/dist/esm/validate/SymbolValidatorVisitor.js +5 -0
  35. package/dist/esm/visitor.js +66 -46
  36. package/dist/types/BaseVisitor.d.ts +2 -2
  37. package/dist/types/SemanticTokenVisitor.d.ts +2 -1
  38. package/dist/types/antlr/CircuitScriptParser.d.ts +100 -85
  39. package/dist/types/antlr/CircuitScriptVisitor.d.ts +8 -4
  40. package/dist/types/execute.d.ts +1 -0
  41. package/dist/types/geometry.d.ts +0 -1
  42. package/dist/types/globals.d.ts +5 -0
  43. package/dist/types/layout.d.ts +16 -3
  44. package/dist/types/objects/ExecutionScope.d.ts +15 -3
  45. package/dist/types/objects/Net.d.ts +1 -0
  46. package/dist/types/objects/types.d.ts +25 -18
  47. package/dist/types/utils.d.ts +3 -1
  48. package/dist/types/validate/SymbolValidatorVisitor.d.ts +2 -1
  49. package/dist/types/visitor.d.ts +3 -2
  50. package/package.json +3 -2
  51. /package/dist/libs/{lib.cst → std.cst} +0 -0
  52. /package/libs/{lib.cst → std.cst} +0 -0
@@ -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 { prepareValue } 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';
@@ -17,13 +18,16 @@ export class ParserVisitor extends BaseVisitor {
17
18
  };
18
19
  visitPin_select_expr = (ctx) => {
19
20
  let value = null;
20
- const ctxIntegerValue = ctx.INTEGER_VALUE();
21
- const ctxStringValue = ctx.STRING_VALUE();
22
- if (ctxIntegerValue) {
23
- value = Number(ctxIntegerValue.getText());
21
+ const ctxData = ctx.data_expr();
22
+ const result = this.visitResult(ctxData);
23
+ if (result instanceof NumericValue) {
24
+ value = result.toNumber();
24
25
  }
25
- else if (ctxStringValue) {
26
- value = this.prepareStringValue(ctxStringValue.getText());
26
+ else if (typeof result === 'string') {
27
+ value = result;
28
+ }
29
+ else {
30
+ throw new RuntimeExecutionError("Invalid value for pin", ctx);
27
31
  }
28
32
  this.setResult(ctx, value);
29
33
  };
@@ -79,39 +83,55 @@ export class ParserVisitor extends BaseVisitor {
79
83
  }
80
84
  this.setResult(ctx, componentPin);
81
85
  };
82
- visitPath_blocks = (ctx) => {
83
- const blocks = ctx.path_block_inner();
84
- let blockIndex = 0;
86
+ visitPath_block = (ctx) => {
85
87
  let blockType = BlockTypes.Branch;
86
- let prevBlockType = null;
87
- blocks.forEach((block, index) => {
88
- if (block.Branch()) {
89
- blockType = BlockTypes.Branch;
90
- }
91
- else if (block.Join()) {
92
- blockType = BlockTypes.Join;
93
- }
94
- else if (block.Parallel()) {
95
- blockType = BlockTypes.Parallel;
96
- }
97
- else if (block.Point()) {
98
- blockType = BlockTypes.Point;
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();
99
107
  }
100
- if (prevBlockType !== blockType) {
101
- if (index > 0) {
102
- this.getExecutor().exitBlocks();
103
- }
104
- this.getExecutor().enterBlocks(blockType);
105
- blockIndex = 0;
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();
106
125
  }
107
- this.getExecutor().enterBlock(blockIndex);
108
- this.visit(block);
109
- this.getExecutor().exitBlock(blockIndex);
110
- blockIndex += 1;
111
- prevBlockType = blockType;
112
- });
113
- this.getExecutor().exitBlocks();
114
- return this.getExecutor().getCurrentPoint();
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
+ }
115
135
  };
116
136
  visitCreate_component_expr = (ctx) => {
117
137
  const scope = this.getScope();
@@ -290,7 +310,7 @@ export class ParserVisitor extends BaseVisitor {
290
310
  if (ctxId !== null) {
291
311
  const varName = ctxId.getText();
292
312
  paramIds.push(varName);
293
- this.getScope().variables.set(varName, {});
313
+ this.getScope().setVariable(varName, {});
294
314
  }
295
315
  const executor = this.getExecutor();
296
316
  const stack = [...this.executionStack];
@@ -300,7 +320,7 @@ export class ParserVisitor extends BaseVisitor {
300
320
  variables.forEach((value, key) => {
301
321
  obj[key] = value;
302
322
  });
303
- executor.scope.variables.set(paramIds[0], obj);
323
+ executor.scope.setVariable(paramIds[0], obj);
304
324
  }
305
325
  const currentStack = this.executionStack.splice(0);
306
326
  this.executionStack.push(...stack);
@@ -381,7 +401,7 @@ export class ParserVisitor extends BaseVisitor {
381
401
  };
382
402
  visitGraphicForExpr = (ctx) => {
383
403
  const forVariableNames = ctx.ID().map(item => item.getText());
384
- const listItems = this.visitResult(ctx.data_expr());
404
+ const listItems = prepareValue(this.visitResult(ctx.data_expr()));
385
405
  let keepLooping = true;
386
406
  let counter = 0;
387
407
  let allCommands = [];
@@ -392,7 +412,7 @@ export class ParserVisitor extends BaseVisitor {
392
412
  useValueArray = [useValueArray];
393
413
  }
394
414
  useValueArray.forEach((value, index) => {
395
- this.getScope().variables.set(forVariableNames[index], value);
415
+ this.getScope().setVariable(forVariableNames[index], value);
396
416
  });
397
417
  const commands = this.visitResult(ctx.graphic_expressions_block());
398
418
  allCommands = allCommands.concat(commands);
@@ -523,6 +543,7 @@ export class ParserVisitor extends BaseVisitor {
523
543
  const ctxAssignmentExpr = ctx.assignment_expr();
524
544
  if (ctxDataExpr) {
525
545
  component = this.visitResult(ctxDataExpr);
546
+ component = prepareValue(component);
526
547
  componentCtx = ctxDataExpr;
527
548
  if (component === null || component === undefined) {
528
549
  this.throwWithContext(ctxDataExpr, "Could not find component: " + ctxDataExpr.getText());
@@ -864,15 +885,13 @@ export class ParserVisitor extends BaseVisitor {
864
885
  const executor = this.getExecutor();
865
886
  executor.log('entering at block');
866
887
  this.visit(ctx.at_component_expr());
867
- const currentComponent = executor.scope.currentComponent;
868
- const currentPin = executor.scope.currentPin;
888
+ const [currentComponent, currentPin] = executor.getCurrentPoint();
869
889
  executor.scope.indentLevel += 1;
870
890
  ctx.at_block_expressions().forEach(expression => {
871
891
  this.visit(expression);
872
892
  });
873
893
  executor.scope.indentLevel -= 1;
874
- executor.scope.currentComponent = currentComponent;
875
- executor.scope.currentPin = currentPin;
894
+ executor.scope.setCurrent(currentComponent, currentPin);
876
895
  executor.log('leaving at block');
877
896
  };
878
897
  visitAt_block_pin_expression_simple = (ctx) => {
@@ -1054,7 +1073,8 @@ export class ParserVisitor extends BaseVisitor {
1054
1073
  visitFor_expr = (ctx) => {
1055
1074
  this.log('in for loop');
1056
1075
  const forVariableNames = ctx.ID().map(item => item.getText());
1057
- const listItems = this.visitResult(ctx.data_expr());
1076
+ let listItems = this.visitResult(ctx.data_expr());
1077
+ listItems = prepareValue(listItems);
1058
1078
  this.getExecutor().addBreakContext(ctx);
1059
1079
  let keepLooping = true;
1060
1080
  let counter = 0;
@@ -1065,7 +1085,7 @@ export class ParserVisitor extends BaseVisitor {
1065
1085
  useValueArray = [useValueArray];
1066
1086
  }
1067
1087
  useValueArray.forEach((value, index) => {
1068
- this.getScope().variables.set(forVariableNames[index], value);
1088
+ this.getScope().setVariable(forVariableNames[index], value);
1069
1089
  });
1070
1090
  this.visit(ctx.expressions_block());
1071
1091
  keepLooping = true;
@@ -4,13 +4,13 @@ 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, ReferenceType } from "./objects/types.js";
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 | ReferenceType | any> {
13
+ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyReference | any> {
14
14
  indentLevel: number;
15
15
  startingContext: ExecutionContext;
16
16
  executionStack: ExecutionContext[];
@@ -1,6 +1,6 @@
1
1
  import { TerminalNode, Token } from "antlr4ng";
2
2
  import { CircuitScriptLexer } from "./antlr/CircuitScriptLexer.js";
3
- import { Function_def_exprContext, Create_component_exprContext, Create_graphic_exprContext, Atom_exprContext, Property_key_exprContext, ValueAtomExprContext, Assignment_exprContext, Import_exprContext, Function_args_exprContext, Function_call_exprContext, GraphicCommandExprContext } from "./antlr/CircuitScriptParser.js";
3
+ import { Function_def_exprContext, Create_component_exprContext, Create_graphic_exprContext, Atom_exprContext, Property_key_exprContext, ValueAtomExprContext, Assignment_exprContext, Import_exprContext, Function_args_exprContext, Function_call_exprContext, GraphicCommandExprContext, For_exprContext } from "./antlr/CircuitScriptParser.js";
4
4
  import { BaseVisitor, OnErrorHandler } from "./BaseVisitor.js";
5
5
  import { NodeScriptEnvironment } from "./environment.js";
6
6
  export declare class SemanticTokensVisitor extends BaseVisitor {
@@ -20,6 +20,7 @@ export declare class SemanticTokensVisitor extends BaseVisitor {
20
20
  visitAssignment_expr: (ctx: Assignment_exprContext) => void;
21
21
  visitAtom_expr: (ctx: Atom_exprContext) => void;
22
22
  visitImport_expr: (ctx: Import_exprContext) => void;
23
+ visitFor_expr: (ctx: For_exprContext) => void;
23
24
  addSemanticToken(node: TerminalNode, modifiers: string[], tokenType?: string | null): void;
24
25
  parseToken(node: TerminalNode, modifiers: string[], tokenType?: string | null): IParsedToken;
25
26
  dumpTokens(): void;
@@ -71,68 +71,70 @@ 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 RULE_expressions_block = 2;
75
- static readonly RULE_path_blocks = 3;
76
- static readonly RULE_path_block_inner = 4;
77
- static readonly RULE_property_set_expr2 = 5;
78
- static readonly RULE_assignment_expr2 = 6;
79
- static readonly RULE_pin_select_expr = 7;
80
- static readonly RULE_component_modifier_expr = 8;
81
- static readonly RULE_data_expr_with_assignment = 9;
82
- static readonly RULE_add_component_expr = 10;
83
- static readonly RULE_component_select_expr = 11;
84
- static readonly RULE_pin_select_expr2 = 12;
85
- static readonly RULE_at_component_expr = 13;
86
- static readonly RULE_to_component_expr = 14;
87
- static readonly RULE_at_to_multiple_expr = 15;
88
- static readonly RULE_at_to_multiple_line_expr = 16;
89
- static readonly RULE_at_to_multiple_line_expr_to_pin = 17;
90
- static readonly RULE_at_block = 18;
91
- static readonly RULE_at_block_expressions = 19;
92
- static readonly RULE_at_block_pin_expr = 20;
93
- static readonly RULE_at_block_pin_expression_simple = 21;
94
- static readonly RULE_at_block_pin_expression_complex = 22;
95
- static readonly RULE_break_keyword = 23;
96
- static readonly RULE_continue_keyword = 24;
97
- static readonly RULE_assignment_expr = 25;
98
- static readonly RULE_operator_assignment_expr = 26;
99
- static readonly RULE_keyword_assignment_expr = 27;
100
- static readonly RULE_parameters = 28;
101
- static readonly RULE_property_set_expr = 29;
102
- static readonly RULE_double_dot_property_set_expr = 30;
103
- static readonly RULE_data_expr = 31;
104
- static readonly RULE_binary_operator = 32;
105
- static readonly RULE_unary_operator = 33;
106
- static readonly RULE_value_expr = 34;
107
- static readonly RULE_function_def_expr = 35;
108
- static readonly RULE_function_expr = 36;
109
- static readonly RULE_function_args_expr = 37;
110
- static readonly RULE_atom_expr = 38;
111
- static readonly RULE_trailer_expr = 39;
112
- static readonly RULE_function_call_expr = 40;
113
- static readonly RULE_net_namespace_expr = 41;
114
- static readonly RULE_function_return_expr = 42;
115
- static readonly RULE_property_block_expr = 43;
116
- static readonly RULE_create_component_expr = 44;
117
- static readonly RULE_graphic_expressions_block = 45;
118
- static readonly RULE_create_graphic_expr = 46;
119
- static readonly RULE_create_module_expr = 47;
120
- static readonly RULE_nested_properties_inner = 48;
121
- static readonly RULE_graphic_expr = 49;
122
- static readonly RULE_property_expr = 50;
123
- static readonly RULE_property_key_expr = 51;
124
- static readonly RULE_property_value_expr = 52;
125
- static readonly RULE_wire_atom_expr = 53;
126
- static readonly RULE_wire_expr = 54;
127
- static readonly RULE_array_expr = 55;
128
- static readonly RULE_point_expr = 56;
129
- static readonly RULE_import_expr = 57;
130
- static readonly RULE_frame_expr = 58;
131
- static readonly RULE_if_expr = 59;
132
- static readonly RULE_if_inner_expr = 60;
133
- static readonly RULE_else_expr = 61;
134
- static readonly RULE_while_expr = 62;
135
- static readonly RULE_for_expr = 63;
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
+ static readonly RULE_break_keyword = 25;
98
+ static readonly RULE_continue_keyword = 26;
99
+ static readonly RULE_assignment_expr = 27;
100
+ static readonly RULE_operator_assignment_expr = 28;
101
+ static readonly RULE_keyword_assignment_expr = 29;
102
+ static readonly RULE_parameters = 30;
103
+ static readonly RULE_property_set_expr = 31;
104
+ static readonly RULE_double_dot_property_set_expr = 32;
105
+ static readonly RULE_data_expr = 33;
106
+ static readonly RULE_binary_operator = 34;
107
+ static readonly RULE_unary_operator = 35;
108
+ static readonly RULE_value_expr = 36;
109
+ static readonly RULE_function_def_expr = 37;
110
+ static readonly RULE_function_expr = 38;
111
+ static readonly RULE_function_args_expr = 39;
112
+ static readonly RULE_atom_expr = 40;
113
+ static readonly RULE_trailer_expr = 41;
114
+ static readonly RULE_function_call_expr = 42;
115
+ static readonly RULE_net_namespace_expr = 43;
116
+ static readonly RULE_function_return_expr = 44;
117
+ static readonly RULE_property_block_expr = 45;
118
+ static readonly RULE_create_component_expr = 46;
119
+ static readonly RULE_graphic_expressions_block = 47;
120
+ static readonly RULE_create_graphic_expr = 48;
121
+ static readonly RULE_create_module_expr = 49;
122
+ static readonly RULE_nested_properties_inner = 50;
123
+ static readonly RULE_graphic_expr = 51;
124
+ static readonly RULE_property_expr = 52;
125
+ static readonly RULE_property_key_expr = 53;
126
+ static readonly RULE_property_value_expr = 54;
127
+ static readonly RULE_wire_atom_expr = 55;
128
+ static readonly RULE_wire_expr = 56;
129
+ static readonly RULE_array_expr = 57;
130
+ static readonly RULE_point_expr = 58;
131
+ static readonly RULE_import_expr = 59;
132
+ static readonly RULE_frame_expr = 60;
133
+ static readonly RULE_if_expr = 61;
134
+ static readonly RULE_if_inner_expr = 62;
135
+ static readonly RULE_else_expr = 63;
136
+ static readonly RULE_while_expr = 64;
137
+ static readonly RULE_for_expr = 65;
136
138
  static readonly literalNames: (string | null)[];
137
139
  static readonly symbolicNames: (string | null)[];
138
140
  static readonly ruleNames: string[];
@@ -145,9 +147,11 @@ export declare class CircuitScriptParser extends antlr.Parser {
145
147
  constructor(input: antlr.TokenStream);
146
148
  script(): ScriptContext;
147
149
  expression(): ExpressionContext;
150
+ flow_expressions(): Flow_expressionsContext;
151
+ graph_expressions(): Graph_expressionsContext;
152
+ graph_linear_expression(): Graph_linear_expressionContext;
148
153
  expressions_block(): Expressions_blockContext;
149
- path_blocks(): Path_blocksContext;
150
- path_block_inner(): Path_block_innerContext;
154
+ path_block(): Path_blockContext;
151
155
  property_set_expr2(): Property_set_expr2Context;
152
156
  assignment_expr2(): Assignment_expr2Context;
153
157
  pin_select_expr(): Pin_select_exprContext;
@@ -231,28 +235,46 @@ export declare class ScriptContext extends antlr.ParserRuleContext {
231
235
  }
232
236
  export declare class ExpressionContext extends antlr.ParserRuleContext {
233
237
  constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
234
- add_component_expr(): Add_component_exprContext | null;
235
- to_component_expr(): To_component_exprContext | null;
236
- at_component_expr(): At_component_exprContext | null;
238
+ graph_expressions(): Graph_expressionsContext | null;
239
+ flow_expressions(): Flow_expressionsContext | null;
237
240
  assignment_expr(): Assignment_exprContext | null;
238
241
  operator_assignment_expr(): Operator_assignment_exprContext | null;
239
242
  property_set_expr(): Property_set_exprContext | null;
240
243
  property_set_expr2(): Property_set_expr2Context | null;
241
244
  double_dot_property_set_expr(): Double_dot_property_set_exprContext | null;
242
- break_keyword(): Break_keywordContext | null;
243
- continue_keyword(): Continue_keywordContext | null;
244
245
  function_def_expr(): Function_def_exprContext | null;
245
246
  function_call_expr(): Function_call_exprContext | null;
246
- wire_expr(): Wire_exprContext | null;
247
247
  import_expr(): Import_exprContext | null;
248
- frame_expr(): Frame_exprContext | null;
249
248
  atom_expr(): Atom_exprContext | null;
250
- at_block(): At_blockContext | null;
251
- path_blocks(): Path_blocksContext | null;
252
- point_expr(): Point_exprContext | null;
249
+ frame_expr(): Frame_exprContext | null;
250
+ get ruleIndex(): number;
251
+ accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
252
+ }
253
+ export declare class Flow_expressionsContext extends antlr.ParserRuleContext {
254
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
253
255
  if_expr(): If_exprContext | null;
254
256
  while_expr(): While_exprContext | null;
255
257
  for_expr(): For_exprContext | null;
258
+ break_keyword(): Break_keywordContext | null;
259
+ continue_keyword(): Continue_keywordContext | null;
260
+ get ruleIndex(): number;
261
+ accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
262
+ }
263
+ export declare class Graph_expressionsContext extends antlr.ParserRuleContext {
264
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
265
+ graph_linear_expression(): Graph_linear_expressionContext | null;
266
+ path_block(): Path_blockContext | null;
267
+ get ruleIndex(): number;
268
+ accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
269
+ }
270
+ export declare class Graph_linear_expressionContext extends antlr.ParserRuleContext {
271
+ constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
272
+ add_component_expr(): Add_component_exprContext | null;
273
+ to_component_expr(): To_component_exprContext | null;
274
+ at_component_expr(): At_component_exprContext | null;
275
+ at_block(): At_blockContext | null;
276
+ wire_expr(): Wire_exprContext | null;
277
+ point_expr(): Point_exprContext | null;
256
278
  get ruleIndex(): number;
257
279
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
258
280
  }
@@ -267,14 +289,7 @@ export declare class Expressions_blockContext extends antlr.ParserRuleContext {
267
289
  get ruleIndex(): number;
268
290
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
269
291
  }
270
- export declare class Path_blocksContext extends antlr.ParserRuleContext {
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 {
292
+ export declare class Path_blockContext extends antlr.ParserRuleContext {
278
293
  constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
279
294
  expressions_block(): Expressions_blockContext;
280
295
  Branch(): antlr.TerminalNode | null;
@@ -307,8 +322,7 @@ export declare class Assignment_expr2Context extends antlr.ParserRuleContext {
307
322
  export declare class Pin_select_exprContext extends antlr.ParserRuleContext {
308
323
  constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
309
324
  Pin(): antlr.TerminalNode;
310
- INTEGER_VALUE(): antlr.TerminalNode | null;
311
- STRING_VALUE(): antlr.TerminalNode | null;
325
+ data_expr(): Data_exprContext;
312
326
  get ruleIndex(): number;
313
327
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
314
328
  }
@@ -451,8 +465,9 @@ export declare class Continue_keywordContext extends antlr.ParserRuleContext {
451
465
  }
452
466
  export declare class Assignment_exprContext extends antlr.ParserRuleContext {
453
467
  constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
454
- atom_expr(): Atom_exprContext;
455
468
  data_expr(): Data_exprContext;
469
+ atom_expr(): Atom_exprContext | null;
470
+ function_call_expr(): Function_call_exprContext | null;
456
471
  get ruleIndex(): number;
457
472
  accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
458
473
  }
@@ -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 { Path_blocksContext } from "./CircuitScriptParser.js";
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";
@@ -78,9 +80,11 @@ import { For_exprContext } from "./CircuitScriptParser.js";
78
80
  export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisitor<Result> {
79
81
  visitScript?: (ctx: ScriptContext) => Result;
80
82
  visitExpression?: (ctx: ExpressionContext) => Result;
83
+ visitFlow_expressions?: (ctx: Flow_expressionsContext) => Result;
84
+ visitGraph_expressions?: (ctx: Graph_expressionsContext) => Result;
85
+ visitGraph_linear_expression?: (ctx: Graph_linear_expressionContext) => Result;
81
86
  visitExpressions_block?: (ctx: Expressions_blockContext) => Result;
82
- visitPath_blocks?: (ctx: Path_blocksContext) => Result;
83
- visitPath_block_inner?: (ctx: Path_block_innerContext) => Result;
87
+ visitPath_block?: (ctx: Path_blockContext) => Result;
84
88
  visitProperty_set_expr2?: (ctx: Property_set_expr2Context) => Result;
85
89
  visitAssignment_expr2?: (ctx: Assignment_expr2Context) => Result;
86
90
  visitPin_select_expr?: (ctx: Pin_select_exprContext) => Result;
@@ -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;
@@ -64,7 +64,6 @@ export declare class Geometry {
64
64
  width: number;
65
65
  height: number;
66
66
  };
67
- static FullCircleRadians: number;
68
67
  static featuresToPath(items: Feature[], flipX: number, flipY: number): {
69
68
  path: string;
70
69
  isClosedPolygon: boolean;
@@ -88,6 +88,11 @@ export declare enum BlockTypes {
88
88
  Parallel = 3,
89
89
  Point = 4
90
90
  }
91
+ export declare enum NetGraphicsParams {
92
+ Color = "color",
93
+ Highight = "highlight",
94
+ LineWidth = "lineWidth"
95
+ }
91
96
  export declare enum FrameType {
92
97
  Frame = 1,
93
98
  Sheet = 2
@@ -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: [ClassComponent, pin: number, net: Net][]): SheetFrame[];
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
- constructor(x: NumericValue, y: NumericValue, segments: WireSegment[]);
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
- constructor(x: NumericValue, y: NumericValue);
137
+ net: RenderNet;
138
+ constructor(x: NumericValue, y: NumericValue, net: RenderNet);
126
139
  }
127
140
  export type SheetFrame = {
128
141
  frame: RenderFrame;
@@ -1,7 +1,7 @@
1
1
  import { ClassComponent } from './ClassComponent.js';
2
2
  import { Net } from './Net.js';
3
- import { CFunction, ComponentPinNet, ComponentPinNetPair, ParseSymbolType, ValueType } from './types.js';
4
- import { LayoutDirection } from '../globals.js';
3
+ import { CFunction, ComponentPinNet, ComponentPinNetPair, ComponentPinWireId, ParseSymbolType, ValueType } from './types.js';
4
+ import { BlockTypes, LayoutDirection } from '../globals.js';
5
5
  import { Wire, WireSegment } from './Wire.js';
6
6
  import { Frame } from './Frame.js';
7
7
  import { ParserRuleContext } from 'antlr4ng';
@@ -17,7 +17,7 @@ export declare class ExecutionScope {
17
17
  symbols: Map<string, {
18
18
  type: ParseSymbolType;
19
19
  }>;
20
- blockStack: Map<number, any>;
20
+ blockStack: Map<number, BlockStackEntry>;
21
21
  contextStack: ParserRuleContext[];
22
22
  onPropertyHandler: OnPropertyHandler[];
23
23
  breakStack: ParserRuleContext[];
@@ -46,6 +46,7 @@ export declare class ExecutionScope {
46
46
  getNets(): ComponentPinNetPair[];
47
47
  dumpNets(): ComponentPinNet[];
48
48
  printNets(): void;
49
+ setVariable(name: string, value: any): void;
49
50
  setActive(type: ActiveObject, item: any): void;
50
51
  clearActive(): void;
51
52
  setCurrent(component: ClassComponent | null, pin?: number | null): void;
@@ -82,4 +83,15 @@ export type SequenceActionAtTo = [
82
83
  export type SequenceActionWire = [SequenceAction.Wire, wireId: number, WireSegment[]];
83
84
  export type SequenceActionAssign = [SequenceAction.Assign, variable: string, ClassComponent];
84
85
  export type SequenceItem = SequenceActionAtTo | SequenceActionWire | [SequenceAction.WireJump, wireId: number, pinId: number] | [SequenceAction.Frame, Frame, "enter" | "exit"] | SequenceActionAssign;
86
+ export type InnerBlockStackEntry = {
87
+ last_net: ComponentPinWireId | null;
88
+ ignore_last_net: boolean;
89
+ };
90
+ export type BlockStackEntry = {
91
+ start_point: ComponentPinWireId;
92
+ end_point: ComponentPinWireId | null;
93
+ inner_blocks: Map<number, InnerBlockStackEntry>;
94
+ current_index: number;
95
+ type: BlockTypes;
96
+ };
85
97
  export {};
@@ -4,6 +4,7 @@ export declare class Net {
4
4
  namespace: string;
5
5
  priority: number;
6
6
  type: any;
7
+ params: Map<string, any>;
7
8
  constructor(namespace: string, name: string, priority?: number, type?: any);
8
9
  toString(): string;
9
10
  static isSame(netA: Net, netB: Net): boolean;