gobstones-code-runner 0.5.4 → 0.6.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a290d6bed637f71612bbc05a6589da4eaab2a7fb6143b32588c84098cf30da4
4
- data.tar.gz: 04e9c9e906cae088671fb7fd068ee298ee12c13ed484ba533140818b916f0a01
3
+ metadata.gz: dd4d6e14b4c9d319c5aac21edc4bbdc650ef33c7a3cc8e21d84e9289fb76945b
4
+ data.tar.gz: 2b0b1dbae7ea6ff8e1d072c2d7d3604f555fe728f3b26e9e0dfe6bebef6f8711
5
5
  SHA512:
6
- metadata.gz: a7ca3879de314f968567c3a1c2c8cf0de9e7b9c4af772f7a3137e2f79362689aa76b6fc2e339b4818388413eeda227e37519e377cfeaeca1a3239c35d8f09ba4
7
- data.tar.gz: d9d12116a96a6dc2d273f475b163a6401861ac45c458d74af23adfb79568523203a6e920bbebd03ae7e3ceb6ae7bc618c62d42c70db6e3146d710048ce3967e9
6
+ metadata.gz: d88527faa85751e22ec962217ffd9ac4ed314df55d4053532ee1ce619bd24a5f242896a9925d264fb61cf3c78cf489bf0810f8184026f4f0d3f31d5121822258
7
+ data.tar.gz: de88f8d3e46319c3af98bb97d2e8db4a0d20051a0f95ef6be858716aa2213a1655f1f7911cff89346eaf1df79001ec549922e35913306943faa2e366e1f577ab
@@ -4472,7 +4472,7 @@ var GbsRuntimeError = exports.GbsRuntimeError = function (_GbsInterpreterExcept3
4472
4472
  Object.defineProperty(exports, "__esModule", {
4473
4473
  value: true
4474
4474
  });
4475
- exports.ASTConstructorDeclaration = exports.ASTFieldBinding = exports.ASTExprFunctionCall = exports.ASTExprStructureUpdate = exports.ASTExprStructure = exports.ASTExprTuple = exports.ASTExprRange = exports.ASTExprList = exports.ASTExprChoose = exports.ASTExprConstantString = exports.ASTExprConstantNumber = exports.ASTExprVariable = exports.ASTPatternTimeout = exports.ASTPatternTuple = exports.ASTPatternStructure = exports.ASTPatternNumber = exports.ASTPatternVariable = exports.ASTPatternWildcard = exports.ASTStmtProcedureCall = exports.ASTStmtAssignTuple = exports.ASTStmtAssignVariable = exports.ASTSwitchBranch = exports.ASTStmtSwitch = exports.ASTStmtWhile = exports.ASTStmtForeach = exports.ASTStmtRepeat = exports.ASTStmtIf = exports.ASTStmtReturn = exports.ASTStmtBlock = exports.ASTDefType = exports.ASTDefFunction = exports.ASTDefProcedure = exports.ASTDefInteractiveProgram = exports.ASTDefProgram = exports.ASTMain = exports.ASTNode = exports.N_ConstructorDeclaration = exports.N_FieldBinding = exports.N_SwitchBranch = exports.N_ExprFunctionCall = exports.N_ExprStructureUpdate = exports.N_ExprStructure = exports.N_ExprTuple = exports.N_ExprRange = exports.N_ExprList = exports.N_ExprChoose = exports.N_ExprConstantString = exports.N_ExprConstantNumber = exports.N_ExprVariable = exports.N_PatternTimeout = exports.N_PatternTuple = exports.N_PatternStructure = exports.N_PatternNumber = exports.N_PatternVariable = exports.N_PatternWildcard = exports.N_StmtProcedureCall = exports.N_StmtAssignTuple = exports.N_StmtAssignVariable = exports.N_StmtSwitch = exports.N_StmtWhile = exports.N_StmtForeach = exports.N_StmtRepeat = exports.N_StmtIf = exports.N_StmtReturn = exports.N_StmtBlock = exports.N_DefType = exports.N_DefFunction = exports.N_DefProcedure = exports.N_DefInteractiveProgram = exports.N_DefProgram = exports.N_Main = undefined;
4475
+ exports.ASTConstructorDeclaration = exports.ASTFieldBinding = exports.ASTExprFunctionCall = exports.ASTExprStructureUpdate = exports.ASTExprStructure = exports.ASTExprTuple = exports.ASTExprRange = exports.ASTExprList = exports.ASTExprMatching = exports.ASTExprChoose = exports.ASTExprConstantString = exports.ASTExprConstantNumber = exports.ASTExprVariable = exports.ASTPatternTimeout = exports.ASTPatternTuple = exports.ASTPatternStructure = exports.ASTPatternNumber = exports.ASTPatternVariable = exports.ASTPatternWildcard = exports.ASTStmtProcedureCall = exports.ASTStmtAssignTuple = exports.ASTStmtAssignVariable = exports.ASTMatchingBranch = exports.ASTSwitchBranch = exports.ASTStmtSwitch = exports.ASTStmtWhile = exports.ASTStmtForeach = exports.ASTStmtRepeat = exports.ASTStmtIf = exports.ASTStmtReturn = exports.ASTStmtBlock = exports.ASTDefType = exports.ASTDefFunction = exports.ASTDefProcedure = exports.ASTDefInteractiveProgram = exports.ASTDefProgram = exports.ASTMain = exports.ASTNode = exports.N_ConstructorDeclaration = exports.N_FieldBinding = exports.N_MatchingBranch = exports.N_SwitchBranch = exports.N_ExprFunctionCall = exports.N_ExprStructureUpdate = exports.N_ExprStructure = exports.N_ExprTuple = exports.N_ExprRange = exports.N_ExprList = exports.N_ExprMatching = exports.N_ExprChoose = exports.N_ExprConstantString = exports.N_ExprConstantNumber = exports.N_ExprVariable = exports.N_PatternTimeout = exports.N_PatternTuple = exports.N_PatternStructure = exports.N_PatternNumber = exports.N_PatternVariable = exports.N_PatternWildcard = exports.N_StmtProcedureCall = exports.N_StmtAssignTuple = exports.N_StmtAssignVariable = exports.N_StmtSwitch = exports.N_StmtWhile = exports.N_StmtForeach = exports.N_StmtRepeat = exports.N_StmtIf = exports.N_StmtReturn = exports.N_StmtBlock = exports.N_DefType = exports.N_DefFunction = exports.N_DefProcedure = exports.N_DefInteractiveProgram = exports.N_DefProgram = exports.N_Main = undefined;
4476
4476
 
4477
4477
  var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
4478
4478
 
@@ -4516,6 +4516,7 @@ var N_ExprVariable = exports.N_ExprVariable = Symbol.for('N_ExprVariable');
4516
4516
  var N_ExprConstantNumber = exports.N_ExprConstantNumber = Symbol.for('N_ExprConstantNumber');
4517
4517
  var N_ExprConstantString = exports.N_ExprConstantString = Symbol.for('N_ExprConstantString');
4518
4518
  var N_ExprChoose = exports.N_ExprChoose = Symbol.for('N_ExprChoose');
4519
+ var N_ExprMatching = exports.N_ExprMatching = Symbol.for('N_ExprMatching');
4519
4520
  var N_ExprList = exports.N_ExprList = Symbol.for('N_ExprList');
4520
4521
  var N_ExprRange = exports.N_ExprRange = Symbol.for('N_ExprRange');
4521
4522
  var N_ExprTuple = exports.N_ExprTuple = Symbol.for('N_ExprTuple');
@@ -4524,6 +4525,8 @@ var N_ExprStructureUpdate = exports.N_ExprStructureUpdate = Symbol.for('N_ExprSt
4524
4525
  var N_ExprFunctionCall = exports.N_ExprFunctionCall = Symbol.for('N_ExprFunctionCall');
4525
4526
  /* SwitchBranch: pattern -> body */
4526
4527
  var N_SwitchBranch = exports.N_SwitchBranch = Symbol.for('N_SwitchBranch');
4528
+ /* MatchingBranch: pattern -> body */
4529
+ var N_MatchingBranch = exports.N_MatchingBranch = Symbol.for('N_MatchingBranch');
4527
4530
  /* FieldBinding: fieldName <- value */
4528
4531
  var N_FieldBinding = exports.N_FieldBinding = Symbol.for('N_FieldBinding');
4529
4532
  /* ConstructorDeclaration */
@@ -5032,8 +5035,32 @@ var ASTSwitchBranch = exports.ASTSwitchBranch = function (_ASTNode14) {
5032
5035
  return ASTSwitchBranch;
5033
5036
  }(ASTNode);
5034
5037
 
5035
- var ASTStmtAssignVariable = exports.ASTStmtAssignVariable = function (_ASTNode15) {
5036
- _inherits(ASTStmtAssignVariable, _ASTNode15);
5038
+ var ASTMatchingBranch = exports.ASTMatchingBranch = function (_ASTNode15) {
5039
+ _inherits(ASTMatchingBranch, _ASTNode15);
5040
+
5041
+ function ASTMatchingBranch(pattern, body) {
5042
+ _classCallCheck(this, ASTMatchingBranch);
5043
+
5044
+ return _possibleConstructorReturn(this, (ASTMatchingBranch.__proto__ || Object.getPrototypeOf(ASTMatchingBranch)).call(this, N_MatchingBranch, [pattern, body]));
5045
+ }
5046
+
5047
+ _createClass(ASTMatchingBranch, [{
5048
+ key: 'pattern',
5049
+ get: function get() {
5050
+ return this._children[0];
5051
+ }
5052
+ }, {
5053
+ key: 'body',
5054
+ get: function get() {
5055
+ return this._children[1];
5056
+ }
5057
+ }]);
5058
+
5059
+ return ASTMatchingBranch;
5060
+ }(ASTNode);
5061
+
5062
+ var ASTStmtAssignVariable = exports.ASTStmtAssignVariable = function (_ASTNode16) {
5063
+ _inherits(ASTStmtAssignVariable, _ASTNode16);
5037
5064
 
5038
5065
  function ASTStmtAssignVariable(variable, value) {
5039
5066
  _classCallCheck(this, ASTStmtAssignVariable);
@@ -5056,8 +5083,8 @@ var ASTStmtAssignVariable = exports.ASTStmtAssignVariable = function (_ASTNode15
5056
5083
  return ASTStmtAssignVariable;
5057
5084
  }(ASTNode);
5058
5085
 
5059
- var ASTStmtAssignTuple = exports.ASTStmtAssignTuple = function (_ASTNode16) {
5060
- _inherits(ASTStmtAssignTuple, _ASTNode16);
5086
+ var ASTStmtAssignTuple = exports.ASTStmtAssignTuple = function (_ASTNode17) {
5087
+ _inherits(ASTStmtAssignTuple, _ASTNode17);
5061
5088
 
5062
5089
  function ASTStmtAssignTuple(variables, value) {
5063
5090
  _classCallCheck(this, ASTStmtAssignTuple);
@@ -5080,8 +5107,8 @@ var ASTStmtAssignTuple = exports.ASTStmtAssignTuple = function (_ASTNode16) {
5080
5107
  return ASTStmtAssignTuple;
5081
5108
  }(ASTNode);
5082
5109
 
5083
- var ASTStmtProcedureCall = exports.ASTStmtProcedureCall = function (_ASTNode17) {
5084
- _inherits(ASTStmtProcedureCall, _ASTNode17);
5110
+ var ASTStmtProcedureCall = exports.ASTStmtProcedureCall = function (_ASTNode18) {
5111
+ _inherits(ASTStmtProcedureCall, _ASTNode18);
5085
5112
 
5086
5113
  function ASTStmtProcedureCall(procedureName, args) {
5087
5114
  _classCallCheck(this, ASTStmtProcedureCall);
@@ -5106,8 +5133,8 @@ var ASTStmtProcedureCall = exports.ASTStmtProcedureCall = function (_ASTNode17)
5106
5133
 
5107
5134
  /* Patterns */
5108
5135
 
5109
- var ASTPatternWildcard = exports.ASTPatternWildcard = function (_ASTNode18) {
5110
- _inherits(ASTPatternWildcard, _ASTNode18);
5136
+ var ASTPatternWildcard = exports.ASTPatternWildcard = function (_ASTNode19) {
5137
+ _inherits(ASTPatternWildcard, _ASTNode19);
5111
5138
 
5112
5139
  function ASTPatternWildcard() {
5113
5140
  _classCallCheck(this, ASTPatternWildcard);
@@ -5125,8 +5152,8 @@ var ASTPatternWildcard = exports.ASTPatternWildcard = function (_ASTNode18) {
5125
5152
  return ASTPatternWildcard;
5126
5153
  }(ASTNode);
5127
5154
 
5128
- var ASTPatternVariable = exports.ASTPatternVariable = function (_ASTNode19) {
5129
- _inherits(ASTPatternVariable, _ASTNode19);
5155
+ var ASTPatternVariable = exports.ASTPatternVariable = function (_ASTNode20) {
5156
+ _inherits(ASTPatternVariable, _ASTNode20);
5130
5157
 
5131
5158
  function ASTPatternVariable(variableName) {
5132
5159
  _classCallCheck(this, ASTPatternVariable);
@@ -5149,8 +5176,8 @@ var ASTPatternVariable = exports.ASTPatternVariable = function (_ASTNode19) {
5149
5176
  return ASTPatternVariable;
5150
5177
  }(ASTNode);
5151
5178
 
5152
- var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode20) {
5153
- _inherits(ASTPatternNumber, _ASTNode20);
5179
+ var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode21) {
5180
+ _inherits(ASTPatternNumber, _ASTNode21);
5154
5181
 
5155
5182
  function ASTPatternNumber(number) {
5156
5183
  _classCallCheck(this, ASTPatternNumber);
@@ -5173,8 +5200,8 @@ var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode20) {
5173
5200
  return ASTPatternNumber;
5174
5201
  }(ASTNode);
5175
5202
 
5176
- var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode21) {
5177
- _inherits(ASTPatternStructure, _ASTNode21);
5203
+ var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode22) {
5204
+ _inherits(ASTPatternStructure, _ASTNode22);
5178
5205
 
5179
5206
  function ASTPatternStructure(constructorName, parameters) {
5180
5207
  _classCallCheck(this, ASTPatternStructure);
@@ -5197,8 +5224,8 @@ var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode21) {
5197
5224
  return ASTPatternStructure;
5198
5225
  }(ASTNode);
5199
5226
 
5200
- var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode22) {
5201
- _inherits(ASTPatternTuple, _ASTNode22);
5227
+ var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode23) {
5228
+ _inherits(ASTPatternTuple, _ASTNode23);
5202
5229
 
5203
5230
  function ASTPatternTuple(parameters) {
5204
5231
  _classCallCheck(this, ASTPatternTuple);
@@ -5216,8 +5243,8 @@ var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode22) {
5216
5243
  return ASTPatternTuple;
5217
5244
  }(ASTNode);
5218
5245
 
5219
- var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode23) {
5220
- _inherits(ASTPatternTimeout, _ASTNode23);
5246
+ var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode24) {
5247
+ _inherits(ASTPatternTimeout, _ASTNode24);
5221
5248
 
5222
5249
  function ASTPatternTimeout(timeout) {
5223
5250
  _classCallCheck(this, ASTPatternTimeout);
@@ -5242,8 +5269,8 @@ var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode23) {
5242
5269
 
5243
5270
  /* Expressions */
5244
5271
 
5245
- var ASTExprVariable = exports.ASTExprVariable = function (_ASTNode24) {
5246
- _inherits(ASTExprVariable, _ASTNode24);
5272
+ var ASTExprVariable = exports.ASTExprVariable = function (_ASTNode25) {
5273
+ _inherits(ASTExprVariable, _ASTNode25);
5247
5274
 
5248
5275
  function ASTExprVariable(variableName) {
5249
5276
  _classCallCheck(this, ASTExprVariable);
@@ -5261,8 +5288,8 @@ var ASTExprVariable = exports.ASTExprVariable = function (_ASTNode24) {
5261
5288
  return ASTExprVariable;
5262
5289
  }(ASTNode);
5263
5290
 
5264
- var ASTExprConstantNumber = exports.ASTExprConstantNumber = function (_ASTNode25) {
5265
- _inherits(ASTExprConstantNumber, _ASTNode25);
5291
+ var ASTExprConstantNumber = exports.ASTExprConstantNumber = function (_ASTNode26) {
5292
+ _inherits(ASTExprConstantNumber, _ASTNode26);
5266
5293
 
5267
5294
  function ASTExprConstantNumber(number) {
5268
5295
  _classCallCheck(this, ASTExprConstantNumber);
@@ -5280,8 +5307,8 @@ var ASTExprConstantNumber = exports.ASTExprConstantNumber = function (_ASTNode25
5280
5307
  return ASTExprConstantNumber;
5281
5308
  }(ASTNode);
5282
5309
 
5283
- var ASTExprConstantString = exports.ASTExprConstantString = function (_ASTNode26) {
5284
- _inherits(ASTExprConstantString, _ASTNode26);
5310
+ var ASTExprConstantString = exports.ASTExprConstantString = function (_ASTNode27) {
5311
+ _inherits(ASTExprConstantString, _ASTNode27);
5285
5312
 
5286
5313
  function ASTExprConstantString(string) {
5287
5314
  _classCallCheck(this, ASTExprConstantString);
@@ -5299,8 +5326,8 @@ var ASTExprConstantString = exports.ASTExprConstantString = function (_ASTNode26
5299
5326
  return ASTExprConstantString;
5300
5327
  }(ASTNode);
5301
5328
 
5302
- var ASTExprChoose = exports.ASTExprChoose = function (_ASTNode27) {
5303
- _inherits(ASTExprChoose, _ASTNode27);
5329
+ var ASTExprChoose = exports.ASTExprChoose = function (_ASTNode28) {
5330
+ _inherits(ASTExprChoose, _ASTNode28);
5304
5331
 
5305
5332
  function ASTExprChoose(condition, trueExpr, falseExpr) {
5306
5333
  _classCallCheck(this, ASTExprChoose);
@@ -5328,8 +5355,32 @@ var ASTExprChoose = exports.ASTExprChoose = function (_ASTNode27) {
5328
5355
  return ASTExprChoose;
5329
5356
  }(ASTNode);
5330
5357
 
5331
- var ASTExprList = exports.ASTExprList = function (_ASTNode28) {
5332
- _inherits(ASTExprList, _ASTNode28);
5358
+ var ASTExprMatching = exports.ASTExprMatching = function (_ASTNode29) {
5359
+ _inherits(ASTExprMatching, _ASTNode29);
5360
+
5361
+ function ASTExprMatching(subject, branches) {
5362
+ _classCallCheck(this, ASTExprMatching);
5363
+
5364
+ return _possibleConstructorReturn(this, (ASTExprMatching.__proto__ || Object.getPrototypeOf(ASTExprMatching)).call(this, N_ExprMatching, [subject, branches]));
5365
+ }
5366
+
5367
+ _createClass(ASTExprMatching, [{
5368
+ key: 'subject',
5369
+ get: function get() {
5370
+ return this._children[0];
5371
+ }
5372
+ }, {
5373
+ key: 'branches',
5374
+ get: function get() {
5375
+ return this._children[1];
5376
+ }
5377
+ }]);
5378
+
5379
+ return ASTExprMatching;
5380
+ }(ASTNode);
5381
+
5382
+ var ASTExprList = exports.ASTExprList = function (_ASTNode30) {
5383
+ _inherits(ASTExprList, _ASTNode30);
5333
5384
 
5334
5385
  function ASTExprList(elements) {
5335
5386
  _classCallCheck(this, ASTExprList);
@@ -5347,8 +5398,8 @@ var ASTExprList = exports.ASTExprList = function (_ASTNode28) {
5347
5398
  return ASTExprList;
5348
5399
  }(ASTNode);
5349
5400
 
5350
- var ASTExprRange = exports.ASTExprRange = function (_ASTNode29) {
5351
- _inherits(ASTExprRange, _ASTNode29);
5401
+ var ASTExprRange = exports.ASTExprRange = function (_ASTNode31) {
5402
+ _inherits(ASTExprRange, _ASTNode31);
5352
5403
 
5353
5404
  // Note: second may be null
5354
5405
  function ASTExprRange(first, second, last) {
@@ -5377,8 +5428,8 @@ var ASTExprRange = exports.ASTExprRange = function (_ASTNode29) {
5377
5428
  return ASTExprRange;
5378
5429
  }(ASTNode);
5379
5430
 
5380
- var ASTExprTuple = exports.ASTExprTuple = function (_ASTNode30) {
5381
- _inherits(ASTExprTuple, _ASTNode30);
5431
+ var ASTExprTuple = exports.ASTExprTuple = function (_ASTNode32) {
5432
+ _inherits(ASTExprTuple, _ASTNode32);
5382
5433
 
5383
5434
  function ASTExprTuple(elements) {
5384
5435
  _classCallCheck(this, ASTExprTuple);
@@ -5396,8 +5447,8 @@ var ASTExprTuple = exports.ASTExprTuple = function (_ASTNode30) {
5396
5447
  return ASTExprTuple;
5397
5448
  }(ASTNode);
5398
5449
 
5399
- var ASTExprStructure = exports.ASTExprStructure = function (_ASTNode31) {
5400
- _inherits(ASTExprStructure, _ASTNode31);
5450
+ var ASTExprStructure = exports.ASTExprStructure = function (_ASTNode33) {
5451
+ _inherits(ASTExprStructure, _ASTNode33);
5401
5452
 
5402
5453
  function ASTExprStructure(constructorName, fieldBindings) {
5403
5454
  _classCallCheck(this, ASTExprStructure);
@@ -5451,8 +5502,8 @@ var ASTExprStructure = exports.ASTExprStructure = function (_ASTNode31) {
5451
5502
  return ASTExprStructure;
5452
5503
  }(ASTNode);
5453
5504
 
5454
- var ASTExprStructureUpdate = exports.ASTExprStructureUpdate = function (_ASTNode32) {
5455
- _inherits(ASTExprStructureUpdate, _ASTNode32);
5505
+ var ASTExprStructureUpdate = exports.ASTExprStructureUpdate = function (_ASTNode34) {
5506
+ _inherits(ASTExprStructureUpdate, _ASTNode34);
5456
5507
 
5457
5508
  function ASTExprStructureUpdate(constructorName, original, fieldBindings) {
5458
5509
  _classCallCheck(this, ASTExprStructureUpdate);
@@ -5511,8 +5562,8 @@ var ASTExprStructureUpdate = exports.ASTExprStructureUpdate = function (_ASTNode
5511
5562
  return ASTExprStructureUpdate;
5512
5563
  }(ASTNode);
5513
5564
 
5514
- var ASTExprFunctionCall = exports.ASTExprFunctionCall = function (_ASTNode33) {
5515
- _inherits(ASTExprFunctionCall, _ASTNode33);
5565
+ var ASTExprFunctionCall = exports.ASTExprFunctionCall = function (_ASTNode35) {
5566
+ _inherits(ASTExprFunctionCall, _ASTNode35);
5516
5567
 
5517
5568
  function ASTExprFunctionCall(functionName, args) {
5518
5569
  _classCallCheck(this, ASTExprFunctionCall);
@@ -5535,8 +5586,8 @@ var ASTExprFunctionCall = exports.ASTExprFunctionCall = function (_ASTNode33) {
5535
5586
  return ASTExprFunctionCall;
5536
5587
  }(ASTNode);
5537
5588
 
5538
- var ASTFieldBinding = exports.ASTFieldBinding = function (_ASTNode34) {
5539
- _inherits(ASTFieldBinding, _ASTNode34);
5589
+ var ASTFieldBinding = exports.ASTFieldBinding = function (_ASTNode36) {
5590
+ _inherits(ASTFieldBinding, _ASTNode36);
5540
5591
 
5541
5592
  function ASTFieldBinding(fieldName, value) {
5542
5593
  _classCallCheck(this, ASTFieldBinding);
@@ -5559,8 +5610,8 @@ var ASTFieldBinding = exports.ASTFieldBinding = function (_ASTNode34) {
5559
5610
  return ASTFieldBinding;
5560
5611
  }(ASTNode);
5561
5612
 
5562
- var ASTConstructorDeclaration = exports.ASTConstructorDeclaration = function (_ASTNode35) {
5563
- _inherits(ASTConstructorDeclaration, _ASTNode35);
5613
+ var ASTConstructorDeclaration = exports.ASTConstructorDeclaration = function (_ASTNode37) {
5614
+ _inherits(ASTConstructorDeclaration, _ASTNode37);
5564
5615
 
5565
5616
  function ASTConstructorDeclaration(constructorName, fieldNames) {
5566
5617
  _classCallCheck(this, ASTConstructorDeclaration);
@@ -5618,6 +5669,9 @@ var T_ELSE = exports.T_ELSE = Symbol.for('T_ELSE');
5618
5669
  var T_CHOOSE = exports.T_CHOOSE = Symbol.for('T_CHOOSE');
5619
5670
  var T_WHEN = exports.T_WHEN = Symbol.for('T_WHEN');
5620
5671
  var T_OTHERWISE = exports.T_OTHERWISE = Symbol.for('T_OTHERWISE');
5672
+ var T_MATCHING = exports.T_MATCHING = Symbol.for('T_MATCHING');
5673
+ var T_SELECT = exports.T_SELECT = Symbol.for('T_SELECT');
5674
+ var T_ON = exports.T_ON = Symbol.for('T_ON');
5621
5675
  var T_REPEAT = exports.T_REPEAT = Symbol.for('T_REPEAT');
5622
5676
  var T_FOREACH = exports.T_FOREACH = Symbol.for('T_FOREACH');
5623
5677
  var T_IN = exports.T_IN = Symbol.for('T_IN');
@@ -8840,6 +8894,12 @@ var LOCALE_ES = exports.LOCALE_ES = {
8840
8894
  'T_MOD': keyword('mod'),
8841
8895
  'T_TYPE': keyword('type'),
8842
8896
  'T_IS': keyword('is'),
8897
+ 'T_CHOOSE': keyword('choose'),
8898
+ 'T_WHEN': keyword('when'),
8899
+ 'T_OTHERWISE': keyword('otherwise'),
8900
+ 'T_MATCHING': keyword('matching'),
8901
+ 'T_SELECT': keyword('select'),
8902
+ 'T_ON': keyword('on'),
8843
8903
  'T_RECORD': keyword('record'),
8844
8904
  'T_VARIANT': keyword('variant'),
8845
8905
  'T_CASE': keyword('case'),
@@ -9033,10 +9093,10 @@ var LOCALE_ES = exports.LOCALE_ES = {
9033
9093
  return 'El constructor "' + name + '" no está definido.';
9034
9094
  },
9035
9095
 
9036
- 'errmsg:wildcard-pattern-should-be-last': 'El comodín "_" tiene que ser la última rama del switch.',
9096
+ 'errmsg:wildcard-pattern-should-be-last': 'El comodín "_" debe estar en la última rama.',
9037
9097
 
9038
9098
  'errmsg:variable-pattern-should-be-last': function errmsgVariablePatternShouldBeLast(name) {
9039
- return 'El patrón variable "' + name + '" tiene que ser la última rama del switch.';
9099
+ return 'El patrón variable "' + name + '" tiene debe estar en la última rama.';
9040
9100
  },
9041
9101
 
9042
9102
  'errmsg:numeric-pattern-repeats-number': function errmsgNumericPatternRepeatsNumber(number) {
@@ -9059,7 +9119,7 @@ var LOCALE_ES = exports.LOCALE_ES = {
9059
9119
 
9060
9120
  'errmsg:patterns-in-interactive-program-must-be-events': 'Los patrones de un "interactive program" deben ser eventos.',
9061
9121
 
9062
- 'errmsg:patterns-in-switch-must-not-be-events': 'Los patrones de un "switch" no pueden ser eventos.',
9122
+ 'errmsg:patterns-in-switch-must-not-be-events': 'El patrón no puede ser un evento.',
9063
9123
 
9064
9124
  'errmsg:structure-construction-repeated-field': function errmsgStructureConstructionRepeatedField(constructorName, fieldName) {
9065
9125
  return 'El campo "' + fieldName + '" está repetido en ' + 'la instanciación del constructor "' + constructorName + '".';
@@ -14480,6 +14540,8 @@ var Parser = exports.Parser = function () {
14480
14540
  return this._parseExprConstantString();
14481
14541
  case _token.T_CHOOSE:
14482
14542
  return this._parseExprChoose(true /* expectInitialChoose */);
14543
+ case _token.T_MATCHING:
14544
+ return this._parseExprMatching();
14483
14545
  case _token.T_UPPERID:
14484
14546
  return this._parseExprStructureOrStructureUpdate();
14485
14547
  case _token.T_LPAREN:
@@ -14566,6 +14628,21 @@ var Parser = exports.Parser = function () {
14566
14628
  return expr1;
14567
14629
  }
14568
14630
  }
14631
+ }, {
14632
+ key: '_parseExprMatching',
14633
+ value: function _parseExprMatching() {
14634
+ var startPos = this._currentToken.startPos;
14635
+ this._match(_token.T_MATCHING);
14636
+ this._match(_token.T_LPAREN);
14637
+ var subject = this._parseExpression();
14638
+ this._match(_token.T_RPAREN);
14639
+ this._match(_token.T_SELECT);
14640
+ var branches = this._parseMatchingBranches();
14641
+ var result = new _ast.ASTExprMatching(subject, branches);
14642
+ result.startPos = startPos;
14643
+ result.endPos = result.endPos;
14644
+ return result;
14645
+ }
14569
14646
 
14570
14647
  /*
14571
14648
  * Parse any of the following constructions:
@@ -14826,6 +14903,47 @@ var Parser = exports.Parser = function () {
14826
14903
  return result;
14827
14904
  }
14828
14905
 
14906
+ /** MatchingBranch **/
14907
+
14908
+ }, {
14909
+ key: '_parseMatchingBranches',
14910
+ value: function _parseMatchingBranches() {
14911
+ var branches = [];
14912
+ while (this._currentToken.tag !== _token.T_OTHERWISE) {
14913
+ branches.push(this._parseMatchingBranch());
14914
+ }
14915
+ this._match(_token.T_OTHERWISE);
14916
+ return branches;
14917
+ }
14918
+ }, {
14919
+ key: '_parseMatchingBranch',
14920
+ value: function _parseMatchingBranch() {
14921
+ var body = this._parseExpression();
14922
+ switch (this._currentToken.tag) {
14923
+ case _token.T_ON:
14924
+ {
14925
+ this._match(_token.T_ON);
14926
+ var pattern = this._parsePattern();
14927
+ var result = new _ast.ASTMatchingBranch(pattern, body);
14928
+ result.startPos = body.startPos;
14929
+ result.endPos = pattern.endPos;
14930
+ return result;
14931
+ }
14932
+ case _token.T_OTHERWISE:
14933
+ {
14934
+ var _pattern = new _ast.ASTPatternWildcard();
14935
+ _pattern.startPos = this._currentToken.startPos;
14936
+ _pattern.endPos = this._currentToken.endPos;
14937
+ var _result2 = new _ast.ASTMatchingBranch(_pattern, body);
14938
+ _result2.startPos = body.startPos;
14939
+ _result2.endPos = this._currentToken.endPos;
14940
+ return _result2;
14941
+ }
14942
+ default:
14943
+ return fail(this._currentToken.startPos, this._currentToken.endPos, 'expected-but-found', [(0, _i18n.i18n)('<alternative>')([(0, _i18n.i18n)('T_ON'), (0, _i18n.i18n)('T_OTHERWISE')]), (0, _i18n.i18n)(Symbol.keyFor(this._currentToken.tag))]);
14944
+ }
14945
+ }
14946
+
14829
14947
  /** FieldBinding **/
14830
14948
 
14831
14949
  }, {
@@ -15033,6 +15151,9 @@ var KEYWORDS = {
15033
15151
  'while': _token.T_WHILE,
15034
15152
  'switch': _token.T_SWITCH,
15035
15153
  'to': _token.T_TO,
15154
+ 'matching': _token.T_MATCHING,
15155
+ 'select': _token.T_SELECT,
15156
+ 'on': _token.T_ON,
15036
15157
  /* Assignment */
15037
15158
  'let': _token.T_LET,
15038
15159
  /* Operators */
@@ -16057,6 +16178,11 @@ var Linter = exports.Linter = function () {
16057
16178
  }, {
16058
16179
  key: '_lintSwitchBranches',
16059
16180
  value: function _lintSwitchBranches(branches, isInteractiveProgram) {
16181
+ this._lintBranches(branches, isInteractiveProgram, false /* isMatching */);
16182
+ }
16183
+ }, {
16184
+ key: '_lintBranches',
16185
+ value: function _lintBranches(branches, isInteractiveProgram, isMatching) {
16060
16186
  /* Check that each pattern is well-formed */
16061
16187
  var _iteratorNormalCompletion8 = true;
16062
16188
  var _didIteratorError8 = false;
@@ -16083,13 +16209,13 @@ var Linter = exports.Linter = function () {
16083
16209
  }
16084
16210
  }
16085
16211
 
16086
- this._switchBranchesCheckWildcardAndVariable(branches);
16087
- this._switchBranchesCheckNoRepeats(branches);
16088
- this._switchBranchesCheckCompatible(branches);
16212
+ this._branchesCheckWildcardAndVariable(branches);
16213
+ this._branchesCheckNoRepeats(branches);
16214
+ this._branchesCheckCompatible(branches);
16089
16215
  if (isInteractiveProgram) {
16090
- this._switchBranchesCheckTypeEvent(branches);
16216
+ this._branchesCheckTypeEvent(branches);
16091
16217
  } else {
16092
- this._switchBranchesCheckTypeNotEvent(branches);
16218
+ this._branchesCheckTypeNotEvent(branches);
16093
16219
  }
16094
16220
 
16095
16221
  /* Lint recursively each branch */
@@ -16101,7 +16227,7 @@ var Linter = exports.Linter = function () {
16101
16227
  for (var _iterator9 = branches[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
16102
16228
  var _branch = _step9.value;
16103
16229
 
16104
- this._lintSwitchBranchBody(_branch);
16230
+ this._lintBranchBody(_branch, isMatching);
16105
16231
  }
16106
16232
  } catch (err) {
16107
16233
  _didIteratorError9 = true;
@@ -16122,8 +16248,8 @@ var Linter = exports.Linter = function () {
16122
16248
  /* Check that there is at most one wildcard/variable pattern at the end */
16123
16249
 
16124
16250
  }, {
16125
- key: '_switchBranchesCheckWildcardAndVariable',
16126
- value: function _switchBranchesCheckWildcardAndVariable(branches) {
16251
+ key: '_branchesCheckWildcardAndVariable',
16252
+ value: function _branchesCheckWildcardAndVariable(branches) {
16127
16253
  var i = 0;
16128
16254
  var n = branches.length;
16129
16255
  var _iteratorNormalCompletion10 = true;
@@ -16162,8 +16288,8 @@ var Linter = exports.Linter = function () {
16162
16288
  * of branches. */
16163
16289
 
16164
16290
  }, {
16165
- key: '_switchBranchesCheckNoRepeats',
16166
- value: function _switchBranchesCheckNoRepeats(branches) {
16291
+ key: '_branchesCheckNoRepeats',
16292
+ value: function _branchesCheckNoRepeats(branches) {
16167
16293
  var coveredNumbers = {};
16168
16294
  var coveredConstructors = {};
16169
16295
  var coveredTuples = {};
@@ -16231,8 +16357,8 @@ var Linter = exports.Linter = function () {
16231
16357
  * i.e. that they belong to the same type */
16232
16358
 
16233
16359
  }, {
16234
- key: '_switchBranchesCheckCompatible',
16235
- value: function _switchBranchesCheckCompatible(branches) {
16360
+ key: '_branchesCheckCompatible',
16361
+ value: function _branchesCheckCompatible(branches) {
16236
16362
  var expectedType = null;
16237
16363
  var _iteratorNormalCompletion12 = true;
16238
16364
  var _didIteratorError12 = false;
@@ -16268,8 +16394,8 @@ var Linter = exports.Linter = function () {
16268
16394
  /* Check that there are patterns are of type Event */
16269
16395
 
16270
16396
  }, {
16271
- key: '_switchBranchesCheckTypeEvent',
16272
- value: function _switchBranchesCheckTypeEvent(branches) {
16397
+ key: '_branchesCheckTypeEvent',
16398
+ value: function _branchesCheckTypeEvent(branches) {
16273
16399
  var _iteratorNormalCompletion13 = true;
16274
16400
  var _didIteratorError13 = false;
16275
16401
  var _iteratorError13 = undefined;
@@ -16302,8 +16428,8 @@ var Linter = exports.Linter = function () {
16302
16428
  /* Check that there are no patterns of type Event */
16303
16429
 
16304
16430
  }, {
16305
- key: '_switchBranchesCheckTypeNotEvent',
16306
- value: function _switchBranchesCheckTypeNotEvent(branches) {
16431
+ key: '_branchesCheckTypeNotEvent',
16432
+ value: function _branchesCheckTypeNotEvent(branches) {
16307
16433
  var _iteratorNormalCompletion14 = true;
16308
16434
  var _didIteratorError14 = false;
16309
16435
  var _iteratorError14 = undefined;
@@ -16336,8 +16462,8 @@ var Linter = exports.Linter = function () {
16336
16462
  /* Recursively lint the body of each branch. Locally bind variables. */
16337
16463
 
16338
16464
  }, {
16339
- key: '_lintSwitchBranchBody',
16340
- value: function _lintSwitchBranchBody(branch) {
16465
+ key: '_lintBranchBody',
16466
+ value: function _lintBranchBody(branch, isMatching) {
16341
16467
  var _iteratorNormalCompletion15 = true;
16342
16468
  var _didIteratorError15 = false;
16343
16469
  var _iteratorError15 = undefined;
@@ -16363,7 +16489,11 @@ var Linter = exports.Linter = function () {
16363
16489
  }
16364
16490
  }
16365
16491
 
16366
- this._lintStatement(branch.body);
16492
+ if (isMatching) {
16493
+ this._lintExpression(branch.body);
16494
+ } else {
16495
+ this._lintStatement(branch.body);
16496
+ }
16367
16497
  var _iteratorNormalCompletion16 = true;
16368
16498
  var _didIteratorError16 = false;
16369
16499
  var _iteratorError16 = undefined;
@@ -16582,6 +16712,8 @@ var Linter = exports.Linter = function () {
16582
16712
  return this._lintExprConstantString(expression);
16583
16713
  case _ast.N_ExprChoose:
16584
16714
  return this._lintExprChoose(expression);
16715
+ case _ast.N_ExprMatching:
16716
+ return this._lintExprMatching(expression);
16585
16717
  case _ast.N_ExprList:
16586
16718
  return this._lintExprList(expression);
16587
16719
  case _ast.N_ExprRange:
@@ -16622,6 +16754,19 @@ var Linter = exports.Linter = function () {
16622
16754
  this._lintExpression(expression.trueExpr);
16623
16755
  this._lintExpression(expression.falseExpr);
16624
16756
  }
16757
+ }, {
16758
+ key: '_lintExprMatching',
16759
+ value: function _lintExprMatching(expression) {
16760
+ this._lintExpression(expression.subject);
16761
+ this._lintMatchingBranches(expression.branches);
16762
+ }
16763
+ }, {
16764
+ key: '_lintMatchingBranches',
16765
+ value: function _lintMatchingBranches(branches) {
16766
+ this._lintBranches(branches, false /* !isInteractiveProgram */
16767
+ , true /* isMatching */
16768
+ );
16769
+ }
16625
16770
  }, {
16626
16771
  key: '_lintExprList',
16627
16772
  value: function _lintExprList(expression) {
@@ -17322,7 +17467,7 @@ var Compiler = exports.Compiler = function () {
17322
17467
  }, {
17323
17468
  key: '_compileDefInteractiveProgram',
17324
17469
  value: function _compileDefInteractiveProgram(definition) {
17325
- this._compileMatchSwitchBranches(definition);
17470
+ this._compileMatchBranches(definition, false /* isMatching */);
17326
17471
  this._produce(definition.startPos, definition.endPos, new _instruction.IReturn());
17327
17472
  }
17328
17473
 
@@ -17673,11 +17818,11 @@ var Compiler = exports.Compiler = function () {
17673
17818
  value: function _compileStmtSwitch(statement) {
17674
17819
  /* Compile the subject */
17675
17820
  this._compileExpression(statement.subject);
17676
- this._compileMatchSwitchBranches(statement);
17821
+ this._compileMatchBranches(statement, false /* !isMatching */);
17677
17822
  }
17678
17823
  }, {
17679
- key: '_compileMatchSwitchBranches',
17680
- value: function _compileMatchSwitchBranches(statement) {
17824
+ key: '_compileMatchBranches',
17825
+ value: function _compileMatchBranches(statement, isMatching) {
17681
17826
  var branchLabels = [];
17682
17827
  /* Attempt to match each pattern */
17683
17828
  var _iteratorNormalCompletion4 = true;
@@ -17719,7 +17864,11 @@ var Compiler = exports.Compiler = function () {
17719
17864
  this._produce(branch.startPos, branch.endPos, new _instruction.ILabel(label));
17720
17865
  this._compilePatternBind(branch.pattern);
17721
17866
  this._produce(branch.startPos, branch.endPos, new _instruction.IPop());
17722
- this._compileStatement(branch.body);
17867
+ if (isMatching) {
17868
+ this._compileExpression(branch.body);
17869
+ } else {
17870
+ this._compileStatement(branch.body);
17871
+ }
17723
17872
  this._compilePatternUnbind(branch.pattern);
17724
17873
  this._produce(branch.startPos, branch.endPos, new _instruction.IJump(labelEnd));
17725
17874
  }
@@ -17995,6 +18144,8 @@ var Compiler = exports.Compiler = function () {
17995
18144
  return this._compileExprConstantString(expression);
17996
18145
  case _ast.N_ExprChoose:
17997
18146
  return this._compileExprChoose(expression);
18147
+ case _ast.N_ExprMatching:
18148
+ return this._compileExprMatching(expression);
17998
18149
  case _ast.N_ExprList:
17999
18150
  return this._compileExprList(expression);
18000
18151
  case _ast.N_ExprRange:
@@ -18069,6 +18220,12 @@ var Compiler = exports.Compiler = function () {
18069
18220
  this._compileExpression(expression.falseExpr);
18070
18221
  this._produce(expression.startPos, expression.endPos, new _instruction.ILabel(labelEnd));
18071
18222
  }
18223
+ }, {
18224
+ key: '_compileExprMatching',
18225
+ value: function _compileExprMatching(expression) {
18226
+ this._compileExpression(expression.subject);
18227
+ this._compileMatchBranches(expression, true /* isMatching */);
18228
+ }
18072
18229
  }, {
18073
18230
  key: '_compileExprList',
18074
18231
  value: function _compileExprList(expression) {
@@ -1,5 +1,5 @@
1
1
  module Gobstones
2
2
  module CodeRunner
3
- VERSION = "0.5.4"
3
+ VERSION = "0.6.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gobstones-code-runner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.4
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Alfonso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-04 00:00:00.000000000 Z
11
+ date: 2018-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler