circuitscript 0.0.24 → 0.0.26
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/LICENSE +1 -1
- package/dist/cjs/BaseVisitor.js +485 -0
- package/dist/cjs/SemanticTokenVisitor.js +218 -0
- package/dist/cjs/SymbolValidatorVisitor.js +233 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +256 -219
- package/dist/cjs/antlr/CircuitScriptParser.js +2891 -2151
- package/dist/cjs/antlr/CircuitScriptVisitor.js +4 -3
- package/dist/cjs/draw_symbols.js +73 -22
- package/dist/cjs/execute.js +70 -78
- package/dist/cjs/export.js +91 -5
- package/dist/cjs/geometry.js +28 -8
- package/dist/cjs/globals.js +1 -2
- package/dist/cjs/helpers.js +180 -7
- 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 +27 -20
- package/dist/cjs/objects/ClassComponent.js +4 -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/render.js +1 -1
- package/dist/cjs/validate.js +81 -0
- package/dist/cjs/visitor.js +601 -823
- package/dist/esm/BaseVisitor.mjs +486 -0
- package/dist/esm/SemanticTokenVisitor.mjs +215 -0
- package/dist/esm/SymbolValidatorVisitor.mjs +222 -0
- package/dist/esm/antlr/CircuitScriptLexer.mjs +231 -218
- package/dist/esm/antlr/CircuitScriptParser.mjs +2852 -2144
- package/dist/esm/antlr/CircuitScriptVisitor.mjs +13 -4
- package/dist/esm/draw_symbols.mjs +74 -23
- package/dist/esm/execute.mjs +70 -75
- package/dist/esm/export.mjs +89 -6
- package/dist/esm/geometry.mjs +28 -8
- package/dist/esm/globals.mjs +1 -2
- package/dist/esm/helpers.mjs +171 -9
- 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 +28 -21
- package/dist/esm/objects/ClassComponent.mjs +4 -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/render.mjs +2 -2
- package/dist/esm/validate.mjs +74 -0
- package/dist/esm/visitor.mjs +415 -643
- package/dist/types/BaseVisitor.d.ts +66 -0
- package/dist/types/SemanticTokenVisitor.d.ts +36 -0
- package/dist/types/SymbolValidatorVisitor.d.ts +61 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +37 -29
- package/dist/types/antlr/CircuitScriptParser.d.ts +606 -494
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +78 -60
- package/dist/types/draw_symbols.d.ts +12 -3
- package/dist/types/execute.d.ts +5 -10
- package/dist/types/export.d.ts +27 -1
- package/dist/types/geometry.d.ts +4 -0
- package/dist/types/globals.d.ts +2 -3
- 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/ClassComponent.d.ts +1 -0
- 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 +43 -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 +184 -0
- package/package.json +11 -6
|
@@ -1,71 +1,81 @@
|
|
|
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 { LogicalOperatorExprContext } from "./CircuitScriptParser.js";
|
|
34
|
+
import { DataExprContext } from "./CircuitScriptParser.js";
|
|
35
|
+
import { UnaryOperatorExprContext } from "./CircuitScriptParser.js";
|
|
36
|
+
import { ValueAtomExprContext } from "./CircuitScriptParser.js";
|
|
37
|
+
import { BinaryOperatorExprContext } from "./CircuitScriptParser.js";
|
|
38
|
+
import { RoundedBracketsExprContext } from "./CircuitScriptParser.js";
|
|
39
|
+
import { Binary_operatorContext } from "./CircuitScriptParser.js";
|
|
40
|
+
import { Unary_operatorContext } from "./CircuitScriptParser.js";
|
|
41
|
+
import { Value_exprContext } from "./CircuitScriptParser.js";
|
|
42
|
+
import { Function_def_exprContext } from "./CircuitScriptParser.js";
|
|
43
|
+
import { Function_exprContext } from "./CircuitScriptParser.js";
|
|
44
|
+
import { Function_args_exprContext } from "./CircuitScriptParser.js";
|
|
45
|
+
import { Atom_exprContext } from "./CircuitScriptParser.js";
|
|
46
|
+
import { Trailer_exprContext } from "./CircuitScriptParser.js";
|
|
47
|
+
import { Function_call_exprContext } from "./CircuitScriptParser.js";
|
|
48
|
+
import { Net_namespace_exprContext } from "./CircuitScriptParser.js";
|
|
49
|
+
import { Function_return_exprContext } from "./CircuitScriptParser.js";
|
|
50
|
+
import { Create_component_exprContext } from "./CircuitScriptParser.js";
|
|
51
|
+
import { Create_graphic_exprContext } from "./CircuitScriptParser.js";
|
|
52
|
+
import { Graphic_exprContext } from "./CircuitScriptParser.js";
|
|
53
|
+
import { Property_exprContext } from "./CircuitScriptParser.js";
|
|
54
|
+
import { Property_key_exprContext } from "./CircuitScriptParser.js";
|
|
55
|
+
import { Nested_propertiesContext } from "./CircuitScriptParser.js";
|
|
56
|
+
import { Single_line_propertyContext } from "./CircuitScriptParser.js";
|
|
57
|
+
import { Blank_exprContext } from "./CircuitScriptParser.js";
|
|
58
|
+
import { Wire_expr_direction_valueContext } from "./CircuitScriptParser.js";
|
|
59
|
+
import { Wire_expr_direction_onlyContext } from "./CircuitScriptParser.js";
|
|
60
|
+
import { Wire_exprContext } from "./CircuitScriptParser.js";
|
|
61
|
+
import { Point_exprContext } from "./CircuitScriptParser.js";
|
|
62
|
+
import { Import_exprContext } from "./CircuitScriptParser.js";
|
|
63
|
+
import { Frame_exprContext } from "./CircuitScriptParser.js";
|
|
64
|
+
import { If_exprContext } from "./CircuitScriptParser.js";
|
|
65
|
+
import { If_inner_exprContext } from "./CircuitScriptParser.js";
|
|
66
|
+
import { Else_exprContext } from "./CircuitScriptParser.js";
|
|
67
|
+
export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisitor<Result> {
|
|
59
68
|
visitScript?: (ctx: ScriptContext) => Result;
|
|
60
69
|
visitExpression?: (ctx: ExpressionContext) => Result;
|
|
61
70
|
visitPath_blocks?: (ctx: Path_blocksContext) => Result;
|
|
62
71
|
visitPath_block_inner?: (ctx: Path_block_innerContext) => Result;
|
|
63
72
|
visitProperty_set_expr2?: (ctx: Property_set_expr2Context) => Result;
|
|
64
73
|
visitAssignment_expr2?: (ctx: Assignment_expr2Context) => Result;
|
|
74
|
+
visitPin_select_expr?: (ctx: Pin_select_exprContext) => Result;
|
|
75
|
+
visitComponent_modifier_expr?: (ctx: Component_modifier_exprContext) => Result;
|
|
65
76
|
visitData_expr_with_assignment?: (ctx: Data_expr_with_assignmentContext) => Result;
|
|
66
77
|
visitAdd_component_expr?: (ctx: Add_component_exprContext) => Result;
|
|
67
78
|
visitComponent_select_expr?: (ctx: Component_select_exprContext) => Result;
|
|
68
|
-
visitPin_select_expr?: (ctx: Pin_select_exprContext) => Result;
|
|
69
79
|
visitPin_select_expr2?: (ctx: Pin_select_expr2Context) => Result;
|
|
70
80
|
visitAt_component_expr?: (ctx: At_component_exprContext) => Result;
|
|
71
81
|
visitTo_component_expr?: (ctx: To_component_exprContext) => Result;
|
|
@@ -83,8 +93,10 @@ export default class CircuitScriptVisitor<Result> extends ParseTreeVisitor<Resul
|
|
|
83
93
|
visitParameters?: (ctx: ParametersContext) => Result;
|
|
84
94
|
visitProperty_set_expr?: (ctx: Property_set_exprContext) => Result;
|
|
85
95
|
visitDouble_dot_property_set_expr?: (ctx: Double_dot_property_set_exprContext) => Result;
|
|
96
|
+
visitFunctionCallExpr?: (ctx: FunctionCallExprContext) => Result;
|
|
86
97
|
visitAdditionExpr?: (ctx: AdditionExprContext) => Result;
|
|
87
98
|
visitMultiplyExpr?: (ctx: MultiplyExprContext) => Result;
|
|
99
|
+
visitLogicalOperatorExpr?: (ctx: LogicalOperatorExprContext) => Result;
|
|
88
100
|
visitDataExpr?: (ctx: DataExprContext) => Result;
|
|
89
101
|
visitUnaryOperatorExpr?: (ctx: UnaryOperatorExprContext) => Result;
|
|
90
102
|
visitValueAtomExpr?: (ctx: ValueAtomExprContext) => Result;
|
|
@@ -98,18 +110,24 @@ export default class CircuitScriptVisitor<Result> extends ParseTreeVisitor<Resul
|
|
|
98
110
|
visitFunction_args_expr?: (ctx: Function_args_exprContext) => Result;
|
|
99
111
|
visitAtom_expr?: (ctx: Atom_exprContext) => Result;
|
|
100
112
|
visitTrailer_expr?: (ctx: Trailer_exprContext) => Result;
|
|
113
|
+
visitFunction_call_expr?: (ctx: Function_call_exprContext) => Result;
|
|
101
114
|
visitNet_namespace_expr?: (ctx: Net_namespace_exprContext) => Result;
|
|
102
115
|
visitFunction_return_expr?: (ctx: Function_return_exprContext) => Result;
|
|
103
116
|
visitCreate_component_expr?: (ctx: Create_component_exprContext) => Result;
|
|
104
117
|
visitCreate_graphic_expr?: (ctx: Create_graphic_exprContext) => Result;
|
|
105
|
-
|
|
118
|
+
visitGraphic_expr?: (ctx: Graphic_exprContext) => Result;
|
|
106
119
|
visitProperty_expr?: (ctx: Property_exprContext) => Result;
|
|
107
120
|
visitProperty_key_expr?: (ctx: Property_key_exprContext) => Result;
|
|
108
121
|
visitNested_properties?: (ctx: Nested_propertiesContext) => Result;
|
|
109
122
|
visitSingle_line_property?: (ctx: Single_line_propertyContext) => Result;
|
|
110
123
|
visitBlank_expr?: (ctx: Blank_exprContext) => Result;
|
|
124
|
+
visitWire_expr_direction_value?: (ctx: Wire_expr_direction_valueContext) => Result;
|
|
125
|
+
visitWire_expr_direction_only?: (ctx: Wire_expr_direction_onlyContext) => Result;
|
|
111
126
|
visitWire_expr?: (ctx: Wire_exprContext) => Result;
|
|
112
127
|
visitPoint_expr?: (ctx: Point_exprContext) => Result;
|
|
113
128
|
visitImport_expr?: (ctx: Import_exprContext) => Result;
|
|
114
129
|
visitFrame_expr?: (ctx: Frame_exprContext) => Result;
|
|
130
|
+
visitIf_expr?: (ctx: If_exprContext) => Result;
|
|
131
|
+
visitIf_inner_expr?: (ctx: If_inner_exprContext) => Result;
|
|
132
|
+
visitElse_expr?: (ctx: Else_exprContext) => Result;
|
|
115
133
|
}
|
|
@@ -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;
|
|
@@ -127,7 +136,7 @@ export declare class SymbolDrawing {
|
|
|
127
136
|
angle: number;
|
|
128
137
|
};
|
|
129
138
|
}
|
|
130
|
-
export type
|
|
139
|
+
export type GraphicExprCommand = [
|
|
131
140
|
commandName: string,
|
|
132
141
|
positionParams: any[],
|
|
133
142
|
keywordParams: Map<string, any>
|
|
@@ -135,8 +144,8 @@ export type SubExpressionCommand = [
|
|
|
135
144
|
export declare class SymbolDrawingCommands extends SymbolDrawing {
|
|
136
145
|
id: string;
|
|
137
146
|
private commands;
|
|
138
|
-
constructor(commands:
|
|
139
|
-
getCommands():
|
|
147
|
+
constructor(commands: GraphicExprCommand[]);
|
|
148
|
+
getCommands(): GraphicExprCommand[];
|
|
140
149
|
clone(): SymbolDrawingCommands;
|
|
141
150
|
}
|
|
142
151
|
type SimplePoint = [x: number, y: number];
|
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;
|
|
@@ -37,19 +36,17 @@ export declare class ExecutionContext {
|
|
|
37
36
|
display?: string;
|
|
38
37
|
type?: string;
|
|
39
38
|
width?: number;
|
|
39
|
+
copy: boolean;
|
|
40
40
|
}): ClassComponent;
|
|
41
41
|
printPoint(extra?: string): void;
|
|
42
42
|
addComponentExisting(component: ClassComponent, pin: number): ComponentPin;
|
|
43
43
|
toComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
44
44
|
addSequence?: boolean;
|
|
45
|
-
cloneNetComponent?: boolean;
|
|
46
45
|
}): ComponentPin;
|
|
47
46
|
atComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
48
47
|
addSequence?: boolean;
|
|
49
|
-
cloneNetComponent?: boolean;
|
|
50
48
|
}): ComponentPin;
|
|
51
|
-
|
|
52
|
-
private cloneComponent;
|
|
49
|
+
copyComponent(component: ClassComponent): ClassComponent;
|
|
53
50
|
enterBlocks(blockType: BlockTypes): void;
|
|
54
51
|
exitBlocks(): void;
|
|
55
52
|
enterBlock(blockIndex: number): void;
|
|
@@ -73,8 +70,6 @@ export declare class ExecutionContext {
|
|
|
73
70
|
enterFrame(): number;
|
|
74
71
|
exitFrame(frameId: number): void;
|
|
75
72
|
}
|
|
76
|
-
export declare function isNetComponent(component: ClassComponent): boolean;
|
|
77
|
-
export declare function isLabelComponent(component: ClassComponent): boolean;
|
|
78
73
|
export declare function getPortSide(pins: Map<number, PinDefinition>, arrangeProps: null | Map<string, number[]>): PortSideItem[];
|
|
79
74
|
type PortSideItem = {
|
|
80
75
|
pinId: number;
|
package/dist/types/export.d.ts
CHANGED
|
@@ -1,2 +1,28 @@
|
|
|
1
1
|
import { NetListItem } from "./visitor.js";
|
|
2
|
-
export declare function generateKiCADNetList(netlist: NetListItem[]):
|
|
2
|
+
export declare function generateKiCADNetList(netlist: NetListItem[]): {
|
|
3
|
+
tree: SExp;
|
|
4
|
+
missingFootprints: {
|
|
5
|
+
refdes: string;
|
|
6
|
+
instanceName: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
export declare function printTree(tree: (IdObject | string)[] | string, level?: number): string;
|
|
10
|
+
export declare class IdObject {
|
|
11
|
+
keyName: string;
|
|
12
|
+
constructor(keyName: string);
|
|
13
|
+
}
|
|
14
|
+
export declare function _id(key: string): IdObject;
|
|
15
|
+
export declare class SExpObject {
|
|
16
|
+
object: SExp;
|
|
17
|
+
constructor(object: SExp);
|
|
18
|
+
getKey(object?: SExp | null): IdObject;
|
|
19
|
+
getValue(object?: SExp | null): any;
|
|
20
|
+
getJSON(object?: SExp | null): {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
};
|
|
23
|
+
getWithId(id: string, object?: SExp | null): SExp | null;
|
|
24
|
+
print(): void;
|
|
25
|
+
}
|
|
26
|
+
export type SExpString = [id: IdObject, string];
|
|
27
|
+
export type SExpNested = [id: IdObject, SExp];
|
|
28
|
+
export type SExp = [id: IdObject, ...(SExpString | SExpNested)[]];
|
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/globals.d.ts
CHANGED
|
@@ -8,8 +8,6 @@ export declare enum GlobalNames {
|
|
|
8
8
|
}
|
|
9
9
|
export declare const NoNetText = "NO_NET";
|
|
10
10
|
export declare enum ParamKeys {
|
|
11
|
-
__is_net = "__is_net",
|
|
12
|
-
__is_label = "__is_label",
|
|
13
11
|
priority = "priority",
|
|
14
12
|
net_name = "net_name"
|
|
15
13
|
}
|
|
@@ -40,7 +38,8 @@ export declare enum ReferenceTypes {
|
|
|
40
38
|
function = "function",
|
|
41
39
|
value = "value",
|
|
42
40
|
variable = "variable",
|
|
43
|
-
instance = "instance"
|
|
41
|
+
instance = "instance",
|
|
42
|
+
pinType = "pinType"
|
|
44
43
|
}
|
|
45
44
|
export declare enum BlockTypes {
|
|
46
45
|
Branch = 1,
|
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
|
}
|