circuitscript 0.1.23 → 0.1.24
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 +35 -23
- package/dist/cjs/BomGeneration.js +167 -0
- package/dist/cjs/ComponentMatchConditions.js +116 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +247 -244
- package/dist/cjs/antlr/CircuitScriptParser.js +1476 -825
- package/dist/cjs/builtinMethods.js +6 -1
- package/dist/cjs/execute.js +27 -16
- package/dist/cjs/graph.js +10 -9
- package/dist/cjs/helpers.js +23 -4
- package/dist/cjs/layout.js +14 -13
- package/dist/cjs/main.js +17 -1
- package/dist/cjs/objects/ExecutionScope.js +3 -0
- package/dist/cjs/objects/PinDefinition.js +11 -1
- package/dist/cjs/objects/types.js +6 -4
- package/dist/cjs/rules-check/no-connect-on-connected-pin.js +81 -0
- package/dist/cjs/rules-check/rules.js +74 -0
- package/dist/cjs/rules-check/unconnected-pins.js +52 -0
- package/dist/cjs/visitor.js +121 -5
- package/dist/esm/BaseVisitor.js +35 -23
- package/dist/esm/BomGeneration.js +137 -0
- package/dist/esm/ComponentMatchConditions.js +109 -0
- package/dist/esm/antlr/CircuitScriptLexer.js +247 -244
- package/dist/esm/antlr/CircuitScriptParser.js +1471 -824
- package/dist/esm/antlr/CircuitScriptVisitor.js +7 -0
- package/dist/esm/builtinMethods.js +6 -1
- package/dist/esm/execute.js +27 -16
- package/dist/esm/graph.js +11 -10
- package/dist/esm/helpers.js +23 -4
- package/dist/esm/layout.js +15 -13
- package/dist/esm/main.js +17 -1
- package/dist/esm/objects/ExecutionScope.js +3 -0
- package/dist/esm/objects/PinDefinition.js +11 -1
- package/dist/esm/objects/types.js +7 -5
- package/dist/esm/rules-check/no-connect-on-connected-pin.js +77 -0
- package/dist/esm/rules-check/rules.js +70 -0
- package/dist/esm/rules-check/unconnected-pins.js +48 -0
- package/dist/esm/visitor.js +121 -5
- package/dist/libs/std.cst +7 -3
- package/dist/types/BomGeneration.d.ts +13 -0
- package/dist/types/ComponentMatchConditions.d.ts +19 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +60 -59
- package/dist/types/antlr/CircuitScriptParser.d.ts +146 -62
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +14 -0
- package/dist/types/execute.d.ts +2 -1
- package/dist/types/graph.d.ts +6 -1
- package/dist/types/helpers.d.ts +3 -0
- package/dist/types/layout.d.ts +3 -2
- package/dist/types/objects/ExecutionScope.d.ts +8 -2
- package/dist/types/objects/ParamDefinition.d.ts +1 -1
- package/dist/types/objects/PinDefinition.d.ts +1 -0
- package/dist/types/objects/types.d.ts +4 -2
- package/dist/types/rules-check/no-connect-on-connected-pin.d.ts +3 -0
- package/dist/types/rules-check/rules.d.ts +15 -0
- package/dist/types/rules-check/unconnected-pins.d.ts +2 -0
- package/dist/types/visitor.d.ts +10 -1
- package/libs/std.cst +7 -3
- package/package.json +2 -1
package/dist/types/helpers.d.ts
CHANGED
package/dist/types/layout.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Graph } from '@dagrejs/graphlib';
|
|
|
2
2
|
import { SymbolGraphic, SymbolText, SymbolDrawingCommands, SimplePoint } from "./draw_symbols.js";
|
|
3
3
|
import { ClassComponent } from "./objects/ClassComponent.js";
|
|
4
4
|
import { WireAutoDirection } from './globals.js';
|
|
5
|
-
import { WireSegment } from './objects/Wire.js';
|
|
5
|
+
import { Wire, WireSegment } from './objects/Wire.js';
|
|
6
6
|
import { Net } from './objects/Net.js';
|
|
7
7
|
import { Logger } from './logger.js';
|
|
8
8
|
import { Frame, FramePlotDirection } from './objects/Frame.js';
|
|
@@ -67,7 +67,8 @@ export declare class RenderWire extends RenderObject {
|
|
|
67
67
|
}[];
|
|
68
68
|
netName: string;
|
|
69
69
|
net: Net;
|
|
70
|
-
|
|
70
|
+
wire: Wire;
|
|
71
|
+
constructor(net: Net, x: NumericValue, y: NumericValue, segments: WireSegment[], wire: Wire);
|
|
71
72
|
refreshPoints(): void;
|
|
72
73
|
getAutoPoints(value: [x: NumericValue, y: NumericValue], direction: WireAutoDirection): [dx: number, dy: number][];
|
|
73
74
|
getWireEnd(): {
|
|
@@ -58,6 +58,7 @@ export declare class ExecutionScope {
|
|
|
58
58
|
setOnPropertyHandler(handler: OnPropertyHandler): void;
|
|
59
59
|
popOnPropertyHandler(): OnPropertyHandler;
|
|
60
60
|
triggerPropertyHandler(visitor: BaseVisitor, value: any, valueCtx: ParserRuleContext): void;
|
|
61
|
+
getInstances(): ClassComponent[];
|
|
61
62
|
}
|
|
62
63
|
export declare enum SequenceAction {
|
|
63
64
|
To = "to",
|
|
@@ -82,9 +83,14 @@ export type SequenceActionAtTo = [
|
|
|
82
83
|
LayoutDirection?,
|
|
83
84
|
string?
|
|
84
85
|
];
|
|
85
|
-
export type SequenceActionWire = [
|
|
86
|
+
export type SequenceActionWire = [
|
|
87
|
+
SequenceAction.Wire,
|
|
88
|
+
wireId: number,
|
|
89
|
+
WireSegment[],
|
|
90
|
+
wire: Wire
|
|
91
|
+
];
|
|
86
92
|
export type SequenceActionAssign = [SequenceAction.Assign, variable: string, ClassComponent];
|
|
87
|
-
export type SequenceItem = SequenceActionAtTo | SequenceActionWire | [SequenceAction.WireJump, wireId: number, pinId:
|
|
93
|
+
export type SequenceItem = SequenceActionAtTo | SequenceActionWire | [SequenceAction.WireJump, wireId: number, pinId: PinId, wire: Wire] | [SequenceAction.Frame, Frame, "enter" | "exit"] | SequenceActionAssign;
|
|
88
94
|
export type InnerBlockStackEntry = {
|
|
89
95
|
last_net: ComponentPinWireId | null;
|
|
90
96
|
ignore_last_net: boolean;
|
|
@@ -22,7 +22,7 @@ export declare class NumericValue {
|
|
|
22
22
|
neg(): NumericValue;
|
|
23
23
|
eq(value: NumericValue): boolean;
|
|
24
24
|
}
|
|
25
|
-
export declare function numeric(value: number): NumericValue;
|
|
25
|
+
export declare function numeric(value: number | string): NumericValue;
|
|
26
26
|
export declare class PercentageValue {
|
|
27
27
|
value: string | number;
|
|
28
28
|
constructor(value: string | number);
|
|
@@ -10,6 +10,7 @@ export declare class PinId {
|
|
|
10
10
|
isString(): boolean;
|
|
11
11
|
toString(): string;
|
|
12
12
|
equals(other: PinId | number | string): boolean;
|
|
13
|
+
getHashValue(): string;
|
|
13
14
|
static from(value: number | string | NumericValue): PinId;
|
|
14
15
|
static isPinIdType(value: number | string): boolean;
|
|
15
16
|
}
|
|
@@ -61,17 +61,19 @@ export declare class AnyReference {
|
|
|
61
61
|
found: boolean;
|
|
62
62
|
name?: string;
|
|
63
63
|
trailers: (string | ['index', number])[];
|
|
64
|
+
trailerIndex: number;
|
|
64
65
|
type: ReferenceTypes;
|
|
65
66
|
value?: any;
|
|
66
|
-
|
|
67
|
+
rootValue?: any;
|
|
67
68
|
referenceName: string;
|
|
68
69
|
constructor(refType: {
|
|
69
70
|
found: boolean;
|
|
70
71
|
name?: string;
|
|
71
72
|
trailers?: (string | ['index', number])[];
|
|
73
|
+
trailerIndex: number;
|
|
72
74
|
type?: ReferenceTypes;
|
|
73
75
|
value?: any;
|
|
74
|
-
|
|
76
|
+
rootValue?: any;
|
|
75
77
|
});
|
|
76
78
|
toString(): string;
|
|
77
79
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Graph } from "@dagrejs/graphlib";
|
|
2
|
+
import { ParserVisitor } from "src/visitor";
|
|
3
|
+
import { ComponentPinNetPair } from "src/objects/types";
|
|
4
|
+
import { Token } from "antlr4ng";
|
|
5
|
+
export declare enum ERC_Rules {
|
|
6
|
+
UnconnectedPin = "UNCONNECTED-PIN",
|
|
7
|
+
UnconnectedWire = "UNCONNECTED-WIRE",
|
|
8
|
+
NoConnectOnConnectedPin = "NO-CONNECT-ON-CONNECTED-PIN"
|
|
9
|
+
}
|
|
10
|
+
export type ERCReportItem = {
|
|
11
|
+
start: Token;
|
|
12
|
+
type: ERC_Rules;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
export declare function EvaluateERCRules(visitor: ParserVisitor, graph: Graph, nets: ComponentPinNetPair[]): ERCReportItem[];
|
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, 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, Annotation_comment_exprContext, At_block_headerContext } from './antlr/CircuitScriptParser.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, 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, Annotation_comment_exprContext, At_block_headerContext, Part_set_exprContext, Part_set_keyContext, Part_match_blockContext, Part_sub_exprContext, Part_value_exprContext, Part_condition_exprContext, Part_condition_key_only_exprContext } 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';
|
|
@@ -6,8 +6,10 @@ import { ExecutionWarning } from "./utils.js";
|
|
|
6
6
|
import { Net } from './objects/Net.js';
|
|
7
7
|
import { BaseVisitor } from './BaseVisitor.js';
|
|
8
8
|
import { ParserRuleContext } from 'antlr4ng';
|
|
9
|
+
import { Wire } from './objects/Wire.js';
|
|
9
10
|
export declare class ParserVisitor extends BaseVisitor {
|
|
10
11
|
componentCreationIndex: number;
|
|
12
|
+
creationCtx: Map<ClassComponent | Wire, ParserRuleContext>;
|
|
11
13
|
visitKeyword_assignment_expr: (ctx: Keyword_assignment_exprContext) => void;
|
|
12
14
|
visitPin_select_expr: (ctx: Pin_select_exprContext) => void;
|
|
13
15
|
trackNewComponentCreated: (callback: () => void) => boolean;
|
|
@@ -60,6 +62,13 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
60
62
|
visitWhile_expr: (ctx: While_exprContext) => void;
|
|
61
63
|
visitFor_expr: (ctx: For_exprContext) => void;
|
|
62
64
|
visitAnnotation_comment_expr: (ctx: Annotation_comment_exprContext) => void;
|
|
65
|
+
visitPart_set_expr: (ctx: Part_set_exprContext) => void;
|
|
66
|
+
visitPart_match_block: (ctx: Part_match_blockContext) => void;
|
|
67
|
+
visitPart_sub_expr: (ctx: Part_sub_exprContext) => void;
|
|
68
|
+
visitPart_set_key: (ctx: Part_set_keyContext) => void;
|
|
69
|
+
visitPart_value_expr: (ctx: Part_value_exprContext) => void;
|
|
70
|
+
visitPart_condition_expr: (ctx: Part_condition_exprContext) => void;
|
|
71
|
+
visitPart_condition_key_only_expr: (ctx: Part_condition_key_only_exprContext) => void;
|
|
63
72
|
private resolveDataExpr;
|
|
64
73
|
private resolveDataValue;
|
|
65
74
|
pinTypes: PinTypes[];
|
package/libs/std.cst
CHANGED
|
@@ -65,6 +65,7 @@ def res(value):
|
|
|
65
65
|
value: value
|
|
66
66
|
size: "0402"
|
|
67
67
|
footprint: "Resistor_SMD:R_0402_1005Metric"
|
|
68
|
+
description: "RES {value} OHM {size}"
|
|
68
69
|
|
|
69
70
|
def cap(value):
|
|
70
71
|
width = 120
|
|
@@ -146,9 +147,9 @@ def led(color):
|
|
|
146
147
|
params:
|
|
147
148
|
size: "0603"
|
|
148
149
|
color: color
|
|
150
|
+
value: color
|
|
149
151
|
footprint: "LED_SMD:LED_0603_1608Metric_Pad1.05x0.95mm_HandSolder"
|
|
150
|
-
|
|
151
|
-
|
|
152
|
+
description: "LED {color} {size}"
|
|
152
153
|
|
|
153
154
|
def cgnd():
|
|
154
155
|
net_name = "gnd"
|
|
@@ -224,6 +225,8 @@ def no_connect(size=20):
|
|
|
224
225
|
path: "M", -size, -size, "L", size, size
|
|
225
226
|
path: "M", -size, size, "L", size, -size
|
|
226
227
|
pin: 1, 0, 0, 0, 0, display_pin_id=false
|
|
228
|
+
params:
|
|
229
|
+
no_connect: true
|
|
227
230
|
|
|
228
231
|
def dnc(size=20):
|
|
229
232
|
return no_connect(size)
|
|
@@ -424,4 +427,5 @@ def sheet_A6(revision="V1"):
|
|
|
424
427
|
|
|
425
428
|
return tmp_sheet
|
|
426
429
|
|
|
427
|
-
document.sheet_type = sheet_A4()
|
|
430
|
+
document.sheet_type = sheet_A4()
|
|
431
|
+
document.bom.columns = ["refdes", "mpn", "manufacturer", "footprint"]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "circuitscript",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.24",
|
|
4
4
|
"description": "Interpreter for the circuitscript language",
|
|
5
5
|
"homepage": "https://circuitscript.net",
|
|
6
6
|
"engines": {
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"license": "MIT",
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@dagrejs/graphlib": "^2.2.4",
|
|
83
|
+
"@fast-csv/format": "^5.0.5",
|
|
83
84
|
"@flatten-js/core": "1.5.5",
|
|
84
85
|
"@svgdotjs/svg.js": "3.2.0",
|
|
85
86
|
"antlr4ng": "^3.0.4",
|