circuitscript 0.0.20 → 0.0.22
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/__tests__/testParse.ts +15 -0
- package/build/src/antlr/CircuitScriptLexer.d.ts +71 -0
- package/build/src/antlr/CircuitScriptParser.d.ts +674 -0
- package/build/src/antlr/CircuitScriptParser.js +142 -112
- package/build/src/antlr/CircuitScriptVisitor.d.ts +115 -0
- package/build/src/antlr/CircuitScriptVisitor.js +2 -0
- package/build/src/draw_symbols.d.ts +162 -0
- package/build/src/execute.d.ts +85 -0
- package/build/src/export.d.ts +2 -0
- package/build/src/fonts.d.ts +1 -0
- package/build/src/geometry.d.ts +84 -0
- package/build/src/globals.d.ts +50 -0
- package/build/src/helpers.d.ts +1 -0
- package/build/src/layout.d.ts +147 -0
- package/build/src/lexer.d.ts +19 -0
- package/build/src/logger.d.ts +6 -0
- package/build/src/main.d.ts +2 -0
- package/build/src/objects/ClassComponent.d.ts +40 -0
- package/build/src/objects/ExecutionScope.d.ts +64 -0
- package/build/src/objects/Frame.d.ts +15 -0
- package/build/src/objects/Net.d.ts +10 -0
- package/build/src/objects/ParamDefinition.d.ts +20 -0
- package/build/src/objects/PinDefinition.d.ts +24 -0
- package/build/src/objects/PinTypes.d.ts +7 -0
- package/build/src/objects/Wire.d.ts +11 -0
- package/build/src/objects/types.d.ts +49 -0
- package/build/src/regenerate-tests.d.ts +1 -0
- package/build/src/render.d.ts +10 -0
- package/build/src/server.d.ts +1 -0
- package/build/src/sizing.d.ts +13 -0
- package/build/src/utils.d.ts +19 -0
- package/build/src/visitor.d.ts +133 -0
- package/build/src/visitor.js +13 -4
- package/package.json +1 -1
- package/src/antlr/CircuitScript.g4 +3 -2
- package/src/antlr/CircuitScriptParser.ts +117 -87
- package/src/antlr/CircuitScriptVisitor.ts +16 -0
- package/src/visitor.ts +27 -11
- package/tsconfig.json +1 -0
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { G } from "@svgdotjs/svg.js";
|
|
2
|
+
import { Feature, GeometryProp, HorizontalAlign, Label, LabelStyle, VerticalAlign } from "./geometry.js";
|
|
3
|
+
import { Logger } from "./logger.js";
|
|
4
|
+
export declare abstract class SymbolGraphic {
|
|
5
|
+
drawPortsName: boolean;
|
|
6
|
+
displayBounds: boolean;
|
|
7
|
+
drawing: SymbolDrawing;
|
|
8
|
+
_angle: number;
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
labelTexts: Map<string, string>;
|
|
12
|
+
get angle(): number;
|
|
13
|
+
set angle(value: number);
|
|
14
|
+
refreshDrawing(calculateSize?: boolean): void;
|
|
15
|
+
calculateSize(): void;
|
|
16
|
+
abstract generateDrawing(): void;
|
|
17
|
+
size(): {
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
};
|
|
21
|
+
draw(group: G, extra?: {}): void;
|
|
22
|
+
drawPlaceRemove(group: G, extra?: {
|
|
23
|
+
place?: boolean;
|
|
24
|
+
}): void;
|
|
25
|
+
pinPosition(id: number): {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
angle: number;
|
|
29
|
+
};
|
|
30
|
+
protected drawBounds(group: G): void;
|
|
31
|
+
protected drawBody(group: G): void;
|
|
32
|
+
protected drawPins(group: G): void;
|
|
33
|
+
protected drawLabels(group: G): void;
|
|
34
|
+
flipTextAnchor(value: HorizontalAlign): HorizontalAlign;
|
|
35
|
+
flipDominantBaseline(value: VerticalAlign): VerticalAlign;
|
|
36
|
+
setLabelValue(labelId: string, labelValue: string): void;
|
|
37
|
+
getLabelValue(labelId: string): string;
|
|
38
|
+
}
|
|
39
|
+
export declare function SymbolFactory(name: string): SymbolGraphic | null;
|
|
40
|
+
export declare class SymbolPointHidden extends SymbolGraphic {
|
|
41
|
+
generateDrawing(): void;
|
|
42
|
+
}
|
|
43
|
+
export declare class SymbolText extends SymbolGraphic {
|
|
44
|
+
text: string;
|
|
45
|
+
fontSize: number;
|
|
46
|
+
fontWeight: string;
|
|
47
|
+
constructor(text: string);
|
|
48
|
+
generateDrawing(): void;
|
|
49
|
+
}
|
|
50
|
+
export declare class SymbolPlaceholder extends SymbolGraphic {
|
|
51
|
+
generateDrawing(): void;
|
|
52
|
+
drawPinParams(drawing: SymbolDrawingCommands, commandName: string, keywordParams: Map<string, any>, positionParams: any[]): void;
|
|
53
|
+
constructor(drawing: SymbolDrawing);
|
|
54
|
+
}
|
|
55
|
+
export declare enum PlaceHolderCommands {
|
|
56
|
+
arc = "arc",
|
|
57
|
+
circle = "circle",
|
|
58
|
+
rect = "rect",
|
|
59
|
+
triangle = "triangle",
|
|
60
|
+
pin = "pin",
|
|
61
|
+
hpin = "hpin",
|
|
62
|
+
vpin = "vpin",
|
|
63
|
+
hline = "hline",
|
|
64
|
+
vline = "vline",
|
|
65
|
+
line = "line",
|
|
66
|
+
label = "label",
|
|
67
|
+
path = "path",
|
|
68
|
+
lineWidth = "lineWidth",
|
|
69
|
+
fill = "fill",
|
|
70
|
+
lineColor = "lineColor"
|
|
71
|
+
}
|
|
72
|
+
export declare class SymbolCustom extends SymbolGraphic {
|
|
73
|
+
pinDefinition: SymbolPinDefintion[];
|
|
74
|
+
bodyWidth: number;
|
|
75
|
+
pinLength: number;
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
pinSpacing: number;
|
|
79
|
+
pinTextPadding: number;
|
|
80
|
+
pins: SymbolPinLayout[];
|
|
81
|
+
_cacheLeftPins: SymbolPinDefintion[];
|
|
82
|
+
_cacheRightPins: SymbolPinDefintion[];
|
|
83
|
+
constructor(pinDefinition: SymbolPinDefintion[]);
|
|
84
|
+
generateDrawing(): void;
|
|
85
|
+
calculateSize(): void;
|
|
86
|
+
}
|
|
87
|
+
export declare class SymbolDrawing {
|
|
88
|
+
items: (Feature | GeometryProp)[];
|
|
89
|
+
pins: [number, Feature, number][];
|
|
90
|
+
angle: number;
|
|
91
|
+
mainOrigin: [number, number];
|
|
92
|
+
logger: Logger;
|
|
93
|
+
clear(): void;
|
|
94
|
+
log(...params: any[]): void;
|
|
95
|
+
addLine(startX: number, startY: number, endX: number, endY: number): SymbolDrawing;
|
|
96
|
+
addPin(pinId: number, startX: number, startY: number, endX: number, endY: number): SymbolDrawing;
|
|
97
|
+
addVLine(startX: number, startY: number, value: number): SymbolDrawing;
|
|
98
|
+
addHLine(startX: number, startY: number, value: number): SymbolDrawing;
|
|
99
|
+
addRect(centerX: number, centerY: number, width: number, height: number): SymbolDrawing;
|
|
100
|
+
addTriangle(startX: number, startY: number, endX: number, endY: number, width: number): SymbolDrawing;
|
|
101
|
+
addRect2(x: number, y: number, x2: number, y2: number): SymbolDrawing;
|
|
102
|
+
addLabel(x: number, y: number, textValue: string, style: LabelStyle): SymbolDrawing;
|
|
103
|
+
addLabelId(id: string, x: number, y: number, textValue: string, style: LabelStyle): SymbolDrawing;
|
|
104
|
+
addPath(...pathParts: any): SymbolDrawing;
|
|
105
|
+
addSetLineWidth(value: number): SymbolDrawing;
|
|
106
|
+
addSetLineColor(value: string): SymbolDrawing;
|
|
107
|
+
addSetFillColor(value: string): SymbolDrawing;
|
|
108
|
+
addArc(x: number, y: number, radius: number, startAngle: number, endAngle: number): SymbolDrawing;
|
|
109
|
+
getPaths(): {
|
|
110
|
+
path: string;
|
|
111
|
+
fillColor: string;
|
|
112
|
+
lineColor: string;
|
|
113
|
+
lineWidth: number;
|
|
114
|
+
}[];
|
|
115
|
+
getPinsPath(): string;
|
|
116
|
+
getLabels(): Label[];
|
|
117
|
+
private featuresToPath;
|
|
118
|
+
getBoundingBox(excludeLabels?: boolean): {
|
|
119
|
+
width: number;
|
|
120
|
+
height: number;
|
|
121
|
+
start: SimplePoint;
|
|
122
|
+
end: SimplePoint;
|
|
123
|
+
};
|
|
124
|
+
getPinPosition(pinId: number): {
|
|
125
|
+
start: [number, number];
|
|
126
|
+
end: [number, number];
|
|
127
|
+
angle: number;
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
export type SubExpressionCommand = [
|
|
131
|
+
commandName: string,
|
|
132
|
+
positionParams: any[],
|
|
133
|
+
keywordParams: Map<string, any>
|
|
134
|
+
];
|
|
135
|
+
export declare class SymbolDrawingCommands extends SymbolDrawing {
|
|
136
|
+
id: string;
|
|
137
|
+
private commands;
|
|
138
|
+
constructor(commands: SubExpressionCommand[]);
|
|
139
|
+
getCommands(): SubExpressionCommand[];
|
|
140
|
+
clone(): SymbolDrawingCommands;
|
|
141
|
+
}
|
|
142
|
+
type SimplePoint = [x: number, y: number];
|
|
143
|
+
type SymbolPinLayout = {
|
|
144
|
+
pinId: number;
|
|
145
|
+
angle: number;
|
|
146
|
+
text: string;
|
|
147
|
+
start: {
|
|
148
|
+
x: number;
|
|
149
|
+
y: number;
|
|
150
|
+
};
|
|
151
|
+
end: {
|
|
152
|
+
x: number;
|
|
153
|
+
y: number;
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
export type SymbolPinDefintion = {
|
|
157
|
+
side: string;
|
|
158
|
+
pinId: number;
|
|
159
|
+
text: string;
|
|
160
|
+
position: number;
|
|
161
|
+
};
|
|
162
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { BlockTypes } from './globals.js';
|
|
2
|
+
import { ClassComponent } from './objects/ClassComponent.js';
|
|
3
|
+
import { ExecutionScope } from './objects/ExecutionScope.js';
|
|
4
|
+
import { Net } from './objects/Net.js';
|
|
5
|
+
import { ParamDefinition } from './objects/ParamDefinition.js';
|
|
6
|
+
import { PinDefinition } from './objects/PinDefinition.js';
|
|
7
|
+
import { CFunction, CFunctionResult, CallableParameter, ComponentPin, ReferenceType } from './objects/types.js';
|
|
8
|
+
import { Logger } from './logger.js';
|
|
9
|
+
export declare class ExecutionContext {
|
|
10
|
+
name: string;
|
|
11
|
+
namespace: string;
|
|
12
|
+
netNamespace: string;
|
|
13
|
+
executionLevel: number;
|
|
14
|
+
scope: ExecutionScope;
|
|
15
|
+
tmpPointId: number;
|
|
16
|
+
resolveNet: (name: string, netNamespace: string) => ({
|
|
17
|
+
found: boolean;
|
|
18
|
+
net?: Net;
|
|
19
|
+
});
|
|
20
|
+
stopFurtherExpressions: boolean;
|
|
21
|
+
returnValue: any;
|
|
22
|
+
silent: boolean;
|
|
23
|
+
logger: Logger;
|
|
24
|
+
__functionCache: {};
|
|
25
|
+
constructor(name: string, namespace: string, netNamespace: string, executionLevel: number, indentLevel: number, silent: boolean, logger: Logger);
|
|
26
|
+
print(...params: any[]): void;
|
|
27
|
+
private setupRoot;
|
|
28
|
+
instanceExists(instanceName: string): boolean;
|
|
29
|
+
getComponent(instanceName: string): ClassComponent;
|
|
30
|
+
getUniqueInstanceName(className: string): string;
|
|
31
|
+
getUniqueNetName(): string;
|
|
32
|
+
getCurrentPoint(): ComponentPin;
|
|
33
|
+
private linkComponentPinNet;
|
|
34
|
+
private mergeNets;
|
|
35
|
+
createComponent(instanceName: string, pins: PinDefinition[], params: ParamDefinition[], props: {
|
|
36
|
+
arrange?: Map<string, number[]>;
|
|
37
|
+
display?: string;
|
|
38
|
+
type?: string;
|
|
39
|
+
width?: number;
|
|
40
|
+
}): ClassComponent;
|
|
41
|
+
printPoint(extra?: string): void;
|
|
42
|
+
addComponentExisting(component: ClassComponent, pin: number): ComponentPin;
|
|
43
|
+
toComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
44
|
+
addSequence?: boolean;
|
|
45
|
+
cloneNetComponent?: boolean;
|
|
46
|
+
}): ComponentPin;
|
|
47
|
+
atComponent(component: ClassComponent, pinId: number | null, options?: {
|
|
48
|
+
addSequence?: boolean;
|
|
49
|
+
cloneNetComponent?: boolean;
|
|
50
|
+
}): ComponentPin;
|
|
51
|
+
private isNetOnlyComponent;
|
|
52
|
+
private cloneComponent;
|
|
53
|
+
enterBlocks(blockType: BlockTypes): void;
|
|
54
|
+
exitBlocks(): void;
|
|
55
|
+
enterBlock(blockIndex: number): void;
|
|
56
|
+
exitBlock(blockIndex: number): void;
|
|
57
|
+
atPointBlock(): void;
|
|
58
|
+
toPointBlock(): void;
|
|
59
|
+
getPointBlockLocation(): [component: ClassComponent, pin: number, wireId: number];
|
|
60
|
+
breakBranch(): void;
|
|
61
|
+
createFunction(functionName: string, __runFunc: CFunction): void;
|
|
62
|
+
hasFunction(functionName: string): boolean;
|
|
63
|
+
getFunction(functionName: string): CFunction;
|
|
64
|
+
resolveVariable(executionStack: ExecutionContext[], idName: string): ReferenceType;
|
|
65
|
+
callFunction(functionName: string, functionParams: CallableParameter[], executionStack: ExecutionContext[], netNamespace: string): CFunctionResult;
|
|
66
|
+
mergeScope(childScope: ExecutionScope, namespace: string): void;
|
|
67
|
+
addWire(segments: [string, number?][]): void;
|
|
68
|
+
addPoint(pointId: string, userDefined?: boolean): ComponentPin;
|
|
69
|
+
setProperty(nameWithProp: string, value: any): void;
|
|
70
|
+
setCurrentComponentStyle(styles: {
|
|
71
|
+
[key: string]: number | string;
|
|
72
|
+
}): void;
|
|
73
|
+
enterFrame(): number;
|
|
74
|
+
exitFrame(frameId: number): void;
|
|
75
|
+
}
|
|
76
|
+
export declare function isNetComponent(component: ClassComponent): boolean;
|
|
77
|
+
export declare function isLabelComponent(component: ClassComponent): boolean;
|
|
78
|
+
export declare function getPortSide(pins: Map<number, PinDefinition>, arrangeProps: null | Map<string, number[]>): PortSideItem[];
|
|
79
|
+
type PortSideItem = {
|
|
80
|
+
pinId: number;
|
|
81
|
+
side: string;
|
|
82
|
+
order: number;
|
|
83
|
+
position: number;
|
|
84
|
+
};
|
|
85
|
+
export {};
|