circuitscript 0.1.11 → 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.
- package/dist/cjs/BaseVisitor.js +78 -51
- package/dist/cjs/antlr/CircuitScriptParser.js +1059 -949
- package/dist/cjs/builtinMethods.js +5 -1
- package/dist/cjs/execute.js +43 -22
- package/dist/cjs/globals.js +7 -1
- package/dist/cjs/layout.js +50 -16
- package/dist/cjs/objects/ExecutionScope.js +3 -0
- package/dist/cjs/objects/Net.js +1 -0
- package/dist/cjs/objects/ParamDefinition.js +3 -0
- package/dist/cjs/objects/types.js +19 -10
- package/dist/cjs/render.js +48 -6
- package/dist/cjs/utils.js +16 -1
- package/dist/cjs/visitor.js +69 -52
- package/dist/esm/BaseVisitor.js +72 -45
- package/dist/esm/antlr/CircuitScriptParser.js +1052 -944
- package/dist/esm/antlr/CircuitScriptVisitor.js +4 -2
- package/dist/esm/builtinMethods.js +6 -2
- package/dist/esm/execute.js +43 -22
- package/dist/esm/globals.js +6 -0
- package/dist/esm/layout.js +53 -17
- package/dist/esm/objects/ExecutionScope.js +3 -0
- package/dist/esm/objects/Net.js +1 -0
- package/dist/esm/objects/ParamDefinition.js +4 -1
- package/dist/esm/objects/types.js +21 -15
- package/dist/esm/render.js +49 -7
- package/dist/esm/utils.js +13 -0
- package/dist/esm/visitor.js +57 -40
- package/dist/types/BaseVisitor.d.ts +2 -2
- package/dist/types/antlr/CircuitScriptParser.d.ts +99 -83
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +8 -4
- package/dist/types/execute.d.ts +1 -0
- package/dist/types/globals.d.ts +5 -0
- package/dist/types/layout.d.ts +16 -3
- package/dist/types/objects/ExecutionScope.d.ts +15 -3
- package/dist/types/objects/Net.d.ts +1 -0
- package/dist/types/objects/types.d.ts +25 -18
- package/dist/types/utils.d.ts +3 -1
- package/dist/types/visitor.d.ts +3 -2
- package/package.json +1 -1
- /package/dist/libs/{lib.cst → std.cst} +0 -0
- /package/libs/{lib.cst → std.cst} +0 -0
package/dist/esm/visitor.js
CHANGED
|
@@ -4,6 +4,7 @@ import { PinDefinition, PinIdType } from './objects/PinDefinition.js';
|
|
|
4
4
|
import { PinTypes } from './objects/PinTypes.js';
|
|
5
5
|
import { DeclaredReference, UndeclaredReference } from './objects/types.js';
|
|
6
6
|
import { BlockTypes, ComponentTypes, Delimiter1, FrameType, GlobalDocumentName, ModuleContainsKeyword, NoNetText, ParamKeys, ReferenceTypes, SymbolPinSide, ValidPinSides, WireAutoDirection } from './globals.js';
|
|
7
|
+
import { 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';
|
|
@@ -82,39 +83,55 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
82
83
|
}
|
|
83
84
|
this.setResult(ctx, componentPin);
|
|
84
85
|
};
|
|
85
|
-
|
|
86
|
-
const blocks = ctx.path_block_inner();
|
|
87
|
-
let blockIndex = 0;
|
|
86
|
+
visitPath_block = (ctx) => {
|
|
88
87
|
let blockType = BlockTypes.Branch;
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
88
|
+
if (ctx.Branch()) {
|
|
89
|
+
blockType = BlockTypes.Branch;
|
|
90
|
+
}
|
|
91
|
+
else if (ctx.Join()) {
|
|
92
|
+
blockType = BlockTypes.Join;
|
|
93
|
+
}
|
|
94
|
+
else if (ctx.Parallel()) {
|
|
95
|
+
blockType = BlockTypes.Parallel;
|
|
96
|
+
}
|
|
97
|
+
else if (ctx.Point()) {
|
|
98
|
+
blockType = BlockTypes.Point;
|
|
99
|
+
}
|
|
100
|
+
const scope = this.getScope();
|
|
101
|
+
const executor = this.getExecutor();
|
|
102
|
+
const indentLevel = scope.indentLevel;
|
|
103
|
+
if (scope.blockStack.has(indentLevel)) {
|
|
104
|
+
const blockStackEntry = scope.blockStack.get(indentLevel);
|
|
105
|
+
if (blockStackEntry.type !== blockType) {
|
|
106
|
+
executor.exitBlocks();
|
|
102
107
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
108
|
+
}
|
|
109
|
+
if (!scope.blockStack.has(indentLevel)) {
|
|
110
|
+
executor.enterBlocks(blockType);
|
|
111
|
+
}
|
|
112
|
+
const blockStackEntry = scope.blockStack.get(indentLevel);
|
|
113
|
+
const { current_index } = blockStackEntry;
|
|
114
|
+
executor.enterBlock(current_index);
|
|
115
|
+
this.visit(ctx.expressions_block());
|
|
116
|
+
executor.exitBlock(current_index);
|
|
117
|
+
blockStackEntry.current_index++;
|
|
118
|
+
};
|
|
119
|
+
visitGraph_expressions = (ctx) => {
|
|
120
|
+
if (ctx.path_block() === null) {
|
|
121
|
+
const scope = this.getScope();
|
|
122
|
+
const indentLevel = scope.indentLevel;
|
|
123
|
+
if (scope.blockStack.has(indentLevel)) {
|
|
124
|
+
this.getExecutor().exitBlocks();
|
|
109
125
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
}
|
|
127
|
+
const ctxPathBlock = ctx.path_block();
|
|
128
|
+
const ctxNotPathBlock = ctx.graph_linear_expression();
|
|
129
|
+
if (ctxPathBlock) {
|
|
130
|
+
this.visit(ctxPathBlock);
|
|
131
|
+
}
|
|
132
|
+
if (ctxNotPathBlock) {
|
|
133
|
+
this.visit(ctxNotPathBlock);
|
|
134
|
+
}
|
|
118
135
|
};
|
|
119
136
|
visitCreate_component_expr = (ctx) => {
|
|
120
137
|
const scope = this.getScope();
|
|
@@ -293,7 +310,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
293
310
|
if (ctxId !== null) {
|
|
294
311
|
const varName = ctxId.getText();
|
|
295
312
|
paramIds.push(varName);
|
|
296
|
-
this.getScope().
|
|
313
|
+
this.getScope().setVariable(varName, {});
|
|
297
314
|
}
|
|
298
315
|
const executor = this.getExecutor();
|
|
299
316
|
const stack = [...this.executionStack];
|
|
@@ -303,7 +320,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
303
320
|
variables.forEach((value, key) => {
|
|
304
321
|
obj[key] = value;
|
|
305
322
|
});
|
|
306
|
-
executor.scope.
|
|
323
|
+
executor.scope.setVariable(paramIds[0], obj);
|
|
307
324
|
}
|
|
308
325
|
const currentStack = this.executionStack.splice(0);
|
|
309
326
|
this.executionStack.push(...stack);
|
|
@@ -384,7 +401,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
384
401
|
};
|
|
385
402
|
visitGraphicForExpr = (ctx) => {
|
|
386
403
|
const forVariableNames = ctx.ID().map(item => item.getText());
|
|
387
|
-
const listItems = this.visitResult(ctx.data_expr());
|
|
404
|
+
const listItems = prepareValue(this.visitResult(ctx.data_expr()));
|
|
388
405
|
let keepLooping = true;
|
|
389
406
|
let counter = 0;
|
|
390
407
|
let allCommands = [];
|
|
@@ -395,7 +412,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
395
412
|
useValueArray = [useValueArray];
|
|
396
413
|
}
|
|
397
414
|
useValueArray.forEach((value, index) => {
|
|
398
|
-
this.getScope().
|
|
415
|
+
this.getScope().setVariable(forVariableNames[index], value);
|
|
399
416
|
});
|
|
400
417
|
const commands = this.visitResult(ctx.graphic_expressions_block());
|
|
401
418
|
allCommands = allCommands.concat(commands);
|
|
@@ -526,6 +543,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
526
543
|
const ctxAssignmentExpr = ctx.assignment_expr();
|
|
527
544
|
if (ctxDataExpr) {
|
|
528
545
|
component = this.visitResult(ctxDataExpr);
|
|
546
|
+
component = prepareValue(component);
|
|
529
547
|
componentCtx = ctxDataExpr;
|
|
530
548
|
if (component === null || component === undefined) {
|
|
531
549
|
this.throwWithContext(ctxDataExpr, "Could not find component: " + ctxDataExpr.getText());
|
|
@@ -867,15 +885,13 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
867
885
|
const executor = this.getExecutor();
|
|
868
886
|
executor.log('entering at block');
|
|
869
887
|
this.visit(ctx.at_component_expr());
|
|
870
|
-
const currentComponent = executor.
|
|
871
|
-
const currentPin = executor.scope.currentPin;
|
|
888
|
+
const [currentComponent, currentPin] = executor.getCurrentPoint();
|
|
872
889
|
executor.scope.indentLevel += 1;
|
|
873
890
|
ctx.at_block_expressions().forEach(expression => {
|
|
874
891
|
this.visit(expression);
|
|
875
892
|
});
|
|
876
893
|
executor.scope.indentLevel -= 1;
|
|
877
|
-
executor.scope.currentComponent
|
|
878
|
-
executor.scope.currentPin = currentPin;
|
|
894
|
+
executor.scope.setCurrent(currentComponent, currentPin);
|
|
879
895
|
executor.log('leaving at block');
|
|
880
896
|
};
|
|
881
897
|
visitAt_block_pin_expression_simple = (ctx) => {
|
|
@@ -1057,7 +1073,8 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1057
1073
|
visitFor_expr = (ctx) => {
|
|
1058
1074
|
this.log('in for loop');
|
|
1059
1075
|
const forVariableNames = ctx.ID().map(item => item.getText());
|
|
1060
|
-
|
|
1076
|
+
let listItems = this.visitResult(ctx.data_expr());
|
|
1077
|
+
listItems = prepareValue(listItems);
|
|
1061
1078
|
this.getExecutor().addBreakContext(ctx);
|
|
1062
1079
|
let keepLooping = true;
|
|
1063
1080
|
let counter = 0;
|
|
@@ -1068,7 +1085,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1068
1085
|
useValueArray = [useValueArray];
|
|
1069
1086
|
}
|
|
1070
1087
|
useValueArray.forEach((value, index) => {
|
|
1071
|
-
this.getScope().
|
|
1088
|
+
this.getScope().setVariable(forVariableNames[index], value);
|
|
1072
1089
|
});
|
|
1073
1090
|
this.visit(ctx.expressions_block());
|
|
1074
1091
|
keepLooping = true;
|
|
@@ -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,
|
|
7
|
+
import { CallableParameter, CFunctionOptions, ComplexType, Direction, FunctionDefinedParameter, AnyReference } from "./objects/types.js";
|
|
8
8
|
import { ParserRuleContext } from 'antlr4ng';
|
|
9
9
|
import { ExecutionWarning } from "./utils.js";
|
|
10
10
|
import { BaseError } from './utils.js';
|
|
11
11
|
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
12
12
|
import { NodeScriptEnvironment } from "./environment.js";
|
|
13
|
-
export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType |
|
|
13
|
+
export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyReference | any> {
|
|
14
14
|
indentLevel: number;
|
|
15
15
|
startingContext: ExecutionContext;
|
|
16
16
|
executionStack: ExecutionContext[];
|
|
@@ -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
|
|
75
|
-
static readonly
|
|
76
|
-
static readonly
|
|
77
|
-
static readonly
|
|
78
|
-
static readonly
|
|
79
|
-
static readonly
|
|
80
|
-
static readonly
|
|
81
|
-
static readonly
|
|
82
|
-
static readonly
|
|
83
|
-
static readonly
|
|
84
|
-
static readonly
|
|
85
|
-
static readonly
|
|
86
|
-
static readonly
|
|
87
|
-
static readonly
|
|
88
|
-
static readonly
|
|
89
|
-
static readonly
|
|
90
|
-
static readonly
|
|
91
|
-
static readonly
|
|
92
|
-
static readonly
|
|
93
|
-
static readonly
|
|
94
|
-
static readonly
|
|
95
|
-
static readonly
|
|
96
|
-
static readonly
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
235
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
|
|
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;
|
|
@@ -450,8 +465,9 @@ export declare class Continue_keywordContext extends antlr.ParserRuleContext {
|
|
|
450
465
|
}
|
|
451
466
|
export declare class Assignment_exprContext extends antlr.ParserRuleContext {
|
|
452
467
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
453
|
-
atom_expr(): Atom_exprContext;
|
|
454
468
|
data_expr(): Data_exprContext;
|
|
469
|
+
atom_expr(): Atom_exprContext | null;
|
|
470
|
+
function_call_expr(): Function_call_exprContext | null;
|
|
455
471
|
get ruleIndex(): number;
|
|
456
472
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
457
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 {
|
|
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
|
-
|
|
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;
|
package/dist/types/execute.d.ts
CHANGED
|
@@ -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;
|
package/dist/types/globals.d.ts
CHANGED
package/dist/types/layout.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Net } from './objects/Net.js';
|
|
|
8
8
|
import { Logger } from './logger.js';
|
|
9
9
|
import { Frame, FramePlotDirection } from './objects/Frame.js';
|
|
10
10
|
import { BoundBox } from './utils.js';
|
|
11
|
+
import { ComponentPinNetPair } from './objects/types.js';
|
|
11
12
|
import { NumericValue } from './objects/ParamDefinition.js';
|
|
12
13
|
export declare class LayoutEngine {
|
|
13
14
|
logger: Logger;
|
|
@@ -19,7 +20,8 @@ export declare class LayoutEngine {
|
|
|
19
20
|
protected print(...params: any[]): void;
|
|
20
21
|
protected printLevel(level: number, ...params: any[]): void;
|
|
21
22
|
protected padLevel(value: number): string;
|
|
22
|
-
runLayout(sequence: SequenceItem[], nets: [
|
|
23
|
+
runLayout(sequence: SequenceItem[], nets: ComponentPinNetPair[]): SheetFrame[];
|
|
24
|
+
private collectRenderNets;
|
|
23
25
|
private flattenFrameItems;
|
|
24
26
|
private findJunctions;
|
|
25
27
|
private placeFrames;
|
|
@@ -52,6 +54,14 @@ export declare class RenderObject {
|
|
|
52
54
|
isFloating: boolean;
|
|
53
55
|
floatingRelativeTo: [selfPin: number, nodeId: string, pin: number][];
|
|
54
56
|
}
|
|
57
|
+
export type RenderNet = {
|
|
58
|
+
netName: string;
|
|
59
|
+
net: Net;
|
|
60
|
+
color?: string;
|
|
61
|
+
lineWidth?: number;
|
|
62
|
+
highlight?: string;
|
|
63
|
+
highlightOpacity?: number;
|
|
64
|
+
};
|
|
55
65
|
export declare class RenderWire extends RenderObject {
|
|
56
66
|
id: number;
|
|
57
67
|
segments: WireSegment[];
|
|
@@ -60,7 +70,8 @@ export declare class RenderWire extends RenderObject {
|
|
|
60
70
|
y: number;
|
|
61
71
|
}[];
|
|
62
72
|
netName: string;
|
|
63
|
-
|
|
73
|
+
net: Net;
|
|
74
|
+
constructor(net: Net, x: NumericValue, y: NumericValue, segments: WireSegment[]);
|
|
64
75
|
refreshPoints(): void;
|
|
65
76
|
getAutoPoints(value: [x: NumericValue, y: NumericValue], direction: WireAutoDirection): [dx: number, dy: number][];
|
|
66
77
|
getWireEnd(): {
|
|
@@ -76,6 +87,7 @@ export type MergedWire = {
|
|
|
76
87
|
netName: string;
|
|
77
88
|
segments: [x: number, y: number][][];
|
|
78
89
|
intersectPoints: [x: number, y: number, count: number][];
|
|
90
|
+
net: RenderNet;
|
|
79
91
|
};
|
|
80
92
|
export declare class RenderComponent extends RenderObject {
|
|
81
93
|
component: ClassComponent;
|
|
@@ -122,7 +134,8 @@ export declare enum RenderFrameType {
|
|
|
122
134
|
export declare class RenderJunction {
|
|
123
135
|
x: NumericValue;
|
|
124
136
|
y: NumericValue;
|
|
125
|
-
|
|
137
|
+
net: RenderNet;
|
|
138
|
+
constructor(x: NumericValue, y: NumericValue, net: RenderNet);
|
|
126
139
|
}
|
|
127
140
|
export type SheetFrame = {
|
|
128
141
|
frame: RenderFrame;
|
|
@@ -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,
|
|
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 {};
|
|
@@ -3,6 +3,7 @@ import { ExecutionContext } from '../execute.js';
|
|
|
3
3
|
import { ClassComponent } from './ClassComponent.js';
|
|
4
4
|
import { Net } from './Net.js';
|
|
5
5
|
import { NumericValue, PercentageValue } from './ParamDefinition.js';
|
|
6
|
+
import { ReferenceTypes } from '../globals.js';
|
|
6
7
|
export type CFunction = (args: CallableParameter[], options?: CFunctionOptions) => CFunctionResult;
|
|
7
8
|
export type CFunctionOptions = {
|
|
8
9
|
netNamespace?: string;
|
|
@@ -21,6 +22,11 @@ export type ComponentPinNetPair = [
|
|
|
21
22
|
pin: number,
|
|
22
23
|
net: Net
|
|
23
24
|
];
|
|
25
|
+
export type ComponentPinWireId = [
|
|
26
|
+
component: ClassComponent,
|
|
27
|
+
pin: number,
|
|
28
|
+
wireId: number
|
|
29
|
+
];
|
|
24
30
|
export type ComponentPin = [
|
|
25
31
|
component: ClassComponent,
|
|
26
32
|
pinId: number | string
|
|
@@ -41,32 +47,33 @@ export type FunctionDefinedParameter = [
|
|
|
41
47
|
token: Token,
|
|
42
48
|
defaultValue: ValueType
|
|
43
49
|
] | [name: string, token: Token];
|
|
50
|
+
export declare class AnyReference {
|
|
51
|
+
found: boolean;
|
|
52
|
+
name?: string;
|
|
53
|
+
trailers: string[];
|
|
54
|
+
type?: ReferenceTypes;
|
|
55
|
+
value?: any;
|
|
56
|
+
parentValue?: any;
|
|
57
|
+
constructor(refType: {
|
|
58
|
+
found: boolean;
|
|
59
|
+
name?: string;
|
|
60
|
+
trailers?: string[];
|
|
61
|
+
type?: ReferenceTypes;
|
|
62
|
+
value?: any;
|
|
63
|
+
parentValue?: any;
|
|
64
|
+
});
|
|
65
|
+
}
|
|
44
66
|
export declare class UndeclaredReference {
|
|
45
|
-
reference:
|
|
46
|
-
constructor(reference:
|
|
67
|
+
reference: AnyReference;
|
|
68
|
+
constructor(reference: AnyReference);
|
|
47
69
|
throwMessage(): string;
|
|
48
70
|
toString(): string;
|
|
49
71
|
nameString(): string;
|
|
50
72
|
}
|
|
51
|
-
export declare class DeclaredReference {
|
|
52
|
-
found: boolean;
|
|
53
|
-
name?: string;
|
|
54
|
-
trailers?: string[];
|
|
55
|
-
type?: 'value' | 'instance' | 'variable';
|
|
56
|
-
value?: any;
|
|
57
|
-
parentValue?: any;
|
|
58
|
-
constructor(refType: ReferenceType);
|
|
73
|
+
export declare class DeclaredReference extends AnyReference {
|
|
59
74
|
toString(): string;
|
|
60
75
|
toDisplayString(): string;
|
|
61
76
|
}
|
|
62
|
-
export type ReferenceType = {
|
|
63
|
-
found: boolean;
|
|
64
|
-
name?: string;
|
|
65
|
-
trailers?: string[];
|
|
66
|
-
type?: 'value' | 'instance' | 'variable';
|
|
67
|
-
value?: any;
|
|
68
|
-
parentValue?: any;
|
|
69
|
-
};
|
|
70
77
|
export declare enum ParseSymbolType {
|
|
71
78
|
Variable = "variable",
|
|
72
79
|
Function = "function",
|