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
package/src/visitor.ts
CHANGED
|
@@ -47,6 +47,8 @@ import {
|
|
|
47
47
|
To_component_exprContext,
|
|
48
48
|
Value_exprContext,
|
|
49
49
|
Wire_exprContext,
|
|
50
|
+
ValueAtomExprContext,
|
|
51
|
+
UnaryOperatorExprContext,
|
|
50
52
|
} from './antlr/CircuitScriptParser.js';
|
|
51
53
|
import { ExecutionContext } from './execute.js';
|
|
52
54
|
import { ClassComponent } from './objects/ClassComponent.js';
|
|
@@ -576,8 +578,8 @@ export class MainVisitor extends ParseTreeVisitor<any> {
|
|
|
576
578
|
return [component, pinValue];
|
|
577
579
|
}
|
|
578
580
|
|
|
579
|
-
|
|
580
|
-
let value
|
|
581
|
+
visitValueAtomExpr(ctx: ValueAtomExprContext): ComplexType {
|
|
582
|
+
let value: ComplexType;
|
|
581
583
|
|
|
582
584
|
if (ctx.value_expr()) {
|
|
583
585
|
value = this.visit(ctx.value_expr()) as ValueType;
|
|
@@ -585,7 +587,7 @@ export class MainVisitor extends ParseTreeVisitor<any> {
|
|
|
585
587
|
} else if (ctx.atom_expr()) {
|
|
586
588
|
const reference = this.visit(ctx.atom_expr());
|
|
587
589
|
|
|
588
|
-
if (!reference.found){
|
|
590
|
+
if (!reference.found) {
|
|
589
591
|
value = new UndeclaredReference(reference);
|
|
590
592
|
} else {
|
|
591
593
|
// This is the returned component from the function call
|
|
@@ -593,26 +595,39 @@ export class MainVisitor extends ParseTreeVisitor<any> {
|
|
|
593
595
|
}
|
|
594
596
|
}
|
|
595
597
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
598
|
+
return value;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
visitUnaryOperatorExpr(ctx: UnaryOperatorExprContext): ComplexType {
|
|
602
|
+
const value = this.visit(ctx.data_expr());
|
|
603
|
+
|
|
604
|
+
const unaryOp = ctx.unary_operator();
|
|
605
|
+
if (unaryOp) {
|
|
606
|
+
if (unaryOp.Not()) {
|
|
607
|
+
if (typeof value === "boolean") {
|
|
599
608
|
value = !value;
|
|
600
609
|
} else {
|
|
601
610
|
throw "Failed to do Not operator";
|
|
602
611
|
}
|
|
603
|
-
} else if (
|
|
604
|
-
if (typeof value === 'number'){
|
|
612
|
+
} else if (unaryOp.Minus()) {
|
|
613
|
+
if (typeof value === 'number') {
|
|
605
614
|
return -value;
|
|
606
615
|
} else {
|
|
607
616
|
throw "Failed to do Negation operator";
|
|
608
617
|
}
|
|
609
618
|
}
|
|
610
619
|
}
|
|
611
|
-
|
|
620
|
+
|
|
621
|
+
return value;
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
visitDataExpr(ctx: DataExprContext): ComplexType {
|
|
625
|
+
let value: ComplexType;
|
|
626
|
+
|
|
612
627
|
if (ctx.create_component_expr()) {
|
|
613
628
|
value = this.visit(ctx.create_component_expr()) as ClassComponent;
|
|
614
629
|
|
|
615
|
-
} else if (ctx.create_graphic_expr()){
|
|
630
|
+
} else if (ctx.create_graphic_expr()) {
|
|
616
631
|
value = this.visit(ctx.create_graphic_expr()) as ClassComponent;
|
|
617
632
|
}
|
|
618
633
|
|
|
@@ -1086,7 +1101,8 @@ export class MainVisitor extends ParseTreeVisitor<any> {
|
|
|
1086
1101
|
const propertyName = ctx.ID().getText();
|
|
1087
1102
|
this.getExecutor().setProperty('..' + propertyName, result);
|
|
1088
1103
|
}
|
|
1089
|
-
|
|
1104
|
+
|
|
1105
|
+
visitRoundedBracketsExpr(ctx: RoundedBracketsExprContext) {
|
|
1090
1106
|
return this.visit(ctx.data_expr());
|
|
1091
1107
|
}
|
|
1092
1108
|
|