circuitscript 0.5.2 → 0.5.3
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 +0 -59
- package/dist/cjs/semantic-tokens/SemanticTokenVisitor.js +2 -0
- package/dist/cjs/validate/SymbolValidatorVisitor.js +2 -0
- package/dist/esm/BaseVisitor.js +0 -59
- package/dist/esm/semantic-tokens/SemanticTokenVisitor.js +2 -0
- package/dist/esm/validate/SymbolValidatorVisitor.js +2 -0
- package/dist/types/BaseVisitor.d.ts +0 -2
- package/dist/types/semantic-tokens/SemanticTokenVisitor.d.ts +2 -1
- package/dist/types/validate/SymbolValidatorVisitor.d.ts +2 -1
- package/package.json +1 -1
package/dist/cjs/BaseVisitor.js
CHANGED
|
@@ -206,65 +206,6 @@ class BaseVisitor extends CircuitScriptParserVisitor_js_1.CircuitScriptParserVis
|
|
|
206
206
|
this.setResult(ctx, newValue);
|
|
207
207
|
}
|
|
208
208
|
};
|
|
209
|
-
this.visitTrailer_expr2 = (ctx) => {
|
|
210
|
-
const reference = this.getResult(ctx);
|
|
211
|
-
const ctxID = ctx.ID();
|
|
212
|
-
const ctxDataExpr = ctx.data_expr();
|
|
213
|
-
const useValue = reference.value;
|
|
214
|
-
let nextReference;
|
|
215
|
-
if (ctxID) {
|
|
216
|
-
reference.trailers.push(ctxID.getText());
|
|
217
|
-
const useRootValue = reference.rootValue ?? reference.value;
|
|
218
|
-
const useTrailerIndex = reference.trailerIndex ?? 0;
|
|
219
|
-
nextReference = this.getExecutor().resolveTrailers(reference.type, useRootValue, reference.trailers);
|
|
220
|
-
nextReference.name =
|
|
221
|
-
[reference.name,
|
|
222
|
-
...reference.trailers.slice(useTrailerIndex)].join('.');
|
|
223
|
-
}
|
|
224
|
-
else if (ctxDataExpr) {
|
|
225
|
-
const arrayIndex = this.visitResult(ctxDataExpr);
|
|
226
|
-
if (arrayIndex instanceof NumericValue_js_1.NumericValue) {
|
|
227
|
-
const arrayIndexValue = arrayIndex.toNumber();
|
|
228
|
-
const foundValue = useValue[arrayIndexValue];
|
|
229
|
-
const refType = foundValue instanceof ClassComponent_js_1.ClassComponent
|
|
230
|
-
? globals_js_1.ReferenceTypes.instance : globals_js_1.ReferenceTypes.variable;
|
|
231
|
-
nextReference = new types_js_1.AnyReference({
|
|
232
|
-
found: true,
|
|
233
|
-
type: refType,
|
|
234
|
-
value: foundValue,
|
|
235
|
-
trailers: [[globals_js_1.TrailerArrayIndex, arrayIndexValue]],
|
|
236
|
-
rootValue: useValue
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
this.setResult(ctx, nextReference);
|
|
241
|
-
};
|
|
242
|
-
this.visitAtom_expr = (ctx) => {
|
|
243
|
-
const executor = this.getExecutor();
|
|
244
|
-
const firstId = ctx.ID(0);
|
|
245
|
-
const atomId = firstId.getText();
|
|
246
|
-
let currentReference;
|
|
247
|
-
if (globals_js_1.PinTypesList.indexOf(atomId) !== -1) {
|
|
248
|
-
currentReference = new types_js_1.AnyReference({
|
|
249
|
-
found: true,
|
|
250
|
-
value: atomId,
|
|
251
|
-
type: globals_js_1.ReferenceTypes.pinType,
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
this.log('resolve variable ctx: ' + ctx.getText(), 'atomId', atomId);
|
|
256
|
-
currentReference = executor.resolveVariable(this.executionStack, atomId);
|
|
257
|
-
this.log('reference:', currentReference.name, 'found:', currentReference.found);
|
|
258
|
-
}
|
|
259
|
-
if (currentReference !== undefined && currentReference.found) {
|
|
260
|
-
ctx.trailer_expr2().forEach(ctxTrailer => {
|
|
261
|
-
this.setResult(ctxTrailer, currentReference);
|
|
262
|
-
currentReference = this.visitResult(ctxTrailer);
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
this.setResult(ctx, currentReference);
|
|
266
|
-
this.log2('atom resolved: ' + ctx.getText() + ' -> ' + currentReference);
|
|
267
|
-
};
|
|
268
209
|
this.visitValue_expr = (ctx) => {
|
|
269
210
|
const sign = ctx.Minus() ? -1 : 1;
|
|
270
211
|
const ctxIntegerValue = ctx.INTEGER_VALUE();
|
|
@@ -106,6 +106,8 @@ class SymbolValidatorVisitor extends BaseVisitor_js_1.BaseVisitor {
|
|
|
106
106
|
this.addSymbolVariable(ctxID.getSymbol(), ctxID.getText(), null);
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
|
+
this.visitTrailer = (ctx) => {
|
|
110
|
+
};
|
|
109
111
|
}
|
|
110
112
|
addSymbolVariable(token, name, value, executor = null) {
|
|
111
113
|
const useExecutor = executor === null ? this.getExecutor() : executor;
|
package/dist/esm/BaseVisitor.js
CHANGED
|
@@ -408,65 +408,6 @@ export class BaseVisitor extends CircuitScriptParserVisitor {
|
|
|
408
408
|
}
|
|
409
409
|
return reference;
|
|
410
410
|
}
|
|
411
|
-
visitTrailer_expr2 = (ctx) => {
|
|
412
|
-
const reference = this.getResult(ctx);
|
|
413
|
-
const ctxID = ctx.ID();
|
|
414
|
-
const ctxDataExpr = ctx.data_expr();
|
|
415
|
-
const useValue = reference.value;
|
|
416
|
-
let nextReference;
|
|
417
|
-
if (ctxID) {
|
|
418
|
-
reference.trailers.push(ctxID.getText());
|
|
419
|
-
const useRootValue = reference.rootValue ?? reference.value;
|
|
420
|
-
const useTrailerIndex = reference.trailerIndex ?? 0;
|
|
421
|
-
nextReference = this.getExecutor().resolveTrailers(reference.type, useRootValue, reference.trailers);
|
|
422
|
-
nextReference.name =
|
|
423
|
-
[reference.name,
|
|
424
|
-
...reference.trailers.slice(useTrailerIndex)].join('.');
|
|
425
|
-
}
|
|
426
|
-
else if (ctxDataExpr) {
|
|
427
|
-
const arrayIndex = this.visitResult(ctxDataExpr);
|
|
428
|
-
if (arrayIndex instanceof NumericValue) {
|
|
429
|
-
const arrayIndexValue = arrayIndex.toNumber();
|
|
430
|
-
const foundValue = useValue[arrayIndexValue];
|
|
431
|
-
const refType = foundValue instanceof ClassComponent
|
|
432
|
-
? ReferenceTypes.instance : ReferenceTypes.variable;
|
|
433
|
-
nextReference = new AnyReference({
|
|
434
|
-
found: true,
|
|
435
|
-
type: refType,
|
|
436
|
-
value: foundValue,
|
|
437
|
-
trailers: [[TrailerArrayIndex, arrayIndexValue]],
|
|
438
|
-
rootValue: useValue
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
}
|
|
442
|
-
this.setResult(ctx, nextReference);
|
|
443
|
-
};
|
|
444
|
-
visitAtom_expr = (ctx) => {
|
|
445
|
-
const executor = this.getExecutor();
|
|
446
|
-
const firstId = ctx.ID(0);
|
|
447
|
-
const atomId = firstId.getText();
|
|
448
|
-
let currentReference;
|
|
449
|
-
if (PinTypesList.indexOf(atomId) !== -1) {
|
|
450
|
-
currentReference = new AnyReference({
|
|
451
|
-
found: true,
|
|
452
|
-
value: atomId,
|
|
453
|
-
type: ReferenceTypes.pinType,
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
else {
|
|
457
|
-
this.log('resolve variable ctx: ' + ctx.getText(), 'atomId', atomId);
|
|
458
|
-
currentReference = executor.resolveVariable(this.executionStack, atomId);
|
|
459
|
-
this.log('reference:', currentReference.name, 'found:', currentReference.found);
|
|
460
|
-
}
|
|
461
|
-
if (currentReference !== undefined && currentReference.found) {
|
|
462
|
-
ctx.trailer_expr2().forEach(ctxTrailer => {
|
|
463
|
-
this.setResult(ctxTrailer, currentReference);
|
|
464
|
-
currentReference = this.visitResult(ctxTrailer);
|
|
465
|
-
});
|
|
466
|
-
}
|
|
467
|
-
this.setResult(ctx, currentReference);
|
|
468
|
-
this.log2('atom resolved: ' + ctx.getText() + ' -> ' + currentReference);
|
|
469
|
-
};
|
|
470
411
|
handleFunctionCall(currentReference, passedNetNamespace, ctx) {
|
|
471
412
|
const executor = this.getExecutor();
|
|
472
413
|
let parameters = [];
|
|
@@ -127,6 +127,8 @@ export class SemanticTokensVisitor extends BaseVisitor {
|
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
+
visitTrailer = (ctx) => {
|
|
131
|
+
};
|
|
130
132
|
addSemanticToken(node, modifiers, tokenType = null) {
|
|
131
133
|
const parsedToken = this.parseToken(node, modifiers, tokenType);
|
|
132
134
|
this.semanticTokens.set(`${parsedToken.line}_${parsedToken.column}_${parsedToken.length}`, parsedToken);
|
|
@@ -57,8 +57,6 @@ export declare class BaseVisitor extends CircuitScriptParserVisitor<ComplexType
|
|
|
57
57
|
visitAssignment_expr: (ctx: Assignment_exprContext) => void;
|
|
58
58
|
protected assignValueToReference(sequenceParts: (string | any)[], leftSideReference: AnyReference, lhsCtx: ParserRuleContext, rhsValue: any): void;
|
|
59
59
|
private getReference;
|
|
60
|
-
visitTrailer_expr2: (ctx: Trailer_expr2Context) => void;
|
|
61
|
-
visitAtom_expr: (ctx: Atom_exprContext) => void;
|
|
62
60
|
private handleFunctionCall;
|
|
63
61
|
protected handleEnterContext(executor: ExecutionContext, executionStack: ExecutionContext[], contextName: string, ctx: ParserRuleContext, options: NewContextOptions, funcDefinedParameters: FunctionDefinedParameter[], passedInParameters: CallableParameter[], isBreakContext?: boolean): ExecutionContext;
|
|
64
62
|
protected handlePopContext(executor: ExecutionContext, executionStack: ExecutionContext[], namespaceExtension: string, isBreakContext?: boolean): ExecutionContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TerminalNode, Token } from "antlr4ng";
|
|
2
2
|
import { CircuitScriptLexer } from "../antlr/CircuitScriptLexer.js";
|
|
3
|
-
import { Function_def_exprContext, Create_component_exprContext, Create_graphic_exprContext, Callable_exprContext, Property_key_exprContext, Assignment_exprContext, Function_args_exprContext, GraphicCommandExprContext, For_exprContext, Annotation_comment_exprContext, ScriptContext, CreateExprContext, Import_simpleContext, Import_specific_or_allContext } from "../antlr/CircuitScriptParser.js";
|
|
3
|
+
import { Function_def_exprContext, Create_component_exprContext, Create_graphic_exprContext, Callable_exprContext, Property_key_exprContext, Assignment_exprContext, Function_args_exprContext, GraphicCommandExprContext, For_exprContext, Annotation_comment_exprContext, ScriptContext, CreateExprContext, Import_simpleContext, Import_specific_or_allContext, TrailerContext } from "../antlr/CircuitScriptParser.js";
|
|
4
4
|
import { BaseVisitor, OnErrorHandler } from "../BaseVisitor.js";
|
|
5
5
|
import { NodeScriptEnvironment } from "../environment/environment.js";
|
|
6
6
|
export declare class SemanticTokensVisitor extends BaseVisitor {
|
|
@@ -23,6 +23,7 @@ export declare class SemanticTokensVisitor extends BaseVisitor {
|
|
|
23
23
|
visitImport_specific_or_all: (ctx: Import_specific_or_allContext) => void;
|
|
24
24
|
visitFor_expr: (ctx: For_exprContext) => void;
|
|
25
25
|
visitAnnotation_comment_expr: (ctx: Annotation_comment_exprContext) => void;
|
|
26
|
+
visitTrailer: (ctx: TrailerContext) => void;
|
|
26
27
|
addSemanticToken(node: TerminalNode, modifiers: string[], tokenType?: string | null): void;
|
|
27
28
|
parseToken(node: TerminalNode, modifiers: string[], tokenType?: string | null): IParsedToken;
|
|
28
29
|
dumpTokens(): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TerminalNode, Token } from "antlr4ng";
|
|
2
|
-
import { Assignment_exprContext, CallableExprContext, UnaryOperatorExprContext, MultiplyExprContext, AdditionExprContext, BinaryOperatorExprContext, Function_def_exprContext, For_exprContext, Import_simpleContext, Import_specific_or_allContext, Create_graphic_exprContext } from "../antlr/CircuitScriptParser.js";
|
|
2
|
+
import { Assignment_exprContext, CallableExprContext, UnaryOperatorExprContext, MultiplyExprContext, AdditionExprContext, BinaryOperatorExprContext, Function_def_exprContext, For_exprContext, Import_simpleContext, Import_specific_or_allContext, Create_graphic_exprContext, TrailerContext } from "../antlr/CircuitScriptParser.js";
|
|
3
3
|
import { ExecutionContext } from "../execute.js";
|
|
4
4
|
import { ComplexType, FunctionDefinedParameter } from "../objects/types.js";
|
|
5
5
|
import { SymbolTableItem } from "./SymbolTable.js";
|
|
@@ -28,6 +28,7 @@ export declare class SymbolValidatorVisitor extends BaseVisitor {
|
|
|
28
28
|
visitFunction_def_expr: (ctx: Function_def_exprContext) => void;
|
|
29
29
|
visitFor_expr: (ctx: For_exprContext) => void;
|
|
30
30
|
visitCreate_graphic_expr: (ctx: Create_graphic_exprContext) => void;
|
|
31
|
+
visitTrailer: (ctx: TrailerContext) => void;
|
|
31
32
|
getSymbols(): SymbolTable;
|
|
32
33
|
dumpSymbols(): void;
|
|
33
34
|
}
|