circuitscript 0.0.21 → 0.0.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.
Files changed (163) hide show
  1. package/dist/cjs/antlr/CircuitScriptLexer.js +288 -0
  2. package/dist/cjs/antlr/CircuitScriptParser.js +4905 -0
  3. package/dist/cjs/antlr/CircuitScriptVisitor.js +6 -0
  4. package/{src/draw_symbols.ts → dist/cjs/draw_symbols.js} +303 -614
  5. package/dist/cjs/execute.js +780 -0
  6. package/{src/export.ts → dist/cjs/export.js} +34 -56
  7. package/dist/cjs/fonts.js +4 -0
  8. package/dist/cjs/geometry.js +430 -0
  9. package/dist/cjs/globals.js +60 -0
  10. package/dist/cjs/helpers.js +99 -0
  11. package/dist/cjs/index.js +29 -0
  12. package/{src/layout.ts → dist/cjs/layout.js} +413 -1002
  13. package/dist/cjs/lexer.js +114 -0
  14. package/dist/cjs/logger.js +17 -0
  15. package/dist/cjs/main.js +87 -0
  16. package/dist/cjs/objects/ClassComponent.js +142 -0
  17. package/dist/cjs/objects/ExecutionScope.js +134 -0
  18. package/dist/cjs/objects/Frame.js +22 -0
  19. package/{src/objects/Net.ts → dist/cjs/objects/Net.js} +9 -24
  20. package/dist/cjs/objects/ParamDefinition.js +42 -0
  21. package/dist/cjs/objects/PinDefinition.js +31 -0
  22. package/dist/cjs/objects/PinTypes.js +11 -0
  23. package/dist/cjs/objects/Wire.js +9 -0
  24. package/dist/cjs/objects/types.js +9 -0
  25. package/dist/cjs/parser.js +299 -0
  26. package/dist/cjs/regenerate-tests.js +23 -0
  27. package/dist/cjs/render.js +155 -0
  28. package/{src/server.ts → dist/cjs/server.js} +15 -21
  29. package/dist/cjs/sizing.js +105 -0
  30. package/{src/utils.ts → dist/cjs/utils.js} +25 -35
  31. package/{src/visitor.ts → dist/cjs/visitor.js} +392 -948
  32. package/{build/src/antlr/CircuitScriptLexer.js → dist/esm/antlr/CircuitScriptLexer.mjs} +90 -91
  33. package/{build/src/antlr/CircuitScriptParser.js → dist/esm/antlr/CircuitScriptParser.mjs} +138 -136
  34. package/{build/src/draw_symbols.js → dist/esm/draw_symbols.mjs} +11 -11
  35. package/{build/src/execute.js → dist/esm/execute.mjs} +9 -8
  36. package/{build/src/export.js → dist/esm/export.mjs} +2 -2
  37. package/{build/src/geometry.js → dist/esm/geometry.mjs} +3 -7
  38. package/{build/src/helpers.js → dist/esm/helpers.mjs} +27 -7
  39. package/dist/esm/index.mjs +13 -0
  40. package/{build/src/layout.js → dist/esm/layout.mjs} +11 -11
  41. package/{build/src/lexer.js → dist/esm/lexer.mjs} +2 -2
  42. package/{build/src/main.js → dist/esm/main.mjs} +5 -5
  43. package/{build/src/objects/ClassComponent.js → dist/esm/objects/ClassComponent.mjs} +3 -3
  44. package/{build/src/objects/PinDefinition.js → dist/esm/objects/PinDefinition.mjs} +1 -1
  45. package/dist/esm/parser.mjs +269 -0
  46. package/{build/src/regenerate-tests.js → dist/esm/regenerate-tests.mjs} +1 -1
  47. package/{build/src/render.js → dist/esm/render.mjs} +7 -24
  48. package/{build/src/sizing.js → dist/esm/sizing.mjs} +22 -8
  49. package/{build/src/visitor.js → dist/esm/visitor.mjs} +10 -29
  50. package/dist/types/antlr/CircuitScriptLexer.d.ts +71 -0
  51. package/dist/types/antlr/CircuitScriptParser.d.ts +675 -0
  52. package/dist/types/antlr/CircuitScriptVisitor.d.ts +115 -0
  53. package/dist/types/draw_symbols.d.ts +162 -0
  54. package/dist/types/execute.d.ts +85 -0
  55. package/dist/types/export.d.ts +2 -0
  56. package/dist/types/fonts.d.ts +1 -0
  57. package/dist/types/geometry.d.ts +84 -0
  58. package/dist/types/globals.d.ts +50 -0
  59. package/dist/types/helpers.d.ts +9 -0
  60. package/dist/types/index.d.ts +13 -0
  61. package/dist/types/layout.d.ts +147 -0
  62. package/dist/types/lexer.d.ts +19 -0
  63. package/dist/types/logger.d.ts +6 -0
  64. package/dist/types/main.d.ts +2 -0
  65. package/dist/types/objects/ClassComponent.d.ts +40 -0
  66. package/dist/types/objects/ExecutionScope.d.ts +64 -0
  67. package/dist/types/objects/Frame.d.ts +15 -0
  68. package/dist/types/objects/Net.d.ts +10 -0
  69. package/dist/types/objects/ParamDefinition.d.ts +20 -0
  70. package/dist/types/objects/PinDefinition.d.ts +24 -0
  71. package/dist/types/objects/PinTypes.d.ts +7 -0
  72. package/dist/types/objects/Wire.d.ts +11 -0
  73. package/dist/types/objects/types.d.ts +49 -0
  74. package/dist/types/parser.d.ts +38 -0
  75. package/dist/types/regenerate-tests.d.ts +1 -0
  76. package/dist/types/render.d.ts +10 -0
  77. package/dist/types/server.d.ts +1 -0
  78. package/dist/types/sizing.d.ts +15 -0
  79. package/dist/types/utils.d.ts +19 -0
  80. package/dist/types/visitor.d.ts +135 -0
  81. package/package.json +30 -12
  82. package/.editorconfig +0 -15
  83. package/.eslintignore +0 -1
  84. package/.eslintrc.json +0 -27
  85. package/.gitlab-ci.yml +0 -81
  86. package/.prettierignore +0 -8
  87. package/.prettierrc +0 -16
  88. package/__tests__/expectedResults.ts +0 -657
  89. package/__tests__/helpers.ts +0 -82
  90. package/__tests__/parseScripts.ts +0 -593
  91. package/__tests__/renderData/script1.cst +0 -58
  92. package/__tests__/renderData/script1.cst.svg +0 -1
  93. package/__tests__/renderData/script2.cst +0 -16
  94. package/__tests__/renderData/script2.cst.svg +0 -1
  95. package/__tests__/renderData/script3.cst +0 -30
  96. package/__tests__/renderData/script3.cst.svg +0 -1
  97. package/__tests__/renderData/script4.cst +0 -54
  98. package/__tests__/renderData/script4.cst.svg +0 -1
  99. package/__tests__/renderData/script5.cst +0 -23
  100. package/__tests__/renderData/script5.cst.svg +0 -1
  101. package/__tests__/renderData/script6.cst +0 -28
  102. package/__tests__/renderData/script6.cst.svg +0 -1
  103. package/__tests__/renderData/script7.cst +0 -26
  104. package/__tests__/renderData/script7.cst.svg +0 -1
  105. package/__tests__/renderData/script8.cst +0 -37
  106. package/__tests__/renderData/script8.cst.svg +0 -1
  107. package/__tests__/testCLI.ts +0 -68
  108. package/__tests__/testMathOps.ts +0 -36
  109. package/__tests__/testMergeWires.ts +0 -141
  110. package/__tests__/testParse.ts +0 -263
  111. package/__tests__/testRender.ts +0 -38
  112. package/build/src/parser.js +0 -69
  113. package/documentation.md +0 -238
  114. package/examples/example_arduino_uno.cst +0 -1146
  115. package/examples/example_garden_pump.cst +0 -567
  116. package/examples/lib.cst +0 -185
  117. package/fonts/Inter-Bold.ttf +0 -0
  118. package/fonts/Inter-Regular.ttf +0 -0
  119. package/fonts/OpenSans-Regular.ttf +0 -0
  120. package/fonts/Roboto-Regular.ttf +0 -0
  121. package/jest.config.js +0 -23
  122. package/libs/lib.cst +0 -185
  123. package/refresh.html +0 -42
  124. package/server.cjs +0 -50
  125. package/src/antlr/CircuitScript.g4 +0 -209
  126. package/src/antlr/CircuitScriptLexer.ts +0 -317
  127. package/src/antlr/CircuitScriptParser.ts +0 -4979
  128. package/src/antlr/CircuitScriptVisitor.ts +0 -420
  129. package/src/execute.ts +0 -1227
  130. package/src/fonts.ts +0 -1
  131. package/src/geometry.ts +0 -638
  132. package/src/globals.ts +0 -67
  133. package/src/helpers.ts +0 -114
  134. package/src/lexer.ts +0 -151
  135. package/src/logger.ts +0 -17
  136. package/src/main.ts +0 -105
  137. package/src/objects/ClassComponent.ts +0 -223
  138. package/src/objects/ExecutionScope.ts +0 -201
  139. package/src/objects/Frame.ts +0 -20
  140. package/src/objects/ParamDefinition.ts +0 -49
  141. package/src/objects/PinDefinition.ts +0 -49
  142. package/src/objects/PinTypes.ts +0 -7
  143. package/src/objects/Wire.ts +0 -19
  144. package/src/objects/types.ts +0 -66
  145. package/src/parser.ts +0 -106
  146. package/src/regenerate-tests.ts +0 -25
  147. package/src/render.ts +0 -260
  148. package/src/sizing.ts +0 -96
  149. package/tsconfig.json +0 -26
  150. package/tsconfig.release.json +0 -8
  151. /package/{build/src/antlr/CircuitScriptVisitor.js → dist/esm/antlr/CircuitScriptVisitor.mjs} +0 -0
  152. /package/{build/src/fonts.js → dist/esm/fonts.mjs} +0 -0
  153. /package/{build/src/globals.js → dist/esm/globals.mjs} +0 -0
  154. /package/{build/src/logger.js → dist/esm/logger.mjs} +0 -0
  155. /package/{build/src/objects/ExecutionScope.js → dist/esm/objects/ExecutionScope.mjs} +0 -0
  156. /package/{build/src/objects/Frame.js → dist/esm/objects/Frame.mjs} +0 -0
  157. /package/{build/src/objects/Net.js → dist/esm/objects/Net.mjs} +0 -0
  158. /package/{build/src/objects/ParamDefinition.js → dist/esm/objects/ParamDefinition.mjs} +0 -0
  159. /package/{build/src/objects/PinTypes.js → dist/esm/objects/PinTypes.mjs} +0 -0
  160. /package/{build/src/objects/Wire.js → dist/esm/objects/Wire.mjs} +0 -0
  161. /package/{build/src/objects/types.js → dist/esm/objects/types.mjs} +0 -0
  162. /package/{build/src/server.js → dist/esm/server.mjs} +0 -0
  163. /package/{build/src/utils.js → dist/esm/utils.mjs} +0 -0
@@ -1,16 +1,16 @@
1
1
  import { ParseTreeVisitor } from 'antlr4';
2
2
  import { readFileSync } from 'fs';
3
3
  import { join } from 'path';
4
- import { ExecutionContext } from './execute.js';
5
- import { ClassComponent } from './objects/ClassComponent.js';
6
- import { NumericValue, ParamDefinition, PercentageValue, PinBlankValue, } from './objects/ParamDefinition.js';
7
- import { PinDefinition, PinIdType } from './objects/PinDefinition.js';
8
- import { PinTypes } from './objects/PinTypes.js';
9
- import { UndeclaredReference } from './objects/types.js';
10
- import { Logger } from './logger.js';
11
- import { BlockTypes, ComponentTypes, NoNetText } from './globals.js';
12
- import { SymbolDrawingCommands } from './draw_symbols.js';
13
- import { parseFileWithVisitor } from './parser.js';
4
+ import { ExecutionContext } from './execute.mjs';
5
+ import { ClassComponent } from './objects/ClassComponent.mjs';
6
+ import { NumericValue, ParamDefinition, PercentageValue, PinBlankValue, } from './objects/ParamDefinition.mjs';
7
+ import { PinDefinition, PinIdType } from './objects/PinDefinition.mjs';
8
+ import { PinTypes } from './objects/PinTypes.mjs';
9
+ import { UndeclaredReference } from './objects/types.mjs';
10
+ import { Logger } from './logger.mjs';
11
+ import { BlockTypes, ComponentTypes, NoNetText } from './globals.mjs';
12
+ import { SymbolDrawingCommands } from './draw_symbols.mjs';
13
+ import { parseFileWithVisitor } from './parser.mjs';
14
14
  export class MainVisitor extends ParseTreeVisitor {
15
15
  indentLevel = 0;
16
16
  startingContext;
@@ -1033,25 +1033,6 @@ export class MainVisitor extends ParseTreeVisitor {
1033
1033
  }
1034
1034
  return returnValue;
1035
1035
  }
1036
- checkNetNamespaceIncludes(targetNetName, targetNamespaceParts, net) {
1037
- if (net.name === targetNetName) {
1038
- const netNamespaceParts = this.getNamespaceParts(net.namespace);
1039
- this.print('check namespace', targetNetName, targetNamespaceParts, netNamespaceParts);
1040
- let matches = 0;
1041
- for (let i = 0; i < netNamespaceParts.length; i++) {
1042
- if (netNamespaceParts[i] === targetNamespaceParts[i]) {
1043
- matches++;
1044
- }
1045
- }
1046
- if (matches === netNamespaceParts.length) {
1047
- return true;
1048
- }
1049
- }
1050
- return false;
1051
- }
1052
- getNamespaceParts(namespace) {
1053
- return namespace.split(".").slice(0, -2);
1054
- }
1055
1036
  setupPrintFunction(context) {
1056
1037
  context.createFunction('print', (params) => {
1057
1038
  const items = params.map(([, , value]) => {
@@ -0,0 +1,71 @@
1
+ import { ATN, CharStream, DFA, 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 Break = 8;
11
+ static readonly Branch = 9;
12
+ static readonly Create = 10;
13
+ static readonly Component = 11;
14
+ static readonly Graphic = 12;
15
+ static readonly Wire = 13;
16
+ static readonly Pin = 14;
17
+ static readonly Add = 15;
18
+ static readonly At = 16;
19
+ static readonly To = 17;
20
+ static readonly Point = 18;
21
+ static readonly Join = 19;
22
+ static readonly Parallel = 20;
23
+ static readonly Return = 21;
24
+ static readonly Define = 22;
25
+ static readonly Import = 23;
26
+ static readonly If = 24;
27
+ static readonly Not = 25;
28
+ static readonly Frame = 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 COMMENT = 46;
49
+ static readonly EOF: number;
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: DFA[];
71
+ }