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.
Files changed (39) hide show
  1. package/__tests__/testParse.ts +15 -0
  2. package/build/src/antlr/CircuitScriptLexer.d.ts +71 -0
  3. package/build/src/antlr/CircuitScriptParser.d.ts +674 -0
  4. package/build/src/antlr/CircuitScriptParser.js +142 -112
  5. package/build/src/antlr/CircuitScriptVisitor.d.ts +115 -0
  6. package/build/src/antlr/CircuitScriptVisitor.js +2 -0
  7. package/build/src/draw_symbols.d.ts +162 -0
  8. package/build/src/execute.d.ts +85 -0
  9. package/build/src/export.d.ts +2 -0
  10. package/build/src/fonts.d.ts +1 -0
  11. package/build/src/geometry.d.ts +84 -0
  12. package/build/src/globals.d.ts +50 -0
  13. package/build/src/helpers.d.ts +1 -0
  14. package/build/src/layout.d.ts +147 -0
  15. package/build/src/lexer.d.ts +19 -0
  16. package/build/src/logger.d.ts +6 -0
  17. package/build/src/main.d.ts +2 -0
  18. package/build/src/objects/ClassComponent.d.ts +40 -0
  19. package/build/src/objects/ExecutionScope.d.ts +64 -0
  20. package/build/src/objects/Frame.d.ts +15 -0
  21. package/build/src/objects/Net.d.ts +10 -0
  22. package/build/src/objects/ParamDefinition.d.ts +20 -0
  23. package/build/src/objects/PinDefinition.d.ts +24 -0
  24. package/build/src/objects/PinTypes.d.ts +7 -0
  25. package/build/src/objects/Wire.d.ts +11 -0
  26. package/build/src/objects/types.d.ts +49 -0
  27. package/build/src/regenerate-tests.d.ts +1 -0
  28. package/build/src/render.d.ts +10 -0
  29. package/build/src/server.d.ts +1 -0
  30. package/build/src/sizing.d.ts +13 -0
  31. package/build/src/utils.d.ts +19 -0
  32. package/build/src/visitor.d.ts +133 -0
  33. package/build/src/visitor.js +13 -4
  34. package/package.json +1 -1
  35. package/src/antlr/CircuitScript.g4 +3 -2
  36. package/src/antlr/CircuitScriptParser.ts +117 -87
  37. package/src/antlr/CircuitScriptVisitor.ts +16 -0
  38. package/src/visitor.ts +27 -11
  39. package/tsconfig.json +1 -0
@@ -223,6 +223,21 @@ R1.mpn = "res-12345"
223
223
  expect(item1.parameters.get('place')).toBe(false);
224
224
  expect(item1.parameters.get('mpn')).toBe('res-12345');
225
225
  });
226
+
227
+ test('unary minus operator', async () => {
228
+ const script = `
229
+ b = 20
230
+ print(b)
231
+ print(-b)
232
+ print(--b)
233
+ print(---b)
234
+ `;
235
+
236
+ const { hasError, visitor } = await runScript(script);
237
+ expect(hasError).toBe(false);
238
+
239
+ expect(visitor.printStream).toStrictEqual([20, -20, 20, -20]);
240
+ });
226
241
  });
227
242
 
228
243
  // This tests that an error is generated at the right position for
@@ -0,0 +1,71 @@
1
+ import { ATN, CharStream, Lexer, RuleContext } from "antlr4";
2
+ export default class CircuitScriptLexer extends Lexer {
3
+ static readonly T__0 = 1;
4
+ static readonly T__1 = 2;
5
+ static readonly T__2 = 3;
6
+ static readonly T__3 = 4;
7
+ static readonly T__4 = 5;
8
+ static readonly T__5 = 6;
9
+ static readonly T__6 = 7;
10
+ static readonly T__7 = 8;
11
+ static readonly Break = 9;
12
+ static readonly Branch = 10;
13
+ static readonly Create = 11;
14
+ static readonly Component = 12;
15
+ static readonly Graphic = 13;
16
+ static readonly Wire = 14;
17
+ static readonly Pin = 15;
18
+ static readonly Add = 16;
19
+ static readonly At = 17;
20
+ static readonly To = 18;
21
+ static readonly Point = 19;
22
+ static readonly Join = 20;
23
+ static readonly Parallel = 21;
24
+ static readonly Return = 22;
25
+ static readonly Define = 23;
26
+ static readonly Import = 24;
27
+ static readonly If = 25;
28
+ static readonly Not = 26;
29
+ static readonly Equals = 27;
30
+ static readonly NotEquals = 28;
31
+ static readonly Addition = 29;
32
+ static readonly Minus = 30;
33
+ static readonly Divide = 31;
34
+ static readonly Multiply = 32;
35
+ static readonly OPEN_PAREN = 33;
36
+ static readonly CLOSE_PAREN = 34;
37
+ static readonly NOT_CONNECTED = 35;
38
+ static readonly BOOLEAN_VALUE = 36;
39
+ static readonly ID = 37;
40
+ static readonly INTEGER_VALUE = 38;
41
+ static readonly DECIMAL_VALUE = 39;
42
+ static readonly NUMERIC_VALUE = 40;
43
+ static readonly STRING_VALUE = 41;
44
+ static readonly PERCENTAGE_VALUE = 42;
45
+ static readonly ALPHA_NUMERIC = 43;
46
+ static readonly WS = 44;
47
+ static readonly NEWLINE = 45;
48
+ static readonly SKIP_ = 46;
49
+ static readonly EOF: any;
50
+ static readonly channelNames: string[];
51
+ static readonly literalNames: (string | null)[];
52
+ static readonly symbolicNames: (string | null)[];
53
+ static readonly modeNames: string[];
54
+ static readonly ruleNames: string[];
55
+ constructor(input: CharStream);
56
+ get grammarFileName(): string;
57
+ get literalNames(): (string | null)[];
58
+ get symbolicNames(): (string | null)[];
59
+ get ruleNames(): string[];
60
+ get serializedATN(): number[];
61
+ get channelNames(): string[];
62
+ get modeNames(): string[];
63
+ action(localctx: RuleContext, ruleIndex: number, actionIndex: number): void;
64
+ private OPEN_PAREN_action;
65
+ private CLOSE_PAREN_action;
66
+ private NEWLINE_action;
67
+ static readonly _serializedATN: number[];
68
+ private static __ATN;
69
+ static get _ATN(): ATN;
70
+ static DecisionsToDFA: any;
71
+ }