circuitscript 0.1.12 → 0.1.13
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 +88 -83
- package/dist/cjs/antlr/CircuitScriptParser.js +761 -854
- package/dist/cjs/builtinMethods.js +5 -3
- package/dist/cjs/execute.js +39 -28
- package/dist/cjs/helpers.js +11 -8
- package/dist/cjs/parser.js +3 -1
- package/dist/cjs/utils.js +3 -3
- package/dist/cjs/visitor.js +3 -3
- package/dist/esm/BaseVisitor.js +48 -43
- package/dist/esm/antlr/CircuitScriptParser.js +759 -850
- package/dist/esm/antlr/CircuitScriptVisitor.js +0 -2
- package/dist/esm/builtinMethods.js +6 -4
- package/dist/esm/execute.js +40 -29
- package/dist/esm/helpers.js +11 -8
- package/dist/esm/parser.js +3 -1
- package/dist/esm/utils.js +1 -1
- package/dist/esm/visitor.js +4 -4
- package/dist/types/BaseVisitor.d.ts +3 -4
- package/dist/types/antlr/CircuitScriptParser.d.ts +42 -58
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +0 -4
- package/dist/types/execute.d.ts +3 -2
- package/dist/types/parser.d.ts +1 -0
- package/dist/types/utils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -25,8 +25,6 @@ export class CircuitScriptVisitor extends AbstractParseTreeVisitor {
|
|
|
25
25
|
visitAt_block_pin_expr;
|
|
26
26
|
visitAt_block_pin_expression_simple;
|
|
27
27
|
visitAt_block_pin_expression_complex;
|
|
28
|
-
visitBreak_keyword;
|
|
29
|
-
visitContinue_keyword;
|
|
30
28
|
visitAssignment_expr;
|
|
31
29
|
visitOperator_assignment_expr;
|
|
32
30
|
visitKeyword_assignment_expr;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Big from "big.js";
|
|
2
2
|
import { numeric, NumericValue } from "./objects/ParamDefinition.js";
|
|
3
|
-
import {
|
|
3
|
+
import { unwrapValue, resolveToNumericValue, RuntimeExecutionError } from "./utils.js";
|
|
4
4
|
const builtInMethods = [
|
|
5
5
|
['enumerate', enumerate],
|
|
6
6
|
['toMils', toMils],
|
|
@@ -16,8 +16,7 @@ export function linkBuiltInMethods(context, visitor) {
|
|
|
16
16
|
context.createFunction('print', (params) => {
|
|
17
17
|
const args = getPositionParams(params);
|
|
18
18
|
const items = args.map(item => {
|
|
19
|
-
|
|
20
|
-
return toString(value);
|
|
19
|
+
return toString(unwrapValue(item));
|
|
21
20
|
});
|
|
22
21
|
if (visitor.printToConsole) {
|
|
23
22
|
console.log('::', ...items);
|
|
@@ -78,7 +77,7 @@ function toMils(value) {
|
|
|
78
77
|
return resolveToNumericValue(bigValue);
|
|
79
78
|
}
|
|
80
79
|
function objectLength(obj) {
|
|
81
|
-
obj =
|
|
80
|
+
obj = unwrapValue(obj);
|
|
82
81
|
if (Array.isArray(obj)) {
|
|
83
82
|
return numeric(obj.length);
|
|
84
83
|
}
|
|
@@ -109,6 +108,9 @@ function arrayGet(arrayObject, index) {
|
|
|
109
108
|
else {
|
|
110
109
|
useValue = index;
|
|
111
110
|
}
|
|
111
|
+
if (isNaN(useValue)) {
|
|
112
|
+
throw new RuntimeExecutionError("Invalid index for arrayGet");
|
|
113
|
+
}
|
|
112
114
|
return arrayObject[useValue];
|
|
113
115
|
}
|
|
114
116
|
function arraySet(arrayObject, index, setValue) {
|
package/dist/esm/execute.js
CHANGED
|
@@ -4,7 +4,7 @@ import { ActiveObject, ExecutionScope, FrameAction, SequenceAction } from './obj
|
|
|
4
4
|
import { Net } from './objects/Net.js';
|
|
5
5
|
import { numeric, NumericValue } from './objects/ParamDefinition.js';
|
|
6
6
|
import { PortSide } from './objects/PinDefinition.js';
|
|
7
|
-
import { DeclaredReference, Direction } from './objects/types.js';
|
|
7
|
+
import { AnyReference, DeclaredReference, Direction } from './objects/types.js';
|
|
8
8
|
import { Wire } from './objects/Wire.js';
|
|
9
9
|
import { Frame } from './objects/Frame.js';
|
|
10
10
|
import { CalculatePinPositions } from './layout.js';
|
|
@@ -562,38 +562,18 @@ export class ExecutionContext {
|
|
|
562
562
|
if (isVariable || isComponentInstance) {
|
|
563
563
|
const scopeList = isVariable ? context.scope.variables
|
|
564
564
|
: context.scope.instances;
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
const trailersPath = trailers.join(".");
|
|
570
|
-
if (!isComponentInstance && (parentValue instanceof ClassComponent)) {
|
|
571
|
-
isComponentInstance = true;
|
|
572
|
-
isVariable = false;
|
|
573
|
-
}
|
|
574
|
-
if (isVariable) {
|
|
575
|
-
useValue = parentValue[trailersPath];
|
|
576
|
-
}
|
|
577
|
-
else if (isComponentInstance) {
|
|
578
|
-
const tmpComponent = parentValue;
|
|
579
|
-
if (tmpComponent.typeProp === ComponentTypes.net) {
|
|
580
|
-
const usedNet = this.scope.getNet(tmpComponent, 1);
|
|
581
|
-
if (usedNet) {
|
|
582
|
-
const trailerValue = trailers.join(".");
|
|
583
|
-
useValue = usedNet.params.get(trailerValue) ?? null;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
else {
|
|
587
|
-
useValue = parentValue.parameters.get(trailersPath);
|
|
588
|
-
}
|
|
589
|
-
}
|
|
565
|
+
const useValue = scopeList.get(idName);
|
|
566
|
+
if (!isComponentInstance && (useValue instanceof ClassComponent)) {
|
|
567
|
+
isComponentInstance = true;
|
|
568
|
+
isVariable = false;
|
|
590
569
|
}
|
|
570
|
+
const tmpReference = this.resolveTrailers(isVariable ? ReferenceTypes.variable : ReferenceTypes.instance, useValue, trailers);
|
|
591
571
|
return new DeclaredReference({
|
|
592
572
|
type: isVariable ? ReferenceTypes.variable
|
|
593
573
|
: ReferenceTypes.instance,
|
|
594
|
-
found: (
|
|
595
|
-
parentValue,
|
|
596
|
-
value:
|
|
574
|
+
found: (tmpReference.value !== undefined),
|
|
575
|
+
parentValue: tmpReference.parentValue,
|
|
576
|
+
value: tmpReference.value,
|
|
597
577
|
name: idName,
|
|
598
578
|
trailers,
|
|
599
579
|
});
|
|
@@ -605,6 +585,37 @@ export class ExecutionContext {
|
|
|
605
585
|
name: idName,
|
|
606
586
|
});
|
|
607
587
|
}
|
|
588
|
+
resolveTrailers(type, item, trailers = []) {
|
|
589
|
+
let parentValue;
|
|
590
|
+
let useValue = item;
|
|
591
|
+
if (trailers.length > 0) {
|
|
592
|
+
parentValue = useValue;
|
|
593
|
+
const trailersPath = trailers.join(".");
|
|
594
|
+
if (type === ReferenceTypes.variable) {
|
|
595
|
+
useValue = parentValue[trailersPath];
|
|
596
|
+
}
|
|
597
|
+
else if (type === ReferenceTypes.instance) {
|
|
598
|
+
const tmpComponent = parentValue;
|
|
599
|
+
if (tmpComponent.typeProp === ComponentTypes.net) {
|
|
600
|
+
const usedNet = this.scope.getNet(tmpComponent, 1);
|
|
601
|
+
if (usedNet) {
|
|
602
|
+
const trailerValue = trailers.join(".");
|
|
603
|
+
useValue = usedNet.params.get(trailerValue) ?? null;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
useValue = parentValue.parameters.get(trailersPath);
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return new AnyReference({
|
|
612
|
+
found: true,
|
|
613
|
+
type: type,
|
|
614
|
+
parentValue,
|
|
615
|
+
trailers,
|
|
616
|
+
value: useValue,
|
|
617
|
+
});
|
|
618
|
+
}
|
|
608
619
|
callFunction(functionName, functionParams, executionStack, netNamespace) {
|
|
609
620
|
let __runFunc = null;
|
|
610
621
|
if (this.__functionCache[functionName] === undefined) {
|
package/dist/esm/helpers.js
CHANGED
|
@@ -184,14 +184,6 @@ export async function renderScript(scriptData, outputPath, options) {
|
|
|
184
184
|
};
|
|
185
185
|
visitor.log('reading file');
|
|
186
186
|
visitor.log('done reading file');
|
|
187
|
-
const { tree, parser, parserTimeTaken, lexerTimeTaken } = await parseFileWithVisitor(visitor, scriptData);
|
|
188
|
-
printWarnings(visitor.getWarnings());
|
|
189
|
-
showStats && console.log('Lexing took:', lexerTimeTaken);
|
|
190
|
-
showStats && console.log('Parsing took:', parserTimeTaken);
|
|
191
|
-
if (dumpNets) {
|
|
192
|
-
const nets = visitor.dumpNets();
|
|
193
|
-
nets.forEach(item => console.log(item.join(" | ")));
|
|
194
|
-
}
|
|
195
187
|
const dumpDirectory = environment.getRelativeToModule('/dump/');
|
|
196
188
|
if (dumpData) {
|
|
197
189
|
console.log('Dump data to:', dumpDirectory);
|
|
@@ -199,8 +191,19 @@ export async function renderScript(scriptData, outputPath, options) {
|
|
|
199
191
|
mkdirSync(dumpDirectory);
|
|
200
192
|
}
|
|
201
193
|
}
|
|
194
|
+
const { tree, parser, parserTimeTaken, lexerTimeTaken, throwError } = await parseFileWithVisitor(visitor, scriptData);
|
|
195
|
+
printWarnings(visitor.getWarnings());
|
|
196
|
+
showStats && console.log('Lexing took:', lexerTimeTaken);
|
|
197
|
+
showStats && console.log('Parsing took:', parserTimeTaken);
|
|
198
|
+
if (dumpNets) {
|
|
199
|
+
const nets = visitor.dumpNets();
|
|
200
|
+
nets.forEach(item => console.log(item.join(" | ")));
|
|
201
|
+
}
|
|
202
202
|
dumpData && writeFileSync(dumpDirectory + 'tree.lisp', tree.toStringTree(null, parser));
|
|
203
203
|
dumpData && writeFileSync(dumpDirectory + 'raw-parser.txt', visitor.logger.dump());
|
|
204
|
+
if (throwError) {
|
|
205
|
+
throw throwError;
|
|
206
|
+
}
|
|
204
207
|
let svgOutput = "";
|
|
205
208
|
if (errors.length === 0) {
|
|
206
209
|
const { frameComponent } = visitor.applySheetFrameComponent();
|
package/dist/esm/parser.js
CHANGED
|
@@ -18,6 +18,7 @@ export async function parseFileWithVisitor(visitor, data) {
|
|
|
18
18
|
parser.removeErrorListeners();
|
|
19
19
|
parser.addErrorListener(parserErrorListener);
|
|
20
20
|
const tree = parser.script();
|
|
21
|
+
let throwError;
|
|
21
22
|
try {
|
|
22
23
|
await visitor.visitAsync(tree);
|
|
23
24
|
}
|
|
@@ -27,7 +28,7 @@ export async function parseFileWithVisitor(visitor, data) {
|
|
|
27
28
|
visitor.onErrorHandler(error.message, null, error);
|
|
28
29
|
}
|
|
29
30
|
else {
|
|
30
|
-
|
|
31
|
+
throwError = error;
|
|
31
32
|
}
|
|
32
33
|
}
|
|
33
34
|
}
|
|
@@ -38,6 +39,7 @@ export async function parseFileWithVisitor(visitor, data) {
|
|
|
38
39
|
hasError: false,
|
|
39
40
|
parserTimeTaken,
|
|
40
41
|
lexerTimeTaken,
|
|
42
|
+
throwError
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
45
|
export class CircuitscriptParserErrorListener {
|
package/dist/esm/utils.js
CHANGED
package/dist/esm/visitor.js
CHANGED
|
@@ -4,7 +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 {
|
|
7
|
+
import { unwrapValue } from "./utils.js";
|
|
8
8
|
import { PlaceHolderCommands, SymbolDrawingCommands } from './draw_symbols.js';
|
|
9
9
|
import { BaseVisitor } from './BaseVisitor.js';
|
|
10
10
|
import { getPortType, RuntimeExecutionError } from './utils.js';
|
|
@@ -401,7 +401,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
401
401
|
};
|
|
402
402
|
visitGraphicForExpr = (ctx) => {
|
|
403
403
|
const forVariableNames = ctx.ID().map(item => item.getText());
|
|
404
|
-
const listItems =
|
|
404
|
+
const listItems = unwrapValue(this.visitResult(ctx.data_expr()));
|
|
405
405
|
let keepLooping = true;
|
|
406
406
|
let counter = 0;
|
|
407
407
|
let allCommands = [];
|
|
@@ -543,7 +543,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
543
543
|
const ctxAssignmentExpr = ctx.assignment_expr();
|
|
544
544
|
if (ctxDataExpr) {
|
|
545
545
|
component = this.visitResult(ctxDataExpr);
|
|
546
|
-
component =
|
|
546
|
+
component = unwrapValue(component);
|
|
547
547
|
componentCtx = ctxDataExpr;
|
|
548
548
|
if (component === null || component === undefined) {
|
|
549
549
|
this.throwWithContext(ctxDataExpr, "Could not find component: " + ctxDataExpr.getText());
|
|
@@ -1074,7 +1074,7 @@ export class ParserVisitor extends BaseVisitor {
|
|
|
1074
1074
|
this.log('in for loop');
|
|
1075
1075
|
const forVariableNames = ctx.ID().map(item => item.getText());
|
|
1076
1076
|
let listItems = this.visitResult(ctx.data_expr());
|
|
1077
|
-
listItems =
|
|
1077
|
+
listItems = unwrapValue(listItems);
|
|
1078
1078
|
this.getExecutor().addBreakContext(ctx);
|
|
1079
1079
|
let keepLooping = true;
|
|
1080
1080
|
let counter = 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Array_exprContext, ArrayExprContext, Assignment_exprContext, Atom_exprContext,
|
|
1
|
+
import { Array_exprContext, ArrayExprContext, Assignment_exprContext, Atom_exprContext, ExpressionContext, Flow_expressionsContext, Function_args_exprContext, Function_call_exprContext, Function_exprContext, Function_return_exprContext, FunctionCallExprContext, Import_exprContext, Operator_assignment_exprContext, ParametersContext, RoundedBracketsExprContext, ScriptContext, Value_exprContext, ValueAtomExprContext } from "./antlr/CircuitScriptParser.js";
|
|
2
2
|
import { CircuitScriptVisitor } from "./antlr/CircuitScriptVisitor.js";
|
|
3
3
|
import { ExecutionContext } from "./execute.js";
|
|
4
4
|
import { Logger } from "./logger.js";
|
|
@@ -20,7 +20,6 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
|
|
|
20
20
|
printToConsole: boolean;
|
|
21
21
|
acceptedDirections: Direction[];
|
|
22
22
|
protected resultData: Map<ParserRuleContext, any>;
|
|
23
|
-
protected paramData: Map<ParserRuleContext, any>;
|
|
24
23
|
pinTypesList: string[];
|
|
25
24
|
onErrorHandler: OnErrorHandler | null;
|
|
26
25
|
environment: NodeScriptEnvironment;
|
|
@@ -50,14 +49,14 @@ export declare class BaseVisitor extends CircuitScriptVisitor<ComplexType | AnyR
|
|
|
50
49
|
visitAtom_expr: (ctx: Atom_exprContext) => void;
|
|
51
50
|
visitFunctionCallExpr: (ctx: FunctionCallExprContext) => void;
|
|
52
51
|
visitFunction_call_expr: (ctx: Function_call_exprContext) => void;
|
|
52
|
+
private handleFunctionCall;
|
|
53
53
|
visitValue_expr: (ctx: Value_exprContext) => void;
|
|
54
54
|
visitValueAtomExpr: (ctx: ValueAtomExprContext) => void;
|
|
55
55
|
visitFunction_args_expr: (ctx: Function_args_exprContext) => void;
|
|
56
56
|
visitParameters: (ctx: ParametersContext) => void;
|
|
57
57
|
visitImport_expr: (ctx: Import_exprContext) => void;
|
|
58
58
|
visitFunction_return_expr: (ctx: Function_return_exprContext) => void;
|
|
59
|
-
|
|
60
|
-
visitContinue_keyword: (ctx: Continue_keywordContext) => void;
|
|
59
|
+
visitFlow_expressions: (ctx: Flow_expressionsContext) => void;
|
|
61
60
|
visitArray_expr: (ctx: Array_exprContext) => void;
|
|
62
61
|
visitArrayExpr: (ctx: ArrayExprContext) => void;
|
|
63
62
|
protected setResult(ctx: ParserRuleContext, value: any): void;
|
|
@@ -94,47 +94,45 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
94
94
|
static readonly RULE_at_block_pin_expr = 22;
|
|
95
95
|
static readonly RULE_at_block_pin_expression_simple = 23;
|
|
96
96
|
static readonly RULE_at_block_pin_expression_complex = 24;
|
|
97
|
-
static readonly
|
|
98
|
-
static readonly
|
|
99
|
-
static readonly
|
|
100
|
-
static readonly
|
|
101
|
-
static readonly
|
|
102
|
-
static readonly
|
|
103
|
-
static readonly
|
|
104
|
-
static readonly
|
|
105
|
-
static readonly
|
|
106
|
-
static readonly
|
|
107
|
-
static readonly
|
|
108
|
-
static readonly
|
|
109
|
-
static readonly
|
|
110
|
-
static readonly
|
|
111
|
-
static readonly
|
|
112
|
-
static readonly
|
|
113
|
-
static readonly
|
|
114
|
-
static readonly
|
|
115
|
-
static readonly
|
|
116
|
-
static readonly
|
|
117
|
-
static readonly
|
|
118
|
-
static readonly
|
|
119
|
-
static readonly
|
|
120
|
-
static readonly
|
|
121
|
-
static readonly
|
|
122
|
-
static readonly
|
|
123
|
-
static readonly
|
|
124
|
-
static readonly
|
|
125
|
-
static readonly
|
|
126
|
-
static readonly
|
|
127
|
-
static readonly
|
|
128
|
-
static readonly
|
|
129
|
-
static readonly
|
|
130
|
-
static readonly
|
|
131
|
-
static readonly
|
|
132
|
-
static readonly
|
|
133
|
-
static readonly
|
|
134
|
-
static readonly
|
|
135
|
-
static readonly
|
|
136
|
-
static readonly RULE_while_expr = 64;
|
|
137
|
-
static readonly RULE_for_expr = 65;
|
|
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;
|
|
138
136
|
static readonly literalNames: (string | null)[];
|
|
139
137
|
static readonly symbolicNames: (string | null)[];
|
|
140
138
|
static readonly ruleNames: string[];
|
|
@@ -170,8 +168,6 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
170
168
|
at_block_pin_expr(): At_block_pin_exprContext;
|
|
171
169
|
at_block_pin_expression_simple(): At_block_pin_expression_simpleContext;
|
|
172
170
|
at_block_pin_expression_complex(): At_block_pin_expression_complexContext;
|
|
173
|
-
break_keyword(): Break_keywordContext;
|
|
174
|
-
continue_keyword(): Continue_keywordContext;
|
|
175
171
|
assignment_expr(): Assignment_exprContext;
|
|
176
172
|
operator_assignment_expr(): Operator_assignment_exprContext;
|
|
177
173
|
keyword_assignment_expr(): Keyword_assignment_exprContext;
|
|
@@ -236,7 +232,6 @@ export declare class ScriptContext extends antlr.ParserRuleContext {
|
|
|
236
232
|
export declare class ExpressionContext extends antlr.ParserRuleContext {
|
|
237
233
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
238
234
|
graph_expressions(): Graph_expressionsContext | null;
|
|
239
|
-
flow_expressions(): Flow_expressionsContext | null;
|
|
240
235
|
assignment_expr(): Assignment_exprContext | null;
|
|
241
236
|
operator_assignment_expr(): Operator_assignment_exprContext | null;
|
|
242
237
|
property_set_expr(): Property_set_exprContext | null;
|
|
@@ -247,6 +242,7 @@ export declare class ExpressionContext extends antlr.ParserRuleContext {
|
|
|
247
242
|
import_expr(): Import_exprContext | null;
|
|
248
243
|
atom_expr(): Atom_exprContext | null;
|
|
249
244
|
frame_expr(): Frame_exprContext | null;
|
|
245
|
+
flow_expressions(): Flow_expressionsContext | null;
|
|
250
246
|
get ruleIndex(): number;
|
|
251
247
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
252
248
|
}
|
|
@@ -255,8 +251,8 @@ export declare class Flow_expressionsContext extends antlr.ParserRuleContext {
|
|
|
255
251
|
if_expr(): If_exprContext | null;
|
|
256
252
|
while_expr(): While_exprContext | null;
|
|
257
253
|
for_expr(): For_exprContext | null;
|
|
258
|
-
|
|
259
|
-
|
|
254
|
+
Break(): antlr.TerminalNode | null;
|
|
255
|
+
Continue(): antlr.TerminalNode | null;
|
|
260
256
|
get ruleIndex(): number;
|
|
261
257
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
262
258
|
}
|
|
@@ -451,18 +447,6 @@ export declare class At_block_pin_expression_complexContext extends antlr.Parser
|
|
|
451
447
|
get ruleIndex(): number;
|
|
452
448
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
453
449
|
}
|
|
454
|
-
export declare class Break_keywordContext extends antlr.ParserRuleContext {
|
|
455
|
-
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
456
|
-
Break(): antlr.TerminalNode;
|
|
457
|
-
get ruleIndex(): number;
|
|
458
|
-
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
459
|
-
}
|
|
460
|
-
export declare class Continue_keywordContext extends antlr.ParserRuleContext {
|
|
461
|
-
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
462
|
-
Continue(): antlr.TerminalNode;
|
|
463
|
-
get ruleIndex(): number;
|
|
464
|
-
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
465
|
-
}
|
|
466
450
|
export declare class Assignment_exprContext extends antlr.ParserRuleContext {
|
|
467
451
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
468
452
|
data_expr(): Data_exprContext;
|
|
@@ -24,8 +24,6 @@ import { At_block_expressionsContext } from "./CircuitScriptParser.js";
|
|
|
24
24
|
import { At_block_pin_exprContext } from "./CircuitScriptParser.js";
|
|
25
25
|
import { At_block_pin_expression_simpleContext } from "./CircuitScriptParser.js";
|
|
26
26
|
import { At_block_pin_expression_complexContext } from "./CircuitScriptParser.js";
|
|
27
|
-
import { Break_keywordContext } from "./CircuitScriptParser.js";
|
|
28
|
-
import { Continue_keywordContext } from "./CircuitScriptParser.js";
|
|
29
27
|
import { Assignment_exprContext } from "./CircuitScriptParser.js";
|
|
30
28
|
import { Operator_assignment_exprContext } from "./CircuitScriptParser.js";
|
|
31
29
|
import { Keyword_assignment_exprContext } from "./CircuitScriptParser.js";
|
|
@@ -103,8 +101,6 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
|
|
|
103
101
|
visitAt_block_pin_expr?: (ctx: At_block_pin_exprContext) => Result;
|
|
104
102
|
visitAt_block_pin_expression_simple?: (ctx: At_block_pin_expression_simpleContext) => Result;
|
|
105
103
|
visitAt_block_pin_expression_complex?: (ctx: At_block_pin_expression_complexContext) => Result;
|
|
106
|
-
visitBreak_keyword?: (ctx: Break_keywordContext) => Result;
|
|
107
|
-
visitContinue_keyword?: (ctx: Continue_keywordContext) => Result;
|
|
108
104
|
visitAssignment_expr?: (ctx: Assignment_exprContext) => Result;
|
|
109
105
|
visitOperator_assignment_expr?: (ctx: Operator_assignment_exprContext) => Result;
|
|
110
106
|
visitKeyword_assignment_expr?: (ctx: Keyword_assignment_exprContext) => Result;
|
package/dist/types/execute.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { BlockTypes, FrameType } from './globals.js';
|
|
1
|
+
import { BlockTypes, FrameType, ReferenceTypes } from './globals.js';
|
|
2
2
|
import { ExecutionWarning } from "./utils.js";
|
|
3
3
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
4
4
|
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
5
5
|
import { Net } from './objects/Net.js';
|
|
6
6
|
import { NumericValue, ParamDefinition } from './objects/ParamDefinition.js';
|
|
7
7
|
import { PinDefinition } from './objects/PinDefinition.js';
|
|
8
|
-
import { CFunction, CFunctionResult, CallableParameter, ComponentPin, DeclaredReference } from './objects/types.js';
|
|
8
|
+
import { AnyReference, CFunction, CFunctionResult, CallableParameter, ComponentPin, DeclaredReference } from './objects/types.js';
|
|
9
9
|
import { Logger } from './logger.js';
|
|
10
10
|
import { UnitDimension } from './helpers.js';
|
|
11
11
|
import { ParserRuleContext } from 'antlr4ng';
|
|
@@ -75,6 +75,7 @@ export declare class ExecutionContext {
|
|
|
75
75
|
hasFunction(functionName: string): boolean;
|
|
76
76
|
getFunction(functionName: string): CFunction;
|
|
77
77
|
resolveVariable(executionStack: ExecutionContext[], idName: string, trailers?: string[]): DeclaredReference;
|
|
78
|
+
resolveTrailers(type: ReferenceTypes, item: any, trailers?: string[]): AnyReference;
|
|
78
79
|
callFunction(functionName: string, functionParams: CallableParameter[], executionStack: ExecutionContext[], netNamespace: string): CFunctionResult;
|
|
79
80
|
mergeScope(childScope: ExecutionScope, namespace: string): void;
|
|
80
81
|
addWire(segments: [string, (number | UnitDimension)?][]): void;
|
package/dist/types/parser.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare function parseFileWithVisitor(visitor: BaseVisitor, data: string)
|
|
|
8
8
|
hasParseError: boolean;
|
|
9
9
|
parserTimeTaken: number;
|
|
10
10
|
lexerTimeTaken: number;
|
|
11
|
+
throwError: any;
|
|
11
12
|
}>;
|
|
12
13
|
export declare class CircuitscriptParserErrorListener implements ANTLRErrorListener {
|
|
13
14
|
syntaxErrorCounter: number;
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -73,5 +73,5 @@ export type ExecutionWarning = {
|
|
|
73
73
|
ctx?: ParserRuleContext;
|
|
74
74
|
};
|
|
75
75
|
export declare function printWarnings(warnings: ExecutionWarning[]): void;
|
|
76
|
-
export declare function
|
|
76
|
+
export declare function unwrapValue(value: AnyReference | DeclaredReference | any): any;
|
|
77
77
|
export declare function isReference(value: any): boolean;
|