circuitscript 0.0.24 → 0.0.25
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 +487 -0
- package/dist/cjs/SemanticTokenVisitor.js +218 -0
- package/dist/cjs/SymbolValidatorVisitor.js +233 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +209 -195
- package/dist/cjs/antlr/CircuitScriptParser.js +2310 -2087
- package/dist/cjs/antlr/CircuitScriptVisitor.js +4 -3
- package/dist/cjs/draw_symbols.js +67 -22
- package/dist/cjs/execute.js +51 -53
- package/dist/cjs/geometry.js +28 -8
- package/dist/cjs/helpers.js +175 -5
- package/dist/cjs/index.js +2 -0
- package/dist/cjs/layout.js +8 -0
- package/dist/cjs/lexer.js +19 -22
- package/dist/cjs/main.js +6 -11
- package/dist/cjs/objects/ClassComponent.js +3 -0
- package/dist/cjs/objects/ExecutionScope.js +1 -0
- package/dist/cjs/objects/types.js +7 -1
- package/dist/cjs/parser.js +29 -258
- package/dist/cjs/validate.js +81 -0
- package/dist/cjs/visitor.js +529 -820
- package/dist/esm/BaseVisitor.mjs +488 -0
- package/dist/esm/SemanticTokenVisitor.mjs +215 -0
- package/dist/esm/SymbolValidatorVisitor.mjs +222 -0
- package/dist/esm/antlr/CircuitScriptLexer.mjs +184 -194
- package/dist/esm/antlr/CircuitScriptParser.mjs +2279 -2084
- package/dist/esm/antlr/CircuitScriptVisitor.mjs +8 -3
- package/dist/esm/draw_symbols.mjs +67 -22
- package/dist/esm/execute.mjs +50 -52
- package/dist/esm/geometry.mjs +28 -8
- package/dist/esm/helpers.mjs +165 -6
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/layout.mjs +8 -0
- package/dist/esm/lexer.mjs +10 -10
- package/dist/esm/main.mjs +7 -12
- package/dist/esm/objects/ClassComponent.mjs +3 -0
- package/dist/esm/objects/ExecutionScope.mjs +1 -0
- package/dist/esm/objects/types.mjs +6 -0
- package/dist/esm/parser.mjs +25 -230
- package/dist/esm/validate.mjs +74 -0
- package/dist/esm/visitor.mjs +343 -640
- package/dist/types/BaseVisitor.d.ts +69 -0
- package/dist/types/SemanticTokenVisitor.d.ts +36 -0
- package/dist/types/SymbolValidatorVisitor.d.ts +61 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +8 -7
- package/dist/types/antlr/CircuitScriptParser.d.ts +513 -469
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +69 -59
- package/dist/types/draw_symbols.d.ts +9 -0
- package/dist/types/execute.d.ts +5 -8
- package/dist/types/geometry.d.ts +4 -0
- package/dist/types/helpers.d.ts +32 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/lexer.d.ts +2 -2
- package/dist/types/objects/ExecutionScope.d.ts +4 -1
- package/dist/types/objects/types.d.ts +5 -0
- package/dist/types/parser.d.ts +15 -28
- package/dist/types/validate.d.ts +2 -0
- package/dist/types/visitor.d.ts +40 -95
- package/fonts/Inter-Bold.ttf +0 -0
- package/fonts/Inter-Regular.ttf +0 -0
- package/fonts/OpenSans-Regular.ttf +0 -0
- package/fonts/Roboto-Regular.ttf +0 -0
- package/libs/lib.cst +183 -0
- package/package.json +11 -6
|
@@ -1,71 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ScriptContext } from "./CircuitScriptParser";
|
|
3
|
-
import { ExpressionContext } from "./CircuitScriptParser";
|
|
4
|
-
import { Path_blocksContext } from "./CircuitScriptParser";
|
|
5
|
-
import { Path_block_innerContext } from "./CircuitScriptParser";
|
|
6
|
-
import { Property_set_expr2Context } from "./CircuitScriptParser";
|
|
7
|
-
import { Assignment_expr2Context } from "./CircuitScriptParser";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
35
|
-
import {
|
|
36
|
-
import {
|
|
37
|
-
import {
|
|
38
|
-
import {
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
41
|
-
import {
|
|
42
|
-
import {
|
|
43
|
-
import {
|
|
44
|
-
import {
|
|
45
|
-
import {
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
-
import {
|
|
51
|
-
import {
|
|
52
|
-
import {
|
|
53
|
-
import {
|
|
54
|
-
import {
|
|
55
|
-
import {
|
|
56
|
-
import {
|
|
57
|
-
import {
|
|
58
|
-
|
|
1
|
+
import { AbstractParseTreeVisitor } from "antlr4ng";
|
|
2
|
+
import { ScriptContext } from "./CircuitScriptParser.js";
|
|
3
|
+
import { ExpressionContext } from "./CircuitScriptParser.js";
|
|
4
|
+
import { Path_blocksContext } from "./CircuitScriptParser.js";
|
|
5
|
+
import { Path_block_innerContext } from "./CircuitScriptParser.js";
|
|
6
|
+
import { Property_set_expr2Context } from "./CircuitScriptParser.js";
|
|
7
|
+
import { Assignment_expr2Context } from "./CircuitScriptParser.js";
|
|
8
|
+
import { Pin_select_exprContext } from "./CircuitScriptParser.js";
|
|
9
|
+
import { Component_modifier_exprContext } from "./CircuitScriptParser.js";
|
|
10
|
+
import { Data_expr_with_assignmentContext } from "./CircuitScriptParser.js";
|
|
11
|
+
import { Add_component_exprContext } from "./CircuitScriptParser.js";
|
|
12
|
+
import { Component_select_exprContext } from "./CircuitScriptParser.js";
|
|
13
|
+
import { Pin_select_expr2Context } from "./CircuitScriptParser.js";
|
|
14
|
+
import { At_component_exprContext } from "./CircuitScriptParser.js";
|
|
15
|
+
import { To_component_exprContext } from "./CircuitScriptParser.js";
|
|
16
|
+
import { At_to_multiple_exprContext } from "./CircuitScriptParser.js";
|
|
17
|
+
import { At_to_multiple_line_exprContext } from "./CircuitScriptParser.js";
|
|
18
|
+
import { At_to_multiple_line_expr_to_pinContext } from "./CircuitScriptParser.js";
|
|
19
|
+
import { At_blockContext } from "./CircuitScriptParser.js";
|
|
20
|
+
import { At_block_expressionsContext } from "./CircuitScriptParser.js";
|
|
21
|
+
import { At_block_pin_exprContext } from "./CircuitScriptParser.js";
|
|
22
|
+
import { At_block_pin_expression_simpleContext } from "./CircuitScriptParser.js";
|
|
23
|
+
import { At_block_pin_expression_complexContext } from "./CircuitScriptParser.js";
|
|
24
|
+
import { Break_keywordContext } from "./CircuitScriptParser.js";
|
|
25
|
+
import { Assignment_exprContext } from "./CircuitScriptParser.js";
|
|
26
|
+
import { Keyword_assignment_exprContext } from "./CircuitScriptParser.js";
|
|
27
|
+
import { ParametersContext } from "./CircuitScriptParser.js";
|
|
28
|
+
import { Property_set_exprContext } from "./CircuitScriptParser.js";
|
|
29
|
+
import { Double_dot_property_set_exprContext } from "./CircuitScriptParser.js";
|
|
30
|
+
import { FunctionCallExprContext } from "./CircuitScriptParser.js";
|
|
31
|
+
import { AdditionExprContext } from "./CircuitScriptParser.js";
|
|
32
|
+
import { MultiplyExprContext } from "./CircuitScriptParser.js";
|
|
33
|
+
import { DataExprContext } from "./CircuitScriptParser.js";
|
|
34
|
+
import { UnaryOperatorExprContext } from "./CircuitScriptParser.js";
|
|
35
|
+
import { ValueAtomExprContext } from "./CircuitScriptParser.js";
|
|
36
|
+
import { BinaryOperatorExprContext } from "./CircuitScriptParser.js";
|
|
37
|
+
import { RoundedBracketsExprContext } from "./CircuitScriptParser.js";
|
|
38
|
+
import { Binary_operatorContext } from "./CircuitScriptParser.js";
|
|
39
|
+
import { Unary_operatorContext } from "./CircuitScriptParser.js";
|
|
40
|
+
import { Value_exprContext } from "./CircuitScriptParser.js";
|
|
41
|
+
import { Function_def_exprContext } from "./CircuitScriptParser.js";
|
|
42
|
+
import { Function_exprContext } from "./CircuitScriptParser.js";
|
|
43
|
+
import { Function_args_exprContext } from "./CircuitScriptParser.js";
|
|
44
|
+
import { Atom_exprContext } from "./CircuitScriptParser.js";
|
|
45
|
+
import { Trailer_exprContext } from "./CircuitScriptParser.js";
|
|
46
|
+
import { Function_call_exprContext } from "./CircuitScriptParser.js";
|
|
47
|
+
import { Net_namespace_exprContext } from "./CircuitScriptParser.js";
|
|
48
|
+
import { Function_return_exprContext } from "./CircuitScriptParser.js";
|
|
49
|
+
import { Create_component_exprContext } from "./CircuitScriptParser.js";
|
|
50
|
+
import { Create_graphic_exprContext } from "./CircuitScriptParser.js";
|
|
51
|
+
import { Sub_exprContext } from "./CircuitScriptParser.js";
|
|
52
|
+
import { Property_exprContext } from "./CircuitScriptParser.js";
|
|
53
|
+
import { Property_key_exprContext } from "./CircuitScriptParser.js";
|
|
54
|
+
import { Nested_propertiesContext } from "./CircuitScriptParser.js";
|
|
55
|
+
import { Single_line_propertyContext } from "./CircuitScriptParser.js";
|
|
56
|
+
import { Blank_exprContext } from "./CircuitScriptParser.js";
|
|
57
|
+
import { Wire_expr_direction_valueContext } from "./CircuitScriptParser.js";
|
|
58
|
+
import { Wire_expr_direction_onlyContext } from "./CircuitScriptParser.js";
|
|
59
|
+
import { Wire_exprContext } from "./CircuitScriptParser.js";
|
|
60
|
+
import { Point_exprContext } from "./CircuitScriptParser.js";
|
|
61
|
+
import { Import_exprContext } from "./CircuitScriptParser.js";
|
|
62
|
+
import { Frame_exprContext } from "./CircuitScriptParser.js";
|
|
63
|
+
export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisitor<Result> {
|
|
59
64
|
visitScript?: (ctx: ScriptContext) => Result;
|
|
60
65
|
visitExpression?: (ctx: ExpressionContext) => Result;
|
|
61
66
|
visitPath_blocks?: (ctx: Path_blocksContext) => Result;
|
|
62
67
|
visitPath_block_inner?: (ctx: Path_block_innerContext) => Result;
|
|
63
68
|
visitProperty_set_expr2?: (ctx: Property_set_expr2Context) => Result;
|
|
64
69
|
visitAssignment_expr2?: (ctx: Assignment_expr2Context) => Result;
|
|
70
|
+
visitPin_select_expr?: (ctx: Pin_select_exprContext) => Result;
|
|
71
|
+
visitComponent_modifier_expr?: (ctx: Component_modifier_exprContext) => Result;
|
|
65
72
|
visitData_expr_with_assignment?: (ctx: Data_expr_with_assignmentContext) => Result;
|
|
66
73
|
visitAdd_component_expr?: (ctx: Add_component_exprContext) => Result;
|
|
67
74
|
visitComponent_select_expr?: (ctx: Component_select_exprContext) => Result;
|
|
68
|
-
visitPin_select_expr?: (ctx: Pin_select_exprContext) => Result;
|
|
69
75
|
visitPin_select_expr2?: (ctx: Pin_select_expr2Context) => Result;
|
|
70
76
|
visitAt_component_expr?: (ctx: At_component_exprContext) => Result;
|
|
71
77
|
visitTo_component_expr?: (ctx: To_component_exprContext) => Result;
|
|
@@ -83,6 +89,7 @@ export default class CircuitScriptVisitor<Result> extends ParseTreeVisitor<Resul
|
|
|
83
89
|
visitParameters?: (ctx: ParametersContext) => Result;
|
|
84
90
|
visitProperty_set_expr?: (ctx: Property_set_exprContext) => Result;
|
|
85
91
|
visitDouble_dot_property_set_expr?: (ctx: Double_dot_property_set_exprContext) => Result;
|
|
92
|
+
visitFunctionCallExpr?: (ctx: FunctionCallExprContext) => Result;
|
|
86
93
|
visitAdditionExpr?: (ctx: AdditionExprContext) => Result;
|
|
87
94
|
visitMultiplyExpr?: (ctx: MultiplyExprContext) => Result;
|
|
88
95
|
visitDataExpr?: (ctx: DataExprContext) => Result;
|
|
@@ -98,6 +105,7 @@ export default class CircuitScriptVisitor<Result> extends ParseTreeVisitor<Resul
|
|
|
98
105
|
visitFunction_args_expr?: (ctx: Function_args_exprContext) => Result;
|
|
99
106
|
visitAtom_expr?: (ctx: Atom_exprContext) => Result;
|
|
100
107
|
visitTrailer_expr?: (ctx: Trailer_exprContext) => Result;
|
|
108
|
+
visitFunction_call_expr?: (ctx: Function_call_exprContext) => Result;
|
|
101
109
|
visitNet_namespace_expr?: (ctx: Net_namespace_exprContext) => Result;
|
|
102
110
|
visitFunction_return_expr?: (ctx: Function_return_exprContext) => Result;
|
|
103
111
|
visitCreate_component_expr?: (ctx: Create_component_exprContext) => Result;
|
|
@@ -108,6 +116,8 @@ export default class CircuitScriptVisitor<Result> extends ParseTreeVisitor<Resul
|
|
|
108
116
|
visitNested_properties?: (ctx: Nested_propertiesContext) => Result;
|
|
109
117
|
visitSingle_line_property?: (ctx: Single_line_propertyContext) => Result;
|
|
110
118
|
visitBlank_expr?: (ctx: Blank_exprContext) => Result;
|
|
119
|
+
visitWire_expr_direction_value?: (ctx: Wire_expr_direction_valueContext) => Result;
|
|
120
|
+
visitWire_expr_direction_only?: (ctx: Wire_expr_direction_onlyContext) => Result;
|
|
111
121
|
visitWire_expr?: (ctx: Wire_exprContext) => Result;
|
|
112
122
|
visitPoint_expr?: (ctx: Point_exprContext) => Result;
|
|
113
123
|
visitImport_expr?: (ctx: Import_exprContext) => Result;
|
|
@@ -6,11 +6,17 @@ export declare abstract class SymbolGraphic {
|
|
|
6
6
|
displayBounds: boolean;
|
|
7
7
|
drawing: SymbolDrawing;
|
|
8
8
|
_angle: number;
|
|
9
|
+
_flipX: number;
|
|
10
|
+
_flipY: number;
|
|
9
11
|
width: number;
|
|
10
12
|
height: number;
|
|
11
13
|
labelTexts: Map<string, string>;
|
|
12
14
|
get angle(): number;
|
|
13
15
|
set angle(value: number);
|
|
16
|
+
get flipX(): number;
|
|
17
|
+
set flipX(value: number);
|
|
18
|
+
get flipY(): number;
|
|
19
|
+
set flipY(value: number);
|
|
14
20
|
refreshDrawing(calculateSize?: boolean): void;
|
|
15
21
|
calculateSize(): void;
|
|
16
22
|
abstract generateDrawing(): void;
|
|
@@ -31,6 +37,7 @@ export declare abstract class SymbolGraphic {
|
|
|
31
37
|
protected drawBody(group: G): void;
|
|
32
38
|
protected drawPins(group: G): void;
|
|
33
39
|
protected drawLabels(group: G): void;
|
|
40
|
+
roundValues(value: number): number;
|
|
34
41
|
flipTextAnchor(value: HorizontalAlign): HorizontalAlign;
|
|
35
42
|
flipDominantBaseline(value: VerticalAlign): VerticalAlign;
|
|
36
43
|
setLabelValue(labelId: string, labelValue: string): void;
|
|
@@ -88,6 +95,8 @@ export declare class SymbolDrawing {
|
|
|
88
95
|
items: (Feature | GeometryProp)[];
|
|
89
96
|
pins: [number, Feature, number][];
|
|
90
97
|
angle: number;
|
|
98
|
+
flipX: number;
|
|
99
|
+
flipY: number;
|
|
91
100
|
mainOrigin: [number, number];
|
|
92
101
|
logger: Logger;
|
|
93
102
|
clear(): void;
|
package/dist/types/execute.d.ts
CHANGED
|
@@ -22,11 +22,10 @@ export declare class ExecutionContext {
|
|
|
22
22
|
silent: boolean;
|
|
23
23
|
logger: Logger;
|
|
24
24
|
__functionCache: {};
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
parentContext: ExecutionContext;
|
|
26
|
+
constructor(name: string, namespace: string, netNamespace: string, executionLevel: number | undefined, indentLevel: number | undefined, silent: boolean | undefined, logger: Logger, parent: ExecutionContext);
|
|
27
|
+
log(...params: any[]): void;
|
|
27
28
|
private setupRoot;
|
|
28
|
-
instanceExists(instanceName: string): boolean;
|
|
29
|
-
getComponent(instanceName: string): ClassComponent;
|
|
30
29
|
getUniqueInstanceName(className: string): string;
|
|
31
30
|
getUniqueNetName(): string;
|
|
32
31
|
getCurrentPoint(): ComponentPin;
|
|
@@ -42,14 +41,11 @@ export declare class ExecutionContext {
|
|
|
42
41
|
addComponentExisting(component: ClassComponent, pin: number): ComponentPin;
|
|
43
42
|
toComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
44
43
|
addSequence?: boolean;
|
|
45
|
-
cloneNetComponent?: boolean;
|
|
46
44
|
}): ComponentPin;
|
|
47
45
|
atComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
48
46
|
addSequence?: boolean;
|
|
49
|
-
cloneNetComponent?: boolean;
|
|
50
47
|
}): ComponentPin;
|
|
51
|
-
|
|
52
|
-
private cloneComponent;
|
|
48
|
+
cloneComponent(component: ClassComponent): ClassComponent;
|
|
53
49
|
enterBlocks(blockType: BlockTypes): void;
|
|
54
50
|
exitBlocks(): void;
|
|
55
51
|
enterBlock(blockIndex: number): void;
|
|
@@ -75,6 +71,7 @@ export declare class ExecutionContext {
|
|
|
75
71
|
}
|
|
76
72
|
export declare function isNetComponent(component: ClassComponent): boolean;
|
|
77
73
|
export declare function isLabelComponent(component: ClassComponent): boolean;
|
|
74
|
+
export declare function isNetOnlyComponent(component: ClassComponent): boolean;
|
|
78
75
|
export declare function getPortSide(pins: Map<number, PinDefinition>, arrangeProps: null | Map<string, number[]>): PortSideItem[];
|
|
79
76
|
type PortSideItem = {
|
|
80
77
|
pinId: number;
|
package/dist/types/geometry.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare class Label extends Flatten.Polygon {
|
|
|
30
30
|
constructor(id: string, text: string, anchorPoint: [number, number], polygon: Flatten.Polygon, style: LabelStyle, bounds: Box);
|
|
31
31
|
static fromPoint(id: string, x: number, y: number, text: string, style: LabelStyle): Label;
|
|
32
32
|
rotate(angle: number, origin: Flatten.Point): Label;
|
|
33
|
+
transform(matrix: Flatten.Matrix): Label;
|
|
33
34
|
getLabelPosition(): [number, number];
|
|
34
35
|
}
|
|
35
36
|
export declare class GeometryProp {
|
|
@@ -47,7 +48,9 @@ export declare class Geometry {
|
|
|
47
48
|
static arc(center: [x: number, y: number], radius: number, startAngle: number, endAngle: number, sweepDirection: boolean): Arc;
|
|
48
49
|
static getCoords(item: Feature): [number, number][];
|
|
49
50
|
static rotateDegs(feature: Feature, angleDegrees: number, center: [number, number]): Feature;
|
|
51
|
+
static flip(feature: Feature, flipX: number, flipY: number): Feature;
|
|
50
52
|
static groupRotate(features: Feature[], angle: number, center: [number, number]): Feature[];
|
|
53
|
+
static groupFlip(features: Feature[], flipX: number, flipY: number): Feature[];
|
|
51
54
|
static groupBounds(features: Feature[]): {
|
|
52
55
|
start: [number, number];
|
|
53
56
|
end: [number, number];
|
|
@@ -60,6 +63,7 @@ export declare class Geometry {
|
|
|
60
63
|
path: string;
|
|
61
64
|
isClosedPolygon: boolean;
|
|
62
65
|
};
|
|
66
|
+
static roundPathValues(pathItems: (string | number)[]): string;
|
|
63
67
|
static angle(dx: number, dy: number): number;
|
|
64
68
|
static getQuadrant(dx: number, dy: number): number;
|
|
65
69
|
static mergeWires(wirePoints: {
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
|
+
import { SymbolValidatorVisitor } from "./SymbolValidatorVisitor.js";
|
|
2
|
+
import { CommonTokenStream, DefaultErrorStrategy, Parser } from "antlr4ng";
|
|
3
|
+
import { CircuitScriptParser } from "./antlr/CircuitScriptParser.js";
|
|
4
|
+
import { CircuitScriptLexer } from "./antlr/CircuitScriptLexer.js";
|
|
5
|
+
import { IParsedToken, SemanticTokensVisitor } from "./SemanticTokenVisitor.js";
|
|
1
6
|
export declare enum JSModuleType {
|
|
2
7
|
CommonJs = "cjs",
|
|
3
8
|
ESM = "mjs"
|
|
4
9
|
}
|
|
5
|
-
export
|
|
10
|
+
export type ScriptOptions = {
|
|
11
|
+
currentDirectory: string | null;
|
|
12
|
+
defaultLibsPath: string;
|
|
13
|
+
dumpNets: boolean;
|
|
14
|
+
dumpData: boolean;
|
|
15
|
+
kicadNetlistPath: string | null;
|
|
16
|
+
showStats: boolean;
|
|
17
|
+
};
|
|
18
|
+
export declare function prepareFile(textData: string): {
|
|
19
|
+
parser: CircuitScriptParser;
|
|
20
|
+
lexer: CircuitScriptLexer;
|
|
21
|
+
lexerTimeTaken: number;
|
|
22
|
+
tokens: CommonTokenStream;
|
|
23
|
+
};
|
|
24
|
+
export declare function getScriptText(filePath: string): string | null;
|
|
25
|
+
export declare function getSemanticTokens(scriptData: string, options: ScriptOptions): {
|
|
26
|
+
visitor: SemanticTokensVisitor;
|
|
27
|
+
parsedTokens: IParsedToken[];
|
|
28
|
+
};
|
|
29
|
+
export declare class ParseErrorStrategy extends DefaultErrorStrategy {
|
|
30
|
+
reportUnwantedToken(recognizer: Parser): void;
|
|
31
|
+
}
|
|
32
|
+
export declare function validateScript(scriptData: string, options: ScriptOptions): SymbolValidatorVisitor;
|
|
33
|
+
export declare function renderScript(scriptData: string, outputPath: string, options: ScriptOptions): string | null;
|
|
6
34
|
export declare function detectJSModuleType(): JSModuleType;
|
|
7
35
|
export declare function getCurrentPath(): {
|
|
8
36
|
filePath: string;
|
|
9
37
|
};
|
|
38
|
+
export declare function getFontsPath(): string;
|
|
39
|
+
export declare function getDefaultLibsPath(): string;
|
|
40
|
+
export declare function getPackageVersion(): string;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/lexer.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CharStream, Token } from "
|
|
2
|
-
import CircuitScriptLexer from "./antlr/CircuitScriptLexer.js";
|
|
1
|
+
import { CharStream, Token } from "antlr4ng";
|
|
2
|
+
import { CircuitScriptLexer } from "./antlr/CircuitScriptLexer.js";
|
|
3
3
|
export declare class MainLexer extends CircuitScriptLexer {
|
|
4
4
|
tokens: any[];
|
|
5
5
|
indents: any[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassComponent } from './ClassComponent.js';
|
|
2
2
|
import { Net } from './Net.js';
|
|
3
|
-
import { CFunction, ComponentPinNet, ComponentPinNetPair, ValueType } from './types.js';
|
|
3
|
+
import { CFunction, ComponentPinNet, ComponentPinNetPair, ParseSymbolType, ValueType } from './types.js';
|
|
4
4
|
import { LayoutDirection } from '../globals.js';
|
|
5
5
|
import { Wire, WireSegment } from './Wire.js';
|
|
6
6
|
import { Frame } from './Frame.js';
|
|
@@ -10,6 +10,9 @@ export declare class ExecutionScope {
|
|
|
10
10
|
instances: Map<string, ClassComponent>;
|
|
11
11
|
functions: Map<string, CFunction>;
|
|
12
12
|
variables: Map<string, ValueType | ClassComponent>;
|
|
13
|
+
symbols: Map<string, {
|
|
14
|
+
type: ParseSymbolType;
|
|
15
|
+
}>;
|
|
13
16
|
blockStack: Map<number, any>;
|
|
14
17
|
wires: Wire[];
|
|
15
18
|
frames: Frame[];
|
package/dist/types/parser.d.ts
CHANGED
|
@@ -1,38 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export declare function parseFileWithVisitor(visitor: MainVisitor, data: string): {
|
|
1
|
+
import { CircuitScriptParser, ScriptContext } from './antlr/CircuitScriptParser.js';
|
|
2
|
+
import { ANTLRErrorListener, ATNConfigSet, ATNSimulator, BitSet, DefaultErrorStrategy, DFA, Parser, RecognitionException, Recognizer, Token } from 'antlr4ng';
|
|
3
|
+
import { BaseVisitor, OnErrorCallback } from './BaseVisitor.js';
|
|
4
|
+
export declare function parseFileWithVisitor(visitor: BaseVisitor, data: string): {
|
|
6
5
|
tree: ScriptContext;
|
|
7
6
|
parser: CircuitScriptParser;
|
|
8
7
|
hasError: boolean;
|
|
9
8
|
hasParseError: boolean;
|
|
10
9
|
parserTimeTaken: number;
|
|
11
10
|
lexerTimeTaken: number;
|
|
12
|
-
tokens: IParsedToken[];
|
|
13
11
|
};
|
|
14
|
-
export declare class
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
script: string;
|
|
18
|
-
semanticTokens: Map<string, IParsedToken>;
|
|
19
|
-
constructor(lexer: CircuitScriptLexer, script: string);
|
|
20
|
-
visit(ctx: ParserRuleContext): any;
|
|
21
|
-
handleError(ctx: ParserRuleContext, err: Error): void;
|
|
22
|
-
checkContext(ctx: ParserRuleContext): void;
|
|
23
|
-
addSemanticToken(parsedToken: IParsedToken): void;
|
|
24
|
-
parseToken(node: TerminalNode, modifiers: string[], tokenType?: string | null): IParsedToken;
|
|
12
|
+
export declare class TempErrorStrategy extends DefaultErrorStrategy {
|
|
13
|
+
recover(recognizer: Parser, e: RecognitionException): void;
|
|
14
|
+
reportError(recognizer: Parser, e: RecognitionException): void;
|
|
25
15
|
}
|
|
26
|
-
export
|
|
27
|
-
line: number;
|
|
28
|
-
column: number;
|
|
29
|
-
length: number;
|
|
30
|
-
tokenType: string;
|
|
31
|
-
tokenModifiers: string[];
|
|
32
|
-
textValue: string;
|
|
33
|
-
}
|
|
34
|
-
export declare class CircuitscriptParserErrorListener extends ErrorListener {
|
|
16
|
+
export declare class CircuitscriptParserErrorListener implements ANTLRErrorListener {
|
|
35
17
|
syntaxErrorCounter: number;
|
|
36
|
-
|
|
37
|
-
|
|
18
|
+
onErrorHandler: OnErrorCallback | null;
|
|
19
|
+
constructor(onErrorHandler?: OnErrorCallback | null);
|
|
20
|
+
syntaxError<S extends Token, T extends ATNSimulator>(recognizer: Recognizer<T>, offendingSymbol: S | null, line: number, charPositionInLine: number, msg: string, e: RecognitionException | null): void;
|
|
21
|
+
reportAmbiguity(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, exact: boolean, ambigAlts: BitSet | undefined, configs: ATNConfigSet): void;
|
|
22
|
+
reportAttemptingFullContext(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, conflictingAlts: BitSet | undefined, configs: ATNConfigSet): void;
|
|
23
|
+
reportContextSensitivity(recognizer: Parser, dfa: DFA, startIndex: number, stopIndex: number, prediction: number, configs: ATNConfigSet): void;
|
|
24
|
+
hasSyntaxErrors(): boolean;
|
|
38
25
|
}
|
package/dist/types/visitor.d.ts
CHANGED
|
@@ -1,101 +1,48 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Add_component_exprContext, AdditionExprContext, Assignment_exprContext, At_blockContext, At_block_pin_exprContext, At_block_pin_expression_complexContext, At_block_pin_expression_simpleContext, At_component_exprContext, Atom_exprContext, BinaryOperatorExprContext, Blank_exprContext, Path_blocksContext, Component_select_exprContext, Create_component_exprContext, Create_graphic_exprContext, DataExprContext, Data_expr_with_assignmentContext, Double_dot_property_set_exprContext, Frame_exprContext, Function_args_exprContext, Function_def_exprContext, Function_return_exprContext, Import_exprContext, Keyword_assignment_exprContext, MultiplyExprContext, Nested_propertiesContext, Net_namespace_exprContext, ParametersContext, Pin_select_expr2Context, Pin_select_exprContext, Point_exprContext, Property_exprContext, Property_key_exprContext, Property_set_exprContext, RoundedBracketsExprContext, ScriptContext, Single_line_propertyContext, Sub_exprContext, To_component_exprContext, Value_exprContext, Wire_exprContext, ValueAtomExprContext, UnaryOperatorExprContext } from './antlr/CircuitScriptParser.js';
|
|
3
|
-
import { ExecutionContext } from './execute.js';
|
|
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, Path_blocksContext, 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, Sub_exprContext, To_component_exprContext, Wire_exprContext, UnaryOperatorExprContext, Wire_expr_direction_onlyContext, Wire_expr_direction_valueContext } from './antlr/CircuitScriptParser.js';
|
|
4
2
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
5
|
-
import { PinBlankValue } from './objects/ParamDefinition.js';
|
|
6
3
|
import { PinTypes } from './objects/PinTypes.js';
|
|
7
|
-
import {
|
|
8
|
-
import { Logger } from './logger.js';
|
|
4
|
+
import { ComponentPin, ComponentPinNet } from './objects/types.js';
|
|
9
5
|
import { Net } from './objects/Net.js';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
visitCreate_graphic_expr(ctx: Create_graphic_exprContext): SymbolDrawingCommands;
|
|
48
|
-
visitSub_expr(ctx: Sub_exprContext): [
|
|
49
|
-
id: string,
|
|
50
|
-
parameters: CallableParameter[]
|
|
51
|
-
];
|
|
52
|
-
visitProperty_expr(ctx: Property_exprContext): Map<string, any>;
|
|
53
|
-
visitSingle_line_property(ctx: Single_line_propertyContext): any | any[];
|
|
54
|
-
visitNested_properties(ctx: Nested_propertiesContext): Map<string, any>;
|
|
55
|
-
visitProperty_key_expr(ctx: Property_key_exprContext): string | number;
|
|
56
|
-
visitData_expr_with_assignment(ctx: Data_expr_with_assignmentContext): [
|
|
57
|
-
component: ComplexType,
|
|
58
|
-
pin: string | number | null
|
|
59
|
-
];
|
|
60
|
-
visitValueAtomExpr(ctx: ValueAtomExprContext): ComplexType;
|
|
61
|
-
visitUnaryOperatorExpr(ctx: UnaryOperatorExprContext): ComplexType;
|
|
62
|
-
visitDataExpr(ctx: DataExprContext): ComplexType;
|
|
63
|
-
visitBinaryOperatorExpr(ctx: BinaryOperatorExprContext): boolean | number;
|
|
64
|
-
visitMultiplyExpr(ctx: MultiplyExprContext): number;
|
|
65
|
-
visitAdditionExpr(ctx: AdditionExprContext): number;
|
|
66
|
-
visitFunction_args_expr(ctx: Function_args_exprContext): FunctionDefinedParameter[];
|
|
67
|
-
createNetResolver(executionStack: ExecutionContext[]): (netName: string, netNamespace: string) => {
|
|
68
|
-
found: boolean;
|
|
69
|
-
net?: Net;
|
|
70
|
-
};
|
|
71
|
-
visitFunction_def_expr(ctx: Function_def_exprContext): void;
|
|
72
|
-
private setupDefinedParameters;
|
|
73
|
-
visitFunction_return_expr(ctx: Function_return_exprContext): ComplexType;
|
|
74
|
-
visitAtom_expr(ctx: Atom_exprContext): ReferenceType;
|
|
75
|
-
visitPin_select_expr2(ctx: Pin_select_expr2Context): string | number;
|
|
76
|
-
visitAt_block_pin_expr(ctx: At_block_pin_exprContext): ComponentPin;
|
|
77
|
-
visitAt_block(ctx: At_blockContext): ComponentPin;
|
|
78
|
-
visitAt_block_pin_expression_simple(ctx: At_block_pin_expression_simpleContext): void;
|
|
79
|
-
visitAt_block_pin_expression_complex(ctx: At_block_pin_expression_complexContext): ComponentPin;
|
|
80
|
-
visitWire_expr(ctx: Wire_exprContext): void;
|
|
81
|
-
visitPoint_expr(ctx: Point_exprContext): ComponentPin;
|
|
82
|
-
visitImport_expr(ctx: Import_exprContext): void;
|
|
83
|
-
visitProperty_set_expr(ctx: Property_set_exprContext): void;
|
|
84
|
-
visitDouble_dot_property_set_expr(ctx: Double_dot_property_set_exprContext): void;
|
|
85
|
-
visitRoundedBracketsExpr(ctx: RoundedBracketsExprContext): any;
|
|
86
|
-
visitFrame_expr(ctx: Frame_exprContext): void;
|
|
87
|
-
visitNet_namespace_expr(ctx: Net_namespace_exprContext): string;
|
|
6
|
+
import { BaseVisitor } from './BaseVisitor.js';
|
|
7
|
+
import { ParserRuleContext } from 'antlr4ng';
|
|
8
|
+
export declare class ParserVisitor extends BaseVisitor {
|
|
9
|
+
visitKeyword_assignment_expr: (ctx: Keyword_assignment_exprContext) => void;
|
|
10
|
+
visitPin_select_expr: (ctx: Pin_select_exprContext) => void;
|
|
11
|
+
visitAdd_component_expr: (ctx: Add_component_exprContext) => ComponentPin;
|
|
12
|
+
visitAt_component_expr: (ctx: At_component_exprContext) => ComponentPin;
|
|
13
|
+
visitTo_component_expr: (ctx: To_component_exprContext) => ComponentPin;
|
|
14
|
+
visitComponent_select_expr: (ctx: Component_select_exprContext) => void;
|
|
15
|
+
visitPath_blocks: (ctx: Path_blocksContext) => ComponentPin;
|
|
16
|
+
visitCreate_component_expr: (ctx: Create_component_exprContext) => void;
|
|
17
|
+
visitCreate_graphic_expr: (ctx: Create_graphic_exprContext) => void;
|
|
18
|
+
visitSub_expr: (ctx: Sub_exprContext) => void;
|
|
19
|
+
visitProperty_expr: (ctx: Property_exprContext) => void;
|
|
20
|
+
visitSingle_line_property: (ctx: Single_line_propertyContext) => void;
|
|
21
|
+
visitNested_properties: (ctx: Nested_propertiesContext) => void;
|
|
22
|
+
visitProperty_key_expr: (ctx: Property_key_exprContext) => void;
|
|
23
|
+
visitData_expr_with_assignment: (ctx: Data_expr_with_assignmentContext) => void;
|
|
24
|
+
visitUnaryOperatorExpr: (ctx: UnaryOperatorExprContext) => void;
|
|
25
|
+
visitDataExpr: (ctx: DataExprContext) => void;
|
|
26
|
+
visitBinaryOperatorExpr: (ctx: BinaryOperatorExprContext) => void;
|
|
27
|
+
visitMultiplyExpr: (ctx: MultiplyExprContext) => void;
|
|
28
|
+
visitAdditionExpr: (ctx: AdditionExprContext) => void;
|
|
29
|
+
visitFunction_def_expr: (ctx: Function_def_exprContext) => void;
|
|
30
|
+
visitPin_select_expr2: (ctx: Pin_select_expr2Context) => void;
|
|
31
|
+
visitAt_block_pin_expr: (ctx: At_block_pin_exprContext) => void;
|
|
32
|
+
visitAt_block: (ctx: At_blockContext) => void;
|
|
33
|
+
visitAt_block_pin_expression_simple: (ctx: At_block_pin_expression_simpleContext) => void;
|
|
34
|
+
visitAt_block_pin_expression_complex: (ctx: At_block_pin_expression_complexContext) => void;
|
|
35
|
+
visitWire_expr_direction_only: (ctx: Wire_expr_direction_onlyContext) => void;
|
|
36
|
+
visitWire_expr_direction_value: (ctx: Wire_expr_direction_valueContext) => void;
|
|
37
|
+
visitWire_expr: (ctx: Wire_exprContext) => void;
|
|
38
|
+
visitPoint_expr: (ctx: Point_exprContext) => ComponentPin;
|
|
39
|
+
visitProperty_set_expr: (ctx: Property_set_exprContext) => void;
|
|
40
|
+
visitDouble_dot_property_set_expr: (ctx: Double_dot_property_set_exprContext) => void;
|
|
41
|
+
visitFrame_expr: (ctx: Frame_exprContext) => void;
|
|
42
|
+
visitNet_namespace_expr: (ctx: Net_namespace_exprContext) => void;
|
|
88
43
|
pinTypes: PinTypes[];
|
|
89
|
-
createImportFileHandler(directory: string, defaultLibsPath: string): ((visitor: MainVisitor, importPath: string) => {
|
|
90
|
-
hasError: boolean;
|
|
91
|
-
hasParseError: boolean;
|
|
92
|
-
pathExists: boolean;
|
|
93
|
-
});
|
|
94
|
-
private importLib;
|
|
95
44
|
private parseCreateComponentPins;
|
|
96
45
|
private parseCreateComponentParams;
|
|
97
|
-
private prepareStringValue;
|
|
98
|
-
print(...params: any[]): void;
|
|
99
46
|
printNets(): void;
|
|
100
47
|
dumpNets(): ComponentPinNet[];
|
|
101
48
|
dumpUniqueNets(): Net[];
|
|
@@ -115,10 +62,8 @@ export declare class MainVisitor extends ParseTreeVisitor<any> {
|
|
|
115
62
|
annotateComponents(): void;
|
|
116
63
|
private resolveNets;
|
|
117
64
|
private setComponentOrientation;
|
|
65
|
+
private setComponentFlip;
|
|
118
66
|
private getPropertyExprList;
|
|
119
|
-
private runExpressions;
|
|
120
|
-
private setupPrintFunction;
|
|
121
|
-
private getNetNamespace;
|
|
122
67
|
}
|
|
123
68
|
export type NetListItem = {
|
|
124
69
|
instanceName: string;
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|