circuitscript 0.1.20 → 0.1.23
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 +22 -0
- package/dist/cjs/ComponentAnnotater.js +88 -0
- package/dist/cjs/RefdesAnnotationVisitor.js +197 -0
- package/dist/cjs/antlr/CircuitScriptLexer.js +202 -197
- package/dist/cjs/antlr/CircuitScriptParser.js +975 -833
- package/dist/cjs/environment.js +15 -1
- package/dist/cjs/execute.js +45 -2
- package/dist/cjs/helpers.js +20 -2
- package/dist/cjs/lexer.js +21 -9
- package/dist/cjs/main.js +13 -0
- package/dist/cjs/objects/ClassComponent.js +4 -1
- package/dist/cjs/objects/ExecutionScope.js +1 -0
- package/dist/cjs/parser.js +1 -0
- package/dist/cjs/visitor.js +122 -71
- package/dist/esm/BaseVisitor.js +22 -0
- package/dist/esm/ComponentAnnotater.js +84 -0
- package/dist/esm/RefdesAnnotationVisitor.js +196 -0
- package/dist/esm/antlr/CircuitScriptLexer.js +202 -197
- package/dist/esm/antlr/CircuitScriptParser.js +971 -831
- package/dist/esm/antlr/CircuitScriptVisitor.js +2 -0
- package/dist/esm/environment.js +15 -1
- package/dist/esm/execute.js +45 -2
- package/dist/esm/helpers.js +20 -2
- package/dist/esm/lexer.js +21 -9
- package/dist/esm/main.js +13 -0
- package/dist/esm/objects/ClassComponent.js +4 -1
- package/dist/esm/objects/ExecutionScope.js +1 -0
- package/dist/esm/parser.js +1 -0
- package/dist/esm/visitor.js +120 -69
- package/dist/types/BaseVisitor.d.ts +3 -0
- package/dist/types/ComponentAnnotater.d.ts +16 -0
- package/dist/types/RefdesAnnotationVisitor.d.ts +35 -0
- package/dist/types/antlr/CircuitScriptLexer.d.ts +15 -14
- package/dist/types/antlr/CircuitScriptParser.d.ts +81 -60
- package/dist/types/antlr/CircuitScriptVisitor.d.ts +4 -0
- package/dist/types/environment.d.ts +1 -0
- package/dist/types/execute.d.ts +8 -1
- package/dist/types/helpers.d.ts +4 -1
- package/dist/types/lexer.d.ts +1 -1
- package/dist/types/objects/ClassComponent.d.ts +9 -0
- package/dist/types/objects/ExecutionScope.d.ts +2 -1
- package/dist/types/objects/types.d.ts +1 -0
- package/dist/types/parser.d.ts +2 -1
- package/dist/types/visitor.d.ts +8 -1
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ParserRuleContext, CommonTokenStream } from 'antlr4ng';
|
|
2
|
+
import { Add_component_exprContext, At_block_headerContext, At_blockContext, At_component_exprContext, Component_select_exprContext, Frame_exprContext, Function_def_exprContext, Function_return_exprContext, ScriptContext, To_component_exprContext } from './antlr/CircuitScriptParser.js';
|
|
3
|
+
import { BaseVisitor } from './BaseVisitor.js';
|
|
4
|
+
import { ClassComponent } from './objects/ClassComponent.js';
|
|
5
|
+
export declare class RefdesAnnotationVisitor extends BaseVisitor {
|
|
6
|
+
private sourceText;
|
|
7
|
+
private tokenStream;
|
|
8
|
+
private modifications;
|
|
9
|
+
resultText: string;
|
|
10
|
+
debug: boolean;
|
|
11
|
+
componentCtxLinks: Map<ParserRuleContext, ClassComponent>;
|
|
12
|
+
constructor(silent: boolean, sourceText: string, tokenStream: CommonTokenStream, componentCtxLinks: Map<ParserRuleContext, ClassComponent>);
|
|
13
|
+
private getOriginalText;
|
|
14
|
+
visitScript: (ctx: ScriptContext) => Promise<void>;
|
|
15
|
+
visitAdd_component_expr: (ctx: Add_component_exprContext) => void;
|
|
16
|
+
visitAt_component_expr: (ctx: At_component_exprContext) => void;
|
|
17
|
+
visitComponent_select_expr: (ctx: Component_select_exprContext) => void;
|
|
18
|
+
visitAt_block_header: (ctx: At_block_headerContext) => void;
|
|
19
|
+
visitAt_block: (ctx: At_blockContext) => void;
|
|
20
|
+
visitTo_component_expr: (ctx: To_component_exprContext) => void;
|
|
21
|
+
visitFunction_def_expr: (ctx: Function_def_exprContext) => void;
|
|
22
|
+
visitFunction_return_expr: (ctx: Function_return_exprContext) => void;
|
|
23
|
+
visitFrame_expr: (ctx: Frame_exprContext) => void;
|
|
24
|
+
visitFunction_call_expr: (ctx: Function_call_exprContext) => void;
|
|
25
|
+
visitParameters: (ctx: ParametersContext) => void;
|
|
26
|
+
addedRefdesAnnotations: string[];
|
|
27
|
+
private generateRefdesAnnotationComment;
|
|
28
|
+
private addRefdesAnnotationComment;
|
|
29
|
+
getOutput(): string;
|
|
30
|
+
private generateModifiedText;
|
|
31
|
+
private buildContextTokenRanges;
|
|
32
|
+
private findContextForToken;
|
|
33
|
+
private markTokensAsProcessed;
|
|
34
|
+
private log;
|
|
35
|
+
}
|
|
@@ -51,20 +51,21 @@ export declare class CircuitScriptLexer extends antlr.Lexer {
|
|
|
51
51
|
static readonly DivideAssign = 49;
|
|
52
52
|
static readonly MultiplyAssign = 50;
|
|
53
53
|
static readonly ModulusAssign = 51;
|
|
54
|
-
static readonly
|
|
55
|
-
static readonly
|
|
56
|
-
static readonly
|
|
57
|
-
static readonly
|
|
58
|
-
static readonly
|
|
59
|
-
static readonly
|
|
60
|
-
static readonly
|
|
61
|
-
static readonly
|
|
62
|
-
static readonly
|
|
63
|
-
static readonly
|
|
64
|
-
static readonly
|
|
65
|
-
static readonly
|
|
66
|
-
static readonly
|
|
67
|
-
static readonly
|
|
54
|
+
static readonly ANNOTATION_START = 52;
|
|
55
|
+
static readonly OPEN_PAREN = 53;
|
|
56
|
+
static readonly CLOSE_PAREN = 54;
|
|
57
|
+
static readonly NOT_CONNECTED = 55;
|
|
58
|
+
static readonly BOOLEAN_VALUE = 56;
|
|
59
|
+
static readonly ID = 57;
|
|
60
|
+
static readonly INTEGER_VALUE = 58;
|
|
61
|
+
static readonly DECIMAL_VALUE = 59;
|
|
62
|
+
static readonly NUMERIC_VALUE = 60;
|
|
63
|
+
static readonly STRING_VALUE = 61;
|
|
64
|
+
static readonly PERCENTAGE_VALUE = 62;
|
|
65
|
+
static readonly ALPHA_NUMERIC = 63;
|
|
66
|
+
static readonly WS = 64;
|
|
67
|
+
static readonly NEWLINE = 65;
|
|
68
|
+
static readonly COMMENT = 66;
|
|
68
69
|
static readonly channelNames: string[];
|
|
69
70
|
static readonly literalNames: (string | null)[];
|
|
70
71
|
static readonly symbolicNames: (string | null)[];
|
|
@@ -53,22 +53,23 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
53
53
|
static readonly DivideAssign = 49;
|
|
54
54
|
static readonly MultiplyAssign = 50;
|
|
55
55
|
static readonly ModulusAssign = 51;
|
|
56
|
-
static readonly
|
|
57
|
-
static readonly
|
|
58
|
-
static readonly
|
|
59
|
-
static readonly
|
|
60
|
-
static readonly
|
|
61
|
-
static readonly
|
|
62
|
-
static readonly
|
|
63
|
-
static readonly
|
|
64
|
-
static readonly
|
|
65
|
-
static readonly
|
|
66
|
-
static readonly
|
|
67
|
-
static readonly
|
|
68
|
-
static readonly
|
|
69
|
-
static readonly
|
|
70
|
-
static readonly
|
|
71
|
-
static readonly
|
|
56
|
+
static readonly ANNOTATION_START = 52;
|
|
57
|
+
static readonly OPEN_PAREN = 53;
|
|
58
|
+
static readonly CLOSE_PAREN = 54;
|
|
59
|
+
static readonly NOT_CONNECTED = 55;
|
|
60
|
+
static readonly BOOLEAN_VALUE = 56;
|
|
61
|
+
static readonly ID = 57;
|
|
62
|
+
static readonly INTEGER_VALUE = 58;
|
|
63
|
+
static readonly DECIMAL_VALUE = 59;
|
|
64
|
+
static readonly NUMERIC_VALUE = 60;
|
|
65
|
+
static readonly STRING_VALUE = 61;
|
|
66
|
+
static readonly PERCENTAGE_VALUE = 62;
|
|
67
|
+
static readonly ALPHA_NUMERIC = 63;
|
|
68
|
+
static readonly WS = 64;
|
|
69
|
+
static readonly NEWLINE = 65;
|
|
70
|
+
static readonly COMMENT = 66;
|
|
71
|
+
static readonly INDENT = 67;
|
|
72
|
+
static readonly DEDENT = 68;
|
|
72
73
|
static readonly RULE_script = 0;
|
|
73
74
|
static readonly RULE_expression = 1;
|
|
74
75
|
static readonly RULE_flow_expressions = 2;
|
|
@@ -91,49 +92,51 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
91
92
|
static readonly RULE_at_to_multiple_line_expr_to_pin = 19;
|
|
92
93
|
static readonly RULE_at_block = 20;
|
|
93
94
|
static readonly RULE_at_block_expressions = 21;
|
|
94
|
-
static readonly
|
|
95
|
-
static readonly
|
|
96
|
-
static readonly
|
|
97
|
-
static readonly
|
|
98
|
-
static readonly
|
|
99
|
-
static readonly
|
|
100
|
-
static readonly
|
|
101
|
-
static readonly
|
|
102
|
-
static readonly
|
|
103
|
-
static readonly
|
|
104
|
-
static readonly
|
|
105
|
-
static readonly
|
|
106
|
-
static readonly
|
|
107
|
-
static readonly
|
|
108
|
-
static readonly
|
|
109
|
-
static readonly
|
|
110
|
-
static readonly
|
|
111
|
-
static readonly
|
|
112
|
-
static readonly
|
|
113
|
-
static readonly
|
|
114
|
-
static readonly
|
|
115
|
-
static readonly
|
|
116
|
-
static readonly
|
|
117
|
-
static readonly
|
|
118
|
-
static readonly
|
|
119
|
-
static readonly
|
|
120
|
-
static readonly
|
|
121
|
-
static readonly
|
|
122
|
-
static readonly
|
|
123
|
-
static readonly
|
|
124
|
-
static readonly
|
|
125
|
-
static readonly
|
|
126
|
-
static readonly
|
|
127
|
-
static readonly
|
|
128
|
-
static readonly
|
|
129
|
-
static readonly
|
|
130
|
-
static readonly
|
|
131
|
-
static readonly
|
|
132
|
-
static readonly
|
|
133
|
-
static readonly
|
|
134
|
-
static readonly
|
|
135
|
-
static readonly
|
|
136
|
-
static readonly
|
|
95
|
+
static readonly RULE_at_block_header = 22;
|
|
96
|
+
static readonly RULE_at_block_pin_expr = 23;
|
|
97
|
+
static readonly RULE_at_block_pin_expression_simple = 24;
|
|
98
|
+
static readonly RULE_at_block_pin_expression_complex = 25;
|
|
99
|
+
static readonly RULE_assignment_expr = 26;
|
|
100
|
+
static readonly RULE_operator_assignment_expr = 27;
|
|
101
|
+
static readonly RULE_keyword_assignment_expr = 28;
|
|
102
|
+
static readonly RULE_parameters = 29;
|
|
103
|
+
static readonly RULE_property_set_expr = 30;
|
|
104
|
+
static readonly RULE_double_dot_property_set_expr = 31;
|
|
105
|
+
static readonly RULE_data_expr = 32;
|
|
106
|
+
static readonly RULE_binary_operator = 33;
|
|
107
|
+
static readonly RULE_unary_operator = 34;
|
|
108
|
+
static readonly RULE_value_expr = 35;
|
|
109
|
+
static readonly RULE_function_def_expr = 36;
|
|
110
|
+
static readonly RULE_function_expr = 37;
|
|
111
|
+
static readonly RULE_function_args_expr = 38;
|
|
112
|
+
static readonly RULE_atom_expr = 39;
|
|
113
|
+
static readonly RULE_trailer_expr = 40;
|
|
114
|
+
static readonly RULE_trailer_expr2 = 41;
|
|
115
|
+
static readonly RULE_function_call_expr = 42;
|
|
116
|
+
static readonly RULE_net_namespace_expr = 43;
|
|
117
|
+
static readonly RULE_function_return_expr = 44;
|
|
118
|
+
static readonly RULE_property_block_expr = 45;
|
|
119
|
+
static readonly RULE_create_component_expr = 46;
|
|
120
|
+
static readonly RULE_graphic_expressions_block = 47;
|
|
121
|
+
static readonly RULE_create_graphic_expr = 48;
|
|
122
|
+
static readonly RULE_create_module_expr = 49;
|
|
123
|
+
static readonly RULE_nested_properties_inner = 50;
|
|
124
|
+
static readonly RULE_graphic_expr = 51;
|
|
125
|
+
static readonly RULE_property_expr = 52;
|
|
126
|
+
static readonly RULE_property_key_expr = 53;
|
|
127
|
+
static readonly RULE_property_value_expr = 54;
|
|
128
|
+
static readonly RULE_wire_atom_expr = 55;
|
|
129
|
+
static readonly RULE_wire_expr = 56;
|
|
130
|
+
static readonly RULE_array_expr = 57;
|
|
131
|
+
static readonly RULE_point_expr = 58;
|
|
132
|
+
static readonly RULE_import_expr = 59;
|
|
133
|
+
static readonly RULE_frame_expr = 60;
|
|
134
|
+
static readonly RULE_if_expr = 61;
|
|
135
|
+
static readonly RULE_if_inner_expr = 62;
|
|
136
|
+
static readonly RULE_else_expr = 63;
|
|
137
|
+
static readonly RULE_while_expr = 64;
|
|
138
|
+
static readonly RULE_for_expr = 65;
|
|
139
|
+
static readonly RULE_annotation_comment_expr = 66;
|
|
137
140
|
static readonly literalNames: (string | null)[];
|
|
138
141
|
static readonly symbolicNames: (string | null)[];
|
|
139
142
|
static readonly ruleNames: string[];
|
|
@@ -166,6 +169,7 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
166
169
|
at_to_multiple_line_expr_to_pin(): At_to_multiple_line_expr_to_pinContext;
|
|
167
170
|
at_block(): At_blockContext;
|
|
168
171
|
at_block_expressions(): At_block_expressionsContext;
|
|
172
|
+
at_block_header(): At_block_headerContext;
|
|
169
173
|
at_block_pin_expr(): At_block_pin_exprContext;
|
|
170
174
|
at_block_pin_expression_simple(): At_block_pin_expression_simpleContext;
|
|
171
175
|
at_block_pin_expression_complex(): At_block_pin_expression_complexContext;
|
|
@@ -210,6 +214,7 @@ export declare class CircuitScriptParser extends antlr.Parser {
|
|
|
210
214
|
else_expr(): Else_exprContext;
|
|
211
215
|
while_expr(): While_exprContext;
|
|
212
216
|
for_expr(): For_exprContext;
|
|
217
|
+
annotation_comment_expr(): Annotation_comment_exprContext;
|
|
213
218
|
sempred(localContext: antlr.ParserRuleContext | null, ruleIndex: number, predIndex: number): boolean;
|
|
214
219
|
private data_expr_sempred;
|
|
215
220
|
static readonly _serializedATN: number[];
|
|
@@ -245,6 +250,7 @@ export declare class ExpressionContext extends antlr.ParserRuleContext {
|
|
|
245
250
|
atom_expr(): Atom_exprContext | null;
|
|
246
251
|
frame_expr(): Frame_exprContext | null;
|
|
247
252
|
flow_expressions(): Flow_expressionsContext | null;
|
|
253
|
+
annotation_comment_expr(): Annotation_comment_exprContext | null;
|
|
248
254
|
get ruleIndex(): number;
|
|
249
255
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
250
256
|
}
|
|
@@ -411,7 +417,7 @@ export declare class At_to_multiple_line_expr_to_pinContext extends antlr.Parser
|
|
|
411
417
|
}
|
|
412
418
|
export declare class At_blockContext extends antlr.ParserRuleContext {
|
|
413
419
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
414
|
-
|
|
420
|
+
at_block_header(): At_block_headerContext;
|
|
415
421
|
NEWLINE(): antlr.TerminalNode[];
|
|
416
422
|
NEWLINE(i: number): antlr.TerminalNode | null;
|
|
417
423
|
INDENT(): antlr.TerminalNode;
|
|
@@ -428,6 +434,14 @@ export declare class At_block_expressionsContext extends antlr.ParserRuleContext
|
|
|
428
434
|
get ruleIndex(): number;
|
|
429
435
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
430
436
|
}
|
|
437
|
+
export declare class At_block_headerContext extends antlr.ParserRuleContext {
|
|
438
|
+
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
439
|
+
at_component_expr(): At_component_exprContext;
|
|
440
|
+
annotation_comment_expr(): Annotation_comment_exprContext[];
|
|
441
|
+
annotation_comment_expr(i: number): Annotation_comment_exprContext | null;
|
|
442
|
+
get ruleIndex(): number;
|
|
443
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
444
|
+
}
|
|
431
445
|
export declare class At_block_pin_exprContext extends antlr.ParserRuleContext {
|
|
432
446
|
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
433
447
|
pin_select_expr2(): Pin_select_expr2Context;
|
|
@@ -914,3 +928,10 @@ export declare class For_exprContext extends antlr.ParserRuleContext {
|
|
|
914
928
|
get ruleIndex(): number;
|
|
915
929
|
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
916
930
|
}
|
|
931
|
+
export declare class Annotation_comment_exprContext extends antlr.ParserRuleContext {
|
|
932
|
+
constructor(parent: antlr.ParserRuleContext | null, invokingState: number);
|
|
933
|
+
ANNOTATION_START(): antlr.TerminalNode;
|
|
934
|
+
ID(): antlr.TerminalNode;
|
|
935
|
+
get ruleIndex(): number;
|
|
936
|
+
accept<Result>(visitor: CircuitScriptVisitor<Result>): Result | null;
|
|
937
|
+
}
|
|
@@ -21,6 +21,7 @@ import { At_to_multiple_line_exprContext } from "./CircuitScriptParser.js";
|
|
|
21
21
|
import { At_to_multiple_line_expr_to_pinContext } from "./CircuitScriptParser.js";
|
|
22
22
|
import { At_blockContext } from "./CircuitScriptParser.js";
|
|
23
23
|
import { At_block_expressionsContext } from "./CircuitScriptParser.js";
|
|
24
|
+
import { At_block_headerContext } from "./CircuitScriptParser.js";
|
|
24
25
|
import { At_block_pin_exprContext } from "./CircuitScriptParser.js";
|
|
25
26
|
import { At_block_pin_expression_simpleContext } from "./CircuitScriptParser.js";
|
|
26
27
|
import { At_block_pin_expression_complexContext } from "./CircuitScriptParser.js";
|
|
@@ -77,6 +78,7 @@ import { If_inner_exprContext } from "./CircuitScriptParser.js";
|
|
|
77
78
|
import { Else_exprContext } from "./CircuitScriptParser.js";
|
|
78
79
|
import { While_exprContext } from "./CircuitScriptParser.js";
|
|
79
80
|
import { For_exprContext } from "./CircuitScriptParser.js";
|
|
81
|
+
import { Annotation_comment_exprContext } from "./CircuitScriptParser.js";
|
|
80
82
|
export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisitor<Result> {
|
|
81
83
|
visitScript?: (ctx: ScriptContext) => Result;
|
|
82
84
|
visitExpression?: (ctx: ExpressionContext) => Result;
|
|
@@ -100,6 +102,7 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
|
|
|
100
102
|
visitAt_to_multiple_line_expr_to_pin?: (ctx: At_to_multiple_line_expr_to_pinContext) => Result;
|
|
101
103
|
visitAt_block?: (ctx: At_blockContext) => Result;
|
|
102
104
|
visitAt_block_expressions?: (ctx: At_block_expressionsContext) => Result;
|
|
105
|
+
visitAt_block_header?: (ctx: At_block_headerContext) => Result;
|
|
103
106
|
visitAt_block_pin_expr?: (ctx: At_block_pin_exprContext) => Result;
|
|
104
107
|
visitAt_block_pin_expression_simple?: (ctx: At_block_pin_expression_simpleContext) => Result;
|
|
105
108
|
visitAt_block_pin_expression_complex?: (ctx: At_block_pin_expression_complexContext) => Result;
|
|
@@ -156,4 +159,5 @@ export declare class CircuitScriptVisitor<Result> extends AbstractParseTreeVisit
|
|
|
156
159
|
visitElse_expr?: (ctx: Else_exprContext) => Result;
|
|
157
160
|
visitWhile_expr?: (ctx: While_exprContext) => Result;
|
|
158
161
|
visitFor_expr?: (ctx: For_exprContext) => Result;
|
|
162
|
+
visitAnnotation_comment_expr?: (ctx: Annotation_comment_exprContext) => Result;
|
|
159
163
|
}
|
|
@@ -9,6 +9,7 @@ export declare class NodeScriptEnvironment {
|
|
|
9
9
|
protected useModuleDirectoryPath: string | null;
|
|
10
10
|
protected useDefaultLibsPath: string | null;
|
|
11
11
|
protected globalCreateSVGWindow: (() => SVGWindow) | null;
|
|
12
|
+
private cachedVersion;
|
|
12
13
|
protected supportedFonts: {
|
|
13
14
|
Arial: string;
|
|
14
15
|
};
|
package/dist/types/execute.d.ts
CHANGED
|
@@ -30,6 +30,10 @@ export declare class ExecutionContext {
|
|
|
30
30
|
parentContext: ExecutionContext;
|
|
31
31
|
componentAngleFollowsWire: boolean;
|
|
32
32
|
warnings: ExecutionWarning[];
|
|
33
|
+
indexedStack: Map<ParserRuleContext, {
|
|
34
|
+
index: number;
|
|
35
|
+
funcCallIndex: Map<ParserRuleContext, number>;
|
|
36
|
+
}>;
|
|
33
37
|
constructor(name: string, namespace: string, netNamespace: string, executionLevel: number | undefined, scopeLevel: number | undefined, silent: boolean | undefined, logger: Logger, warnings: ExecutionWarning[], parent: ExecutionContext);
|
|
34
38
|
logWarning(message: string, context?: ParserRuleContext, fileName?: string): void;
|
|
35
39
|
log(...params: any[]): void;
|
|
@@ -68,7 +72,10 @@ export declare class ExecutionContext {
|
|
|
68
72
|
atPointBlock(): void;
|
|
69
73
|
toPointBlock(): void;
|
|
70
74
|
getPointBlockLocation(): [component: ClassComponent, pin: number, wireId: number];
|
|
75
|
+
getParentBreakContext(): null | ParserRuleContext;
|
|
71
76
|
addBreakContext(ctx: ParserRuleContext): void;
|
|
77
|
+
setBreakContextIndex(index: number): void;
|
|
78
|
+
resetBreakContextFunctionCalls(): void;
|
|
72
79
|
popBreakContext(): ParserRuleContext;
|
|
73
80
|
getBreakContext(): ParserRuleContext;
|
|
74
81
|
createFunction(functionName: string, __runFunc: CFunction, source?: ParserRuleContext, uniqueId?: string): void;
|
|
@@ -77,7 +84,7 @@ export declare class ExecutionContext {
|
|
|
77
84
|
resolveVariable(executionStack: ExecutionContext[], idName: string, trailers?: string[]): AnyReference;
|
|
78
85
|
resolveTrailers(type: ReferenceTypes, item: any, trailers?: string[]): AnyReference;
|
|
79
86
|
callFunction(functionName: string, functionParams: CallableParameter[], executionStack: ExecutionContext[], netNamespace: string): CFunctionResult;
|
|
80
|
-
mergeScope(childScope: ExecutionScope, namespace: string):
|
|
87
|
+
mergeScope(childScope: ExecutionScope, namespace: string): ClassComponent[];
|
|
81
88
|
addWire(segments: [string, (number | UnitDimension)?][]): void;
|
|
82
89
|
addPoint(pointId: string, userDefined?: boolean): ComponentPin;
|
|
83
90
|
private getPointSymbol;
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -18,6 +18,9 @@ export type ScriptOptions = {
|
|
|
18
18
|
dumpData: boolean;
|
|
19
19
|
showStats: boolean;
|
|
20
20
|
environment: NodeScriptEnvironment;
|
|
21
|
+
inputPath?: string;
|
|
22
|
+
updateSource: boolean;
|
|
23
|
+
saveAnnotatedCopy: string | boolean;
|
|
21
24
|
};
|
|
22
25
|
export declare function prepareFile(textData: string): {
|
|
23
26
|
parser: CircuitScriptParser;
|
|
@@ -42,7 +45,7 @@ export declare function renderScriptCustom(scriptData: string, outputPath: strin
|
|
|
42
45
|
export declare abstract class ParseOutputHandler {
|
|
43
46
|
beforeRender: boolean;
|
|
44
47
|
afterRender: boolean;
|
|
45
|
-
abstract parse(visitor: ParserVisitor, outputPath: string | null, fileExtension: string | null): boolean;
|
|
48
|
+
abstract parse(visitor: ParserVisitor, outputPath: string | null, fileExtension: string | null, extra: any | null): boolean;
|
|
46
49
|
}
|
|
47
50
|
export declare class KiCadNetListOutputHandler extends ParseOutputHandler {
|
|
48
51
|
beforeRender: boolean;
|
package/dist/types/lexer.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class MainLexer extends CircuitScriptLexer {
|
|
|
10
10
|
nextToken(): Token;
|
|
11
11
|
createDedent(): Token;
|
|
12
12
|
getCharIndex(): number;
|
|
13
|
-
commonToken(type: number, text: string): Token;
|
|
13
|
+
commonToken(type: number, text: string, start?: number, stop?: number): Token;
|
|
14
14
|
getIndentationCount(whitespace: string): number;
|
|
15
15
|
atStartOfInput(): boolean;
|
|
16
16
|
openBrace(): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ParserRuleContext } from 'antlr4ng';
|
|
1
2
|
import { Expressions_blockContext } from 'src/antlr/CircuitScriptParser.js';
|
|
2
3
|
import { SymbolDrawingCommands } from '../draw_symbols.js';
|
|
3
4
|
import { Net } from './Net.js';
|
|
@@ -31,6 +32,9 @@ export declare class ClassComponent {
|
|
|
31
32
|
useWireOrientationAngle: boolean;
|
|
32
33
|
didSetWireOrientationAngle: boolean;
|
|
33
34
|
assignedRefDes: string | null;
|
|
35
|
+
placeHolderRefDes: string | null;
|
|
36
|
+
ctxReferences: CtxReference[];
|
|
37
|
+
_creationIndex: number;
|
|
34
38
|
constructor(instanceName: string, numPins: number);
|
|
35
39
|
setupPins(): void;
|
|
36
40
|
getDefaultPin(): PinId;
|
|
@@ -55,3 +59,8 @@ export declare class ModuleComponent extends ClassComponent {
|
|
|
55
59
|
moduleExecutionContextName?: string;
|
|
56
60
|
modulePinIdToPortMap?: Map<number, ClassComponent>;
|
|
57
61
|
}
|
|
62
|
+
export type CtxReference = {
|
|
63
|
+
ctx: ParserRuleContext;
|
|
64
|
+
indexedStack: [ParserRuleContext, number][];
|
|
65
|
+
creationFlag: boolean;
|
|
66
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ClassComponent } from './ClassComponent.js';
|
|
2
2
|
import { Net } from './Net.js';
|
|
3
|
-
import { CFunctionEntry, ComponentPinNet, ComponentPinNetPair, ComponentPinWireId, ParseSymbolType, ValueType } from './types.js';
|
|
3
|
+
import { CFunction, CFunctionEntry, ComponentPinNet, ComponentPinNetPair, ComponentPinWireId, ParseSymbolType, ValueType } from './types.js';
|
|
4
4
|
import { BlockTypes, LayoutDirection } from '../globals.js';
|
|
5
5
|
import { Wire, WireSegment } from './Wire.js';
|
|
6
6
|
import { Frame } from './Frame.js';
|
|
@@ -14,6 +14,7 @@ export declare class ExecutionScope {
|
|
|
14
14
|
private nets;
|
|
15
15
|
instances: Map<string, ClassComponent>;
|
|
16
16
|
functions: Map<string, CFunctionEntry>;
|
|
17
|
+
functionCounter: Map<CFunction, number>;
|
|
17
18
|
variables: Map<string, ValueType | ClassComponent>;
|
|
18
19
|
symbols: Map<string, {
|
|
19
20
|
type: ParseSymbolType;
|
package/dist/types/parser.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { CircuitScriptParser, ScriptContext } from './antlr/CircuitScriptParser.js';
|
|
2
|
-
import { ANTLRErrorListener, ATNConfigSet, ATNSimulator, BitSet, DFA, Parser, RecognitionException, Recognizer, Token } from 'antlr4ng';
|
|
2
|
+
import { ANTLRErrorListener, ATNConfigSet, ATNSimulator, BitSet, CommonTokenStream, DFA, Parser, RecognitionException, Recognizer, Token } from 'antlr4ng';
|
|
3
3
|
import { BaseVisitor, OnErrorHandler } from './BaseVisitor.js';
|
|
4
4
|
export declare function parseFileWithVisitor(visitor: BaseVisitor, data: string): Promise<{
|
|
5
5
|
tree: ScriptContext;
|
|
6
6
|
parser: CircuitScriptParser;
|
|
7
|
+
tokens: CommonTokenStream;
|
|
7
8
|
hasError: boolean;
|
|
8
9
|
hasParseError: boolean;
|
|
9
10
|
parserTimeTaken: number;
|
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 } 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 } 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';
|
|
@@ -7,8 +7,10 @@ import { Net } from './objects/Net.js';
|
|
|
7
7
|
import { BaseVisitor } from './BaseVisitor.js';
|
|
8
8
|
import { ParserRuleContext } from 'antlr4ng';
|
|
9
9
|
export declare class ParserVisitor extends BaseVisitor {
|
|
10
|
+
componentCreationIndex: number;
|
|
10
11
|
visitKeyword_assignment_expr: (ctx: Keyword_assignment_exprContext) => void;
|
|
11
12
|
visitPin_select_expr: (ctx: Pin_select_exprContext) => void;
|
|
13
|
+
trackNewComponentCreated: (callback: () => void) => boolean;
|
|
12
14
|
visitAdd_component_expr: (ctx: Add_component_exprContext) => void;
|
|
13
15
|
visitAt_component_expr: (ctx: At_component_exprContext) => ComponentPin;
|
|
14
16
|
visitTo_component_expr: (ctx: To_component_exprContext) => ComponentPin;
|
|
@@ -40,6 +42,7 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
40
42
|
visitFunction_def_expr: (ctx: Function_def_exprContext) => void;
|
|
41
43
|
visitPin_select_expr2: (ctx: Pin_select_expr2Context) => void;
|
|
42
44
|
visitAt_block_pin_expr: (ctx: At_block_pin_exprContext) => void;
|
|
45
|
+
visitAt_block_header: (ctx: At_block_headerContext) => void;
|
|
43
46
|
visitAt_block: (ctx: At_blockContext) => void;
|
|
44
47
|
visitAt_block_pin_expression_simple: (ctx: At_block_pin_expression_simpleContext) => void;
|
|
45
48
|
visitAt_block_pin_expression_complex: (ctx: At_block_pin_expression_complexContext) => void;
|
|
@@ -56,6 +59,7 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
56
59
|
visitIf_inner_expr: (ctx: If_inner_exprContext) => void;
|
|
57
60
|
visitWhile_expr: (ctx: While_exprContext) => void;
|
|
58
61
|
visitFor_expr: (ctx: For_exprContext) => void;
|
|
62
|
+
visitAnnotation_comment_expr: (ctx: Annotation_comment_exprContext) => void;
|
|
59
63
|
private resolveDataExpr;
|
|
60
64
|
private resolveDataValue;
|
|
61
65
|
pinTypes: PinTypes[];
|
|
@@ -88,6 +92,9 @@ export declare class ParserVisitor extends BaseVisitor {
|
|
|
88
92
|
private getPropertyExprList;
|
|
89
93
|
getWarnings(): ExecutionWarning[];
|
|
90
94
|
}
|
|
95
|
+
export declare const ComponentRefDesPrefixes: {
|
|
96
|
+
[key: string]: string;
|
|
97
|
+
};
|
|
91
98
|
export type NetListItem = {
|
|
92
99
|
instanceName: string;
|
|
93
100
|
instance: ClassComponent;
|