circuitscript 0.1.11 → 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 +147 -115
- package/dist/cjs/antlr/CircuitScriptParser.js +949 -932
- package/dist/cjs/builtinMethods.js +7 -1
- package/dist/cjs/execute.js +67 -35
- package/dist/cjs/globals.js +7 -1
- package/dist/cjs/helpers.js +11 -8
- 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/parser.js +3 -1
- 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 +113 -81
- package/dist/esm/antlr/CircuitScriptParser.js +943 -926
- package/dist/esm/antlr/CircuitScriptVisitor.js +4 -4
- package/dist/esm/builtinMethods.js +8 -2
- package/dist/esm/execute.js +68 -36
- package/dist/esm/globals.js +6 -0
- package/dist/esm/helpers.js +11 -8
- 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/parser.js +3 -1
- 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 +5 -6
- package/dist/types/antlr/CircuitScriptParser.d.ts +58 -58
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +8 -8
- package/dist/types/execute.d.ts +4 -2
- 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/parser.d.ts +1 -0
- 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
|
@@ -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",
|
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
|
@@ -4,7 +4,7 @@ import { ClassComponent } from "./objects/ClassComponent.js";
|
|
|
4
4
|
import { NumericValue } from "./objects/ParamDefinition.js";
|
|
5
5
|
import { SequenceAction, SequenceItem } from './objects/ExecutionScope.js';
|
|
6
6
|
import { BlockTypes } from './globals.js';
|
|
7
|
-
import {
|
|
7
|
+
import { DeclaredReference, AnyReference } from './objects/types.js';
|
|
8
8
|
export declare class SimpleStopwatch {
|
|
9
9
|
startTime: Date;
|
|
10
10
|
constructor();
|
|
@@ -73,3 +73,5 @@ export type ExecutionWarning = {
|
|
|
73
73
|
ctx?: ParserRuleContext;
|
|
74
74
|
};
|
|
75
75
|
export declare function printWarnings(warnings: ExecutionWarning[]): void;
|
|
76
|
+
export declare function unwrapValue(value: AnyReference | DeclaredReference | any): any;
|
|
77
|
+
export declare function isReference(value: any): boolean;
|
package/dist/types/visitor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Add_component_exprContext, AdditionExprContext, At_blockContext, At_block_pin_exprContext, At_block_pin_expression_complexContext, At_block_pin_expression_simpleContext, At_component_exprContext, BinaryOperatorExprContext,
|
|
1
|
+
import { Add_component_exprContext, AdditionExprContext, At_blockContext, At_block_pin_exprContext, At_block_pin_expression_complexContext, At_block_pin_expression_simpleContext, At_component_exprContext, BinaryOperatorExprContext, Component_select_exprContext, Create_component_exprContext, Create_graphic_exprContext, DataExprContext, Data_expr_with_assignmentContext, Double_dot_property_set_exprContext, Frame_exprContext, Function_def_exprContext, Keyword_assignment_exprContext, MultiplyExprContext, Nested_propertiesContext, Net_namespace_exprContext, Pin_select_expr2Context, Pin_select_exprContext, Point_exprContext, Property_exprContext, Property_key_exprContext, Property_set_exprContext, Single_line_propertyContext, To_component_exprContext, Wire_exprContext, UnaryOperatorExprContext, Wire_expr_direction_onlyContext, Wire_expr_direction_valueContext, If_exprContext, If_inner_exprContext, LogicalOperatorExprContext, Nested_properties_innerContext, Expressions_blockContext, Create_module_exprContext, Property_block_exprContext, While_exprContext, For_exprContext, GraphicCommandExprContext, Graphic_expressions_blockContext, GraphicForExprContext, Graph_expressionsContext, Path_blockContext } from './antlr/CircuitScriptParser.js';
|
|
2
2
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
3
3
|
import { PinTypes } from './objects/PinTypes.js';
|
|
4
4
|
import { ComponentPin, ComponentPinNet, ComponentPinNetPair } from './objects/types.js';
|
|
@@ -13,7 +13,8 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
13
13
|
visitAt_component_expr: (ctx: At_component_exprContext) => ComponentPin;
|
|
14
14
|
visitTo_component_expr: (ctx: To_component_exprContext) => ComponentPin;
|
|
15
15
|
visitComponent_select_expr: (ctx: Component_select_exprContext) => void;
|
|
16
|
-
|
|
16
|
+
visitPath_block: (ctx: Path_blockContext) => void;
|
|
17
|
+
visitGraph_expressions: (ctx: Graph_expressionsContext) => void;
|
|
17
18
|
visitCreate_component_expr: (ctx: Create_component_exprContext) => void;
|
|
18
19
|
visitCreate_graphic_expr: (ctx: Create_graphic_exprContext) => void;
|
|
19
20
|
visitGraphic_expressions_block: (ctx: Graphic_expressions_blockContext) => void;
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|