circuitscript 0.0.19 → 0.0.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "circuitscript",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "description": "Interpreter for the circuitscript language",
5
5
  "homepage": "https://circuitscript.net",
6
6
  "engines": {
@@ -106,8 +106,9 @@ property_set_expr: atom_expr '=' data_expr;
106
106
  double_dot_property_set_expr: '..' ID '=' data_expr;
107
107
 
108
108
  data_expr:
109
- (unary_operator? (value_expr | atom_expr)) #DataExpr
110
- | '(' data_expr ')' #RoundedBracketsExpr
109
+ '(' data_expr ')' #RoundedBracketsExpr
110
+ | (value_expr | atom_expr) #ValueAtomExpr
111
+ | unary_operator data_expr #UnaryOperatorExpr
111
112
  | data_expr (Multiply | Divide) data_expr #MultiplyExpr
112
113
  | data_expr (Addition | Minus) data_expr #AdditionExpr
113
114
  | data_expr binary_operator data_expr #BinaryOperatorExpr
@@ -1744,25 +1744,27 @@ export default class CircuitScriptParser extends Parser {
1744
1744
  {
1745
1745
  this.state = 329;
1746
1746
  this._errHandler.sync(this);
1747
- switch ( this._interp.adaptivePredict(this._input, 34, this._ctx) ) {
1747
+ switch ( this._interp.adaptivePredict(this._input, 33, this._ctx) ) {
1748
1748
  case 1:
1749
1749
  {
1750
- localctx = new DataExprContext(this, localctx);
1750
+ localctx = new RoundedBracketsExprContext(this, localctx);
1751
1751
  this._ctx = localctx;
1752
1752
  _prevctx = localctx;
1753
1753
 
1754
- {
1754
+ this.state = 316;
1755
+ this.match(CircuitScriptParser.OPEN_PAREN);
1755
1756
  this.state = 317;
1756
- this._errHandler.sync(this);
1757
- switch ( this._interp.adaptivePredict(this._input, 32, this._ctx) ) {
1758
- case 1:
1759
- {
1760
- this.state = 316;
1761
- this.unary_operator();
1762
- }
1763
- break;
1757
+ this.data_expr(0);
1758
+ this.state = 318;
1759
+ this.match(CircuitScriptParser.CLOSE_PAREN);
1764
1760
  }
1765
- this.state = 321;
1761
+ break;
1762
+ case 2:
1763
+ {
1764
+ localctx = new ValueAtomExprContext(this, localctx);
1765
+ this._ctx = localctx;
1766
+ _prevctx = localctx;
1767
+ this.state = 322;
1766
1768
  this._errHandler.sync(this);
1767
1769
  switch (this._input.LA(1)) {
1768
1770
  case 6:
@@ -1774,7 +1776,7 @@ export default class CircuitScriptParser extends Parser {
1774
1776
  case 41:
1775
1777
  case 42:
1776
1778
  {
1777
- this.state = 319;
1779
+ this.state = 320;
1778
1780
  this.value_expr();
1779
1781
  }
1780
1782
  break;
@@ -1782,7 +1784,7 @@ export default class CircuitScriptParser extends Parser {
1782
1784
  case 31:
1783
1785
  case 37:
1784
1786
  {
1785
- this.state = 320;
1787
+ this.state = 321;
1786
1788
  this.atom_expr();
1787
1789
  }
1788
1790
  break;
@@ -1790,22 +1792,19 @@ export default class CircuitScriptParser extends Parser {
1790
1792
  throw new NoViableAltException(this);
1791
1793
  }
1792
1794
  }
1793
- }
1794
1795
  break;
1795
- case 2:
1796
+ case 3:
1796
1797
  {
1797
- localctx = new RoundedBracketsExprContext(this, localctx);
1798
+ localctx = new UnaryOperatorExprContext(this, localctx);
1798
1799
  this._ctx = localctx;
1799
1800
  _prevctx = localctx;
1800
- this.state = 323;
1801
- this.match(CircuitScriptParser.OPEN_PAREN);
1802
1801
  this.state = 324;
1803
- this.data_expr(0);
1802
+ this.unary_operator();
1804
1803
  this.state = 325;
1805
- this.match(CircuitScriptParser.CLOSE_PAREN);
1804
+ this.data_expr(6);
1806
1805
  }
1807
1806
  break;
1808
- case 3:
1807
+ case 4:
1809
1808
  {
1810
1809
  localctx = new DataExprContext(this, localctx);
1811
1810
  this._ctx = localctx;
@@ -1814,7 +1813,7 @@ export default class CircuitScriptParser extends Parser {
1814
1813
  this.create_component_expr();
1815
1814
  }
1816
1815
  break;
1817
- case 4:
1816
+ case 5:
1818
1817
  {
1819
1818
  localctx = new DataExprContext(this, localctx);
1820
1819
  this._ctx = localctx;
@@ -1827,7 +1826,7 @@ export default class CircuitScriptParser extends Parser {
1827
1826
  this._ctx.stop = this._input.LT(-1);
1828
1827
  this.state = 343;
1829
1828
  this._errHandler.sync(this);
1830
- _alt = this._interp.adaptivePredict(this._input, 36, this._ctx);
1829
+ _alt = this._interp.adaptivePredict(this._input, 35, this._ctx);
1831
1830
  while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) {
1832
1831
  if (_alt === 1) {
1833
1832
  if (this._parseListeners != null) {
@@ -1837,7 +1836,7 @@ export default class CircuitScriptParser extends Parser {
1837
1836
  {
1838
1837
  this.state = 341;
1839
1838
  this._errHandler.sync(this);
1840
- switch ( this._interp.adaptivePredict(this._input, 35, this._ctx) ) {
1839
+ switch ( this._interp.adaptivePredict(this._input, 34, this._ctx) ) {
1841
1840
  case 1:
1842
1841
  {
1843
1842
  localctx = new MultiplyExprContext(this, new Data_exprContext(this, _parentctx, _parentState));
@@ -1899,7 +1898,7 @@ export default class CircuitScriptParser extends Parser {
1899
1898
  }
1900
1899
  this.state = 345;
1901
1900
  this._errHandler.sync(this);
1902
- _alt = this._interp.adaptivePredict(this._input, 36, this._ctx);
1901
+ _alt = this._interp.adaptivePredict(this._input, 35, this._ctx);
1903
1902
  }
1904
1903
  }
1905
1904
  }
@@ -2207,7 +2206,7 @@ export default class CircuitScriptParser extends Parser {
2207
2206
  let _alt: number;
2208
2207
  this.state = 408;
2209
2208
  this._errHandler.sync(this);
2210
- switch ( this._interp.adaptivePredict(this._input, 46, this._ctx) ) {
2209
+ switch ( this._interp.adaptivePredict(this._input, 45, this._ctx) ) {
2211
2210
  case 1:
2212
2211
  this.enterOuterAlt(localctx, 1);
2213
2212
  {
@@ -2215,7 +2214,7 @@ export default class CircuitScriptParser extends Parser {
2215
2214
  this.match(CircuitScriptParser.ID);
2216
2215
  this.state = 384;
2217
2216
  this._errHandler.sync(this);
2218
- _alt = this._interp.adaptivePredict(this._input, 43, this._ctx);
2217
+ _alt = this._interp.adaptivePredict(this._input, 42, this._ctx);
2219
2218
  while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) {
2220
2219
  if (_alt === 1) {
2221
2220
  {
@@ -2229,7 +2228,7 @@ export default class CircuitScriptParser extends Parser {
2229
2228
  }
2230
2229
  this.state = 386;
2231
2230
  this._errHandler.sync(this);
2232
- _alt = this._interp.adaptivePredict(this._input, 43, this._ctx);
2231
+ _alt = this._interp.adaptivePredict(this._input, 42, this._ctx);
2233
2232
  }
2234
2233
  this.state = 393;
2235
2234
  this._errHandler.sync(this);
@@ -2323,7 +2322,7 @@ export default class CircuitScriptParser extends Parser {
2323
2322
  this.match(CircuitScriptParser.ID);
2324
2323
  this.state = 417;
2325
2324
  this._errHandler.sync(this);
2326
- _alt = this._interp.adaptivePredict(this._input, 48, this._ctx);
2325
+ _alt = this._interp.adaptivePredict(this._input, 47, this._ctx);
2327
2326
  while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) {
2328
2327
  if (_alt === 1) {
2329
2328
  {
@@ -2335,7 +2334,7 @@ export default class CircuitScriptParser extends Parser {
2335
2334
  }
2336
2335
  this.state = 419;
2337
2336
  this._errHandler.sync(this);
2338
- _alt = this._interp.adaptivePredict(this._input, 48, this._ctx);
2337
+ _alt = this._interp.adaptivePredict(this._input, 47, this._ctx);
2339
2338
  }
2340
2339
  }
2341
2340
  }
@@ -2430,7 +2429,7 @@ export default class CircuitScriptParser extends Parser {
2430
2429
  this.match(CircuitScriptParser.Divide);
2431
2430
  this.state = 434;
2432
2431
  this._errHandler.sync(this);
2433
- switch ( this._interp.adaptivePredict(this._input, 52, this._ctx) ) {
2432
+ switch ( this._interp.adaptivePredict(this._input, 51, this._ctx) ) {
2434
2433
  case 1:
2435
2434
  {
2436
2435
  this.state = 433;
@@ -2633,7 +2632,7 @@ export default class CircuitScriptParser extends Parser {
2633
2632
  this.match(CircuitScriptParser.T__0);
2634
2633
  this.state = 472;
2635
2634
  this._errHandler.sync(this);
2636
- switch ( this._interp.adaptivePredict(this._input, 57, this._ctx) ) {
2635
+ switch ( this._interp.adaptivePredict(this._input, 56, this._ctx) ) {
2637
2636
  case 1:
2638
2637
  {
2639
2638
  this.state = 467;
@@ -2879,7 +2878,7 @@ export default class CircuitScriptParser extends Parser {
2879
2878
  this.match(CircuitScriptParser.ID);
2880
2879
  this.state = 508;
2881
2880
  this._errHandler.sync(this);
2882
- _alt = this._interp.adaptivePredict(this._input, 62, this._ctx);
2881
+ _alt = this._interp.adaptivePredict(this._input, 61, this._ctx);
2883
2882
  while (_alt !== 2 && _alt !== ATN.INVALID_ALT_NUMBER) {
2884
2883
  if (_alt === 1) {
2885
2884
  {
@@ -2898,7 +2897,7 @@ export default class CircuitScriptParser extends Parser {
2898
2897
  }
2899
2898
  this.state = 510;
2900
2899
  this._errHandler.sync(this);
2901
- _alt = this._interp.adaptivePredict(this._input, 62, this._ctx);
2900
+ _alt = this._interp.adaptivePredict(this._input, 61, this._ctx);
2902
2901
  }
2903
2902
  }
2904
2903
  }
@@ -3091,40 +3090,40 @@ export default class CircuitScriptParser extends Parser {
3091
3090
  1,24,1,24,1,24,5,24,285,8,24,10,24,12,24,288,9,24,1,24,1,24,5,24,292,8,
3092
3091
  24,10,24,12,24,295,9,24,1,24,1,24,1,24,5,24,300,8,24,10,24,12,24,303,9,
3093
3092
  24,3,24,305,8,24,1,25,1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,27,1,27,
3094
- 3,27,318,8,27,1,27,1,27,3,27,322,8,27,1,27,1,27,1,27,1,27,1,27,1,27,3,27,
3095
- 330,8,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,5,27,342,8,27,
3096
- 10,27,12,27,345,9,27,1,28,1,28,1,29,1,29,1,30,3,30,352,8,30,1,30,1,30,3,
3097
- 30,356,8,30,1,31,1,31,1,31,1,31,3,31,362,8,31,1,31,1,31,1,31,1,31,1,31,
3098
- 1,31,4,31,370,8,31,11,31,12,31,371,1,31,1,31,1,32,1,32,3,32,378,8,32,1,
3099
- 33,1,33,1,33,5,33,383,8,33,10,33,12,33,386,9,33,1,33,1,33,1,33,1,33,5,33,
3100
- 392,8,33,10,33,12,33,395,9,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,5,33,404,
3101
- 8,33,10,33,12,33,407,9,33,3,33,409,8,33,1,34,3,34,412,8,34,1,34,1,34,5,
3102
- 34,416,8,34,10,34,12,34,419,9,34,1,35,1,35,3,35,423,8,35,1,35,1,35,1,35,
3103
- 3,35,428,8,35,1,36,3,36,431,8,36,1,36,1,36,3,36,435,8,36,1,37,1,37,1,37,
3104
- 1,38,1,38,1,38,1,38,1,38,1,38,1,38,4,38,447,8,38,11,38,12,38,448,1,38,1,
3105
- 38,1,39,1,39,1,39,1,39,1,39,1,39,1,39,4,39,460,8,39,11,39,12,39,461,1,39,
3106
- 1,39,1,40,1,40,1,40,1,40,1,40,1,40,1,40,3,40,473,8,40,1,41,1,41,1,41,1,
3107
- 41,1,42,1,42,1,43,1,43,1,43,1,43,4,43,485,8,43,11,43,12,43,486,1,43,1,43,
3108
- 1,43,1,43,5,43,493,8,43,10,43,12,43,496,9,43,3,43,498,8,43,1,44,1,44,1,
3109
- 44,1,44,1,45,1,45,1,45,5,45,507,8,45,10,45,12,45,510,9,45,1,46,1,46,1,46,
3110
- 1,47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,48,4,48,524,8,48,11,48,12,48,
3111
- 525,1,48,1,48,1,48,0,1,54,49,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,
3112
- 32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,
3113
- 80,82,84,86,88,90,92,94,96,0,11,2,0,10,10,19,21,1,0,37,38,2,0,38,38,41,
3114
- 41,2,0,35,35,38,38,1,0,31,32,1,0,29,30,1,0,27,28,2,0,26,26,30,30,2,0,36,
3115
- 36,38,42,2,0,15,15,37,37,2,0,37,38,41,41,562,0,100,1,0,0,0,2,122,1,0,0,
3116
- 0,4,125,1,0,0,0,6,129,1,0,0,0,8,141,1,0,0,0,10,153,1,0,0,0,12,159,1,0,0,
3117
- 0,14,164,1,0,0,0,16,171,1,0,0,0,18,173,1,0,0,0,20,176,1,0,0,0,22,178,1,
3118
- 0,0,0,24,186,1,0,0,0,26,201,1,0,0,0,28,223,1,0,0,0,30,233,1,0,0,0,32,235,
3119
- 1,0,0,0,34,249,1,0,0,0,36,251,1,0,0,0,38,259,1,0,0,0,40,261,1,0,0,0,42,
3120
- 271,1,0,0,0,44,273,1,0,0,0,46,277,1,0,0,0,48,304,1,0,0,0,50,306,1,0,0,0,
3121
- 52,310,1,0,0,0,54,329,1,0,0,0,56,346,1,0,0,0,58,348,1,0,0,0,60,355,1,0,
3122
- 0,0,62,357,1,0,0,0,64,377,1,0,0,0,66,408,1,0,0,0,68,411,1,0,0,0,70,427,
3123
- 1,0,0,0,72,430,1,0,0,0,74,436,1,0,0,0,76,439,1,0,0,0,78,452,1,0,0,0,80,
3124
- 465,1,0,0,0,82,474,1,0,0,0,84,478,1,0,0,0,86,497,1,0,0,0,88,499,1,0,0,0,
3125
- 90,503,1,0,0,0,92,511,1,0,0,0,94,514,1,0,0,0,96,517,1,0,0,0,98,101,3,2,
3126
- 1,0,99,101,5,45,0,0,100,98,1,0,0,0,100,99,1,0,0,0,101,102,1,0,0,0,102,100,
3127
- 1,0,0,0,102,103,1,0,0,0,103,104,1,0,0,0,104,105,5,0,0,1,105,1,1,0,0,0,106,
3093
+ 1,27,1,27,1,27,1,27,1,27,3,27,323,8,27,1,27,1,27,1,27,1,27,1,27,3,27,330,
3094
+ 8,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,27,5,27,342,8,27,10,
3095
+ 27,12,27,345,9,27,1,28,1,28,1,29,1,29,1,30,3,30,352,8,30,1,30,1,30,3,30,
3096
+ 356,8,30,1,31,1,31,1,31,1,31,3,31,362,8,31,1,31,1,31,1,31,1,31,1,31,1,31,
3097
+ 4,31,370,8,31,11,31,12,31,371,1,31,1,31,1,32,1,32,3,32,378,8,32,1,33,1,
3098
+ 33,1,33,5,33,383,8,33,10,33,12,33,386,9,33,1,33,1,33,1,33,1,33,5,33,392,
3099
+ 8,33,10,33,12,33,395,9,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,5,33,404,8,
3100
+ 33,10,33,12,33,407,9,33,3,33,409,8,33,1,34,3,34,412,8,34,1,34,1,34,5,34,
3101
+ 416,8,34,10,34,12,34,419,9,34,1,35,1,35,3,35,423,8,35,1,35,1,35,1,35,3,
3102
+ 35,428,8,35,1,36,3,36,431,8,36,1,36,1,36,3,36,435,8,36,1,37,1,37,1,37,1,
3103
+ 38,1,38,1,38,1,38,1,38,1,38,1,38,4,38,447,8,38,11,38,12,38,448,1,38,1,38,
3104
+ 1,39,1,39,1,39,1,39,1,39,1,39,1,39,4,39,460,8,39,11,39,12,39,461,1,39,1,
3105
+ 39,1,40,1,40,1,40,1,40,1,40,1,40,1,40,3,40,473,8,40,1,41,1,41,1,41,1,41,
3106
+ 1,42,1,42,1,43,1,43,1,43,1,43,4,43,485,8,43,11,43,12,43,486,1,43,1,43,1,
3107
+ 43,1,43,5,43,493,8,43,10,43,12,43,496,9,43,3,43,498,8,43,1,44,1,44,1,44,
3108
+ 1,44,1,45,1,45,1,45,5,45,507,8,45,10,45,12,45,510,9,45,1,46,1,46,1,46,1,
3109
+ 47,1,47,1,47,1,48,1,48,1,48,1,48,1,48,1,48,4,48,524,8,48,11,48,12,48,525,
3110
+ 1,48,1,48,1,48,0,1,54,49,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,
3111
+ 34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,
3112
+ 82,84,86,88,90,92,94,96,0,11,2,0,10,10,19,21,1,0,37,38,2,0,38,38,41,41,
3113
+ 2,0,35,35,38,38,1,0,31,32,1,0,29,30,1,0,27,28,2,0,26,26,30,30,2,0,36,36,
3114
+ 38,42,2,0,15,15,37,37,2,0,37,38,41,41,562,0,100,1,0,0,0,2,122,1,0,0,0,4,
3115
+ 125,1,0,0,0,6,129,1,0,0,0,8,141,1,0,0,0,10,153,1,0,0,0,12,159,1,0,0,0,14,
3116
+ 164,1,0,0,0,16,171,1,0,0,0,18,173,1,0,0,0,20,176,1,0,0,0,22,178,1,0,0,0,
3117
+ 24,186,1,0,0,0,26,201,1,0,0,0,28,223,1,0,0,0,30,233,1,0,0,0,32,235,1,0,
3118
+ 0,0,34,249,1,0,0,0,36,251,1,0,0,0,38,259,1,0,0,0,40,261,1,0,0,0,42,271,
3119
+ 1,0,0,0,44,273,1,0,0,0,46,277,1,0,0,0,48,304,1,0,0,0,50,306,1,0,0,0,52,
3120
+ 310,1,0,0,0,54,329,1,0,0,0,56,346,1,0,0,0,58,348,1,0,0,0,60,355,1,0,0,0,
3121
+ 62,357,1,0,0,0,64,377,1,0,0,0,66,408,1,0,0,0,68,411,1,0,0,0,70,427,1,0,
3122
+ 0,0,72,430,1,0,0,0,74,436,1,0,0,0,76,439,1,0,0,0,78,452,1,0,0,0,80,465,
3123
+ 1,0,0,0,82,474,1,0,0,0,84,478,1,0,0,0,86,497,1,0,0,0,88,499,1,0,0,0,90,
3124
+ 503,1,0,0,0,92,511,1,0,0,0,94,514,1,0,0,0,96,517,1,0,0,0,98,101,3,2,1,0,
3125
+ 99,101,5,45,0,0,100,98,1,0,0,0,100,99,1,0,0,0,101,102,1,0,0,0,102,100,1,
3126
+ 0,0,0,102,103,1,0,0,0,103,104,1,0,0,0,104,105,5,0,0,1,105,1,1,0,0,0,106,
3128
3127
  123,3,14,7,0,107,123,3,24,12,0,108,123,3,22,11,0,109,123,3,44,22,0,110,
3129
3128
  123,3,50,25,0,111,123,3,8,4,0,112,123,3,52,26,0,113,123,3,42,21,0,114,123,
3130
3129
  3,62,31,0,115,123,3,90,45,0,116,123,3,94,47,0,117,123,3,96,48,0,118,123,
@@ -3182,11 +3181,11 @@ export default class CircuitScriptParser extends Parser {
3182
3181
  0,0,0,302,305,1,0,0,0,303,301,1,0,0,0,304,281,1,0,0,0,304,296,1,0,0,0,305,
3183
3182
  49,1,0,0,0,306,307,3,68,34,0,307,308,5,3,0,0,308,309,3,54,27,0,309,51,1,
3184
3183
  0,0,0,310,311,5,4,0,0,311,312,5,37,0,0,312,313,5,3,0,0,313,314,3,54,27,
3185
- 0,314,53,1,0,0,0,315,317,6,27,-1,0,316,318,3,58,29,0,317,316,1,0,0,0,317,
3186
- 318,1,0,0,0,318,321,1,0,0,0,319,322,3,60,30,0,320,322,3,68,34,0,321,319,
3187
- 1,0,0,0,321,320,1,0,0,0,322,330,1,0,0,0,323,324,5,33,0,0,324,325,3,54,27,
3188
- 0,325,326,5,34,0,0,326,330,1,0,0,0,327,330,3,76,38,0,328,330,3,78,39,0,
3189
- 329,315,1,0,0,0,329,323,1,0,0,0,329,327,1,0,0,0,329,328,1,0,0,0,330,343,
3184
+ 0,314,53,1,0,0,0,315,316,6,27,-1,0,316,317,5,33,0,0,317,318,3,54,27,0,318,
3185
+ 319,5,34,0,0,319,330,1,0,0,0,320,323,3,60,30,0,321,323,3,68,34,0,322,320,
3186
+ 1,0,0,0,322,321,1,0,0,0,323,330,1,0,0,0,324,325,3,58,29,0,325,326,3,54,
3187
+ 27,6,326,330,1,0,0,0,327,330,3,76,38,0,328,330,3,78,39,0,329,315,1,0,0,
3188
+ 0,329,322,1,0,0,0,329,324,1,0,0,0,329,327,1,0,0,0,329,328,1,0,0,0,330,343,
3190
3189
  1,0,0,0,331,332,10,5,0,0,332,333,7,4,0,0,333,342,3,54,27,6,334,335,10,4,
3191
3190
  0,0,335,336,7,5,0,0,336,342,3,54,27,5,337,338,10,3,0,0,338,339,3,56,28,
3192
3191
  0,339,340,3,54,27,4,340,342,1,0,0,0,341,331,1,0,0,0,341,334,1,0,0,0,341,
@@ -3239,10 +3238,10 @@ export default class CircuitScriptParser extends Parser {
3239
3238
  5,8,0,0,518,519,5,1,0,0,519,520,5,45,0,0,520,523,5,47,0,0,521,524,5,45,
3240
3239
  0,0,522,524,3,2,1,0,523,521,1,0,0,0,523,522,1,0,0,0,524,525,1,0,0,0,525,
3241
3240
  523,1,0,0,0,525,526,1,0,0,0,526,527,1,0,0,0,527,528,5,48,0,0,528,97,1,0,
3242
- 0,0,65,100,102,122,127,135,137,147,149,159,162,167,171,181,184,192,196,
3243
- 199,209,217,219,230,241,243,249,255,259,265,267,286,293,301,304,317,321,
3244
- 329,341,343,351,355,361,369,371,377,384,393,405,408,411,417,422,427,430,
3245
- 434,446,448,459,461,472,484,486,494,497,508,523,525];
3241
+ 0,0,64,100,102,122,127,135,137,147,149,159,162,167,171,181,184,192,196,
3242
+ 199,209,217,219,230,241,243,249,255,259,265,267,286,293,301,304,322,329,
3243
+ 341,343,351,355,361,369,371,377,384,393,405,408,411,417,422,427,430,434,
3244
+ 446,448,459,461,472,484,486,494,497,508,523,525];
3246
3245
 
3247
3246
  private static __ATN: ATN;
3248
3247
  public static get _ATN(): ATN {
@@ -4179,15 +4178,6 @@ export class DataExprContext extends Data_exprContext {
4179
4178
  super(parser, ctx.parentCtx, ctx.invokingState);
4180
4179
  super.copyFrom(ctx);
4181
4180
  }
4182
- public value_expr(): Value_exprContext {
4183
- return this.getTypedRuleContext(Value_exprContext, 0) as Value_exprContext;
4184
- }
4185
- public atom_expr(): Atom_exprContext {
4186
- return this.getTypedRuleContext(Atom_exprContext, 0) as Atom_exprContext;
4187
- }
4188
- public unary_operator(): Unary_operatorContext {
4189
- return this.getTypedRuleContext(Unary_operatorContext, 0) as Unary_operatorContext;
4190
- }
4191
4181
  public create_component_expr(): Create_component_exprContext {
4192
4182
  return this.getTypedRuleContext(Create_component_exprContext, 0) as Create_component_exprContext;
4193
4183
  }
@@ -4203,6 +4193,46 @@ export class DataExprContext extends Data_exprContext {
4203
4193
  }
4204
4194
  }
4205
4195
  }
4196
+ export class UnaryOperatorExprContext extends Data_exprContext {
4197
+ constructor(parser: CircuitScriptParser, ctx: Data_exprContext) {
4198
+ super(parser, ctx.parentCtx, ctx.invokingState);
4199
+ super.copyFrom(ctx);
4200
+ }
4201
+ public unary_operator(): Unary_operatorContext {
4202
+ return this.getTypedRuleContext(Unary_operatorContext, 0) as Unary_operatorContext;
4203
+ }
4204
+ public data_expr(): Data_exprContext {
4205
+ return this.getTypedRuleContext(Data_exprContext, 0) as Data_exprContext;
4206
+ }
4207
+ // @Override
4208
+ public accept<Result>(visitor: CircuitScriptVisitor<Result>): Result {
4209
+ if (visitor.visitUnaryOperatorExpr) {
4210
+ return visitor.visitUnaryOperatorExpr(this);
4211
+ } else {
4212
+ return visitor.visitChildren(this);
4213
+ }
4214
+ }
4215
+ }
4216
+ export class ValueAtomExprContext extends Data_exprContext {
4217
+ constructor(parser: CircuitScriptParser, ctx: Data_exprContext) {
4218
+ super(parser, ctx.parentCtx, ctx.invokingState);
4219
+ super.copyFrom(ctx);
4220
+ }
4221
+ public value_expr(): Value_exprContext {
4222
+ return this.getTypedRuleContext(Value_exprContext, 0) as Value_exprContext;
4223
+ }
4224
+ public atom_expr(): Atom_exprContext {
4225
+ return this.getTypedRuleContext(Atom_exprContext, 0) as Atom_exprContext;
4226
+ }
4227
+ // @Override
4228
+ public accept<Result>(visitor: CircuitScriptVisitor<Result>): Result {
4229
+ if (visitor.visitValueAtomExpr) {
4230
+ return visitor.visitValueAtomExpr(this);
4231
+ } else {
4232
+ return visitor.visitChildren(this);
4233
+ }
4234
+ }
4235
+ }
4206
4236
  export class BinaryOperatorExprContext extends Data_exprContext {
4207
4237
  constructor(parser: CircuitScriptParser, ctx: Data_exprContext) {
4208
4238
  super(parser, ctx.parentCtx, ctx.invokingState);
@@ -35,6 +35,8 @@ import { Double_dot_property_set_exprContext } from "./CircuitScriptParser";
35
35
  import { AdditionExprContext } from "./CircuitScriptParser";
36
36
  import { MultiplyExprContext } from "./CircuitScriptParser";
37
37
  import { DataExprContext } from "./CircuitScriptParser";
38
+ import { UnaryOperatorExprContext } from "./CircuitScriptParser";
39
+ import { ValueAtomExprContext } from "./CircuitScriptParser";
38
40
  import { BinaryOperatorExprContext } from "./CircuitScriptParser";
39
41
  import { RoundedBracketsExprContext } from "./CircuitScriptParser";
40
42
  import { Binary_operatorContext } from "./CircuitScriptParser";
@@ -252,6 +254,20 @@ export default class CircuitScriptVisitor<Result> extends ParseTreeVisitor<Resul
252
254
  * @return the visitor result
253
255
  */
254
256
  visitDataExpr?: (ctx: DataExprContext) => Result;
257
+ /**
258
+ * Visit a parse tree produced by the `UnaryOperatorExpr`
259
+ * labeled alternative in `CircuitScriptParser.data_expr`.
260
+ * @param ctx the parse tree
261
+ * @return the visitor result
262
+ */
263
+ visitUnaryOperatorExpr?: (ctx: UnaryOperatorExprContext) => Result;
264
+ /**
265
+ * Visit a parse tree produced by the `ValueAtomExpr`
266
+ * labeled alternative in `CircuitScriptParser.data_expr`.
267
+ * @param ctx the parse tree
268
+ * @return the visitor result
269
+ */
270
+ visitValueAtomExpr?: (ctx: ValueAtomExprContext) => Result;
255
271
  /**
256
272
  * Visit a parse tree produced by the `BinaryOperatorExpr`
257
273
  * labeled alternative in `CircuitScriptParser.data_expr`.
package/src/execute.ts CHANGED
@@ -1008,6 +1008,11 @@ export class ExecutionContext {
1008
1008
  }
1009
1009
 
1010
1010
  addWire(segments: [string, number?][]): void {
1011
+
1012
+ if (this.scope.currentComponent === null) {
1013
+ throw "No current component";
1014
+ }
1015
+
1011
1016
  const tmp = segments.map(item => {
1012
1017
  const [direction, value=null] = item;
1013
1018
  return {
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';
@@ -366,29 +368,39 @@ export class MainVisitor extends ParseTreeVisitor<any> {
366
368
 
367
369
  visitPath_blocks(ctx: Path_blocksContext): ComponentPin {
368
370
  const blocks = ctx.path_block_inner_list();
371
+
372
+ let blockIndex = 0; // Tracks the index of the block with the given type
369
373
  let blockType = BlockTypes.Branch;
374
+ let prevBlockType = null;
370
375
 
371
- if (blocks.length > 0){
372
- const firstBlock = blocks[0];
373
- if (firstBlock.Branch()){
376
+ blocks.forEach((block, index) => {
377
+ if (block.Branch()) {
374
378
  blockType = BlockTypes.Branch
375
- } else if (firstBlock.Join()){
379
+ } else if (block.Join()) {
376
380
  blockType = BlockTypes.Join;
377
- } else if (firstBlock.Parallel()){
381
+ } else if (block.Parallel()) {
378
382
  blockType = BlockTypes.Parallel;
379
- } else if (firstBlock.Point()){
383
+ } else if (block.Point()) {
380
384
  blockType = BlockTypes.Point;
381
385
  }
382
- }
383
386
 
384
- this.getExecutor().enterBlocks(blockType);
387
+ if (prevBlockType !== blockType) {
388
+ if (index > 0) {
389
+ // If not the first block, then exit the
390
+ // group of blocks.
391
+ this.getExecutor().exitBlocks();
392
+ }
385
393
 
386
- blocks.forEach((branch, index) => {
387
- this.getExecutor().enterBlock(index);
394
+ this.getExecutor().enterBlocks(blockType);
395
+ blockIndex = 0; // Reset counter.
396
+ }
388
397
 
389
- this.visit(branch);
398
+ this.getExecutor().enterBlock(blockIndex);
399
+ this.visit(block);
400
+ this.getExecutor().exitBlock(blockIndex);
401
+ blockIndex += 1;
390
402
 
391
- this.getExecutor().exitBlock(index);
403
+ prevBlockType = blockType;
392
404
  });
393
405
 
394
406
  this.getExecutor().exitBlocks();
@@ -566,8 +578,8 @@ export class MainVisitor extends ParseTreeVisitor<any> {
566
578
  return [component, pinValue];
567
579
  }
568
580
 
569
- visitDataExpr(ctx: DataExprContext): ComplexType {
570
- let value : ComplexType;
581
+ visitValueAtomExpr(ctx: ValueAtomExprContext): ComplexType {
582
+ let value: ComplexType;
571
583
 
572
584
  if (ctx.value_expr()) {
573
585
  value = this.visit(ctx.value_expr()) as ValueType;
@@ -575,7 +587,7 @@ export class MainVisitor extends ParseTreeVisitor<any> {
575
587
  } else if (ctx.atom_expr()) {
576
588
  const reference = this.visit(ctx.atom_expr());
577
589
 
578
- if (!reference.found){
590
+ if (!reference.found) {
579
591
  value = new UndeclaredReference(reference);
580
592
  } else {
581
593
  // This is the returned component from the function call
@@ -583,26 +595,39 @@ export class MainVisitor extends ParseTreeVisitor<any> {
583
595
  }
584
596
  }
585
597
 
586
- if (ctx.unary_operator()){
587
- if(ctx.unary_operator().Not()){
588
- if(typeof value === "boolean"){
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") {
589
608
  value = !value;
590
609
  } else {
591
610
  throw "Failed to do Not operator";
592
611
  }
593
- } else if (ctx.unary_operator().Minus()){
594
- if (typeof value === 'number'){
612
+ } else if (unaryOp.Minus()) {
613
+ if (typeof value === 'number') {
595
614
  return -value;
596
615
  } else {
597
616
  throw "Failed to do Negation operator";
598
617
  }
599
618
  }
600
619
  }
601
-
620
+
621
+ return value;
622
+ }
623
+
624
+ visitDataExpr(ctx: DataExprContext): ComplexType {
625
+ let value: ComplexType;
626
+
602
627
  if (ctx.create_component_expr()) {
603
628
  value = this.visit(ctx.create_component_expr()) as ClassComponent;
604
629
 
605
- } else if (ctx.create_graphic_expr()){
630
+ } else if (ctx.create_graphic_expr()) {
606
631
  value = this.visit(ctx.create_graphic_expr()) as ClassComponent;
607
632
  }
608
633
 
@@ -1076,7 +1101,8 @@ export class MainVisitor extends ParseTreeVisitor<any> {
1076
1101
  const propertyName = ctx.ID().getText();
1077
1102
  this.getExecutor().setProperty('..' + propertyName, result);
1078
1103
  }
1079
- visitRoundedBracketsExpr(ctx: RoundedBracketsExprContext){
1104
+
1105
+ visitRoundedBracketsExpr(ctx: RoundedBracketsExprContext) {
1080
1106
  return this.visit(ctx.data_expr());
1081
1107
  }
1082
1108