gobstones-code-runner 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d096a3edbdc717aeee04ce0a9a6da2e49195707a35140f4f5a6116613a80dc3
4
- data.tar.gz: fe6774c8b482b3af6b66bc35a4b0a267420b1ea2c94983c33310a337e0fede8e
3
+ metadata.gz: 6f7ef66628bf9b72a8a81c6a2bb22cf1fd2a219c5e3a34a1b939ae1d2cd4da3a
4
+ data.tar.gz: bc604bcb3c94bcbd4aa273afd35e234c5e834159babfaf3a181a3fd26b6c3906
5
5
  SHA512:
6
- metadata.gz: 6104cf0e37e18b7c16ab9964835cf52de88f004a52598e7c98cc3013d4b0670de88382fc51daaefc6319b787dd7e1672567b51bd880a699b1516f7c507fd88b9
7
- data.tar.gz: 64cc76cf22a63d2f68cff993cbf754975448b8160b1fd23ff6fdfe1847d7496ca41a5c9328bd606d3fcefb56412e8c68b2d83ceb87fece8e0c4073e83248e6b3
6
+ metadata.gz: af4ec3a49236ae4346e8279885c1786ffcbac4c96de3d3dc786a36e72034296c887761ceb34e6d923960aa7624ffbf1f4f3d7e1affc00fcd88de01d3f60964bd
7
+ data.tar.gz: d38df24298a0d95e10aa94186c4b887520999a3ed9a186710c374e2654a559b9d47efd8c426dbcd4ea60b16665075a93276dcef46d007aa4d46b5077b62d6317
@@ -4474,7 +4474,7 @@ var GbsRuntimeError = exports.GbsRuntimeError = function (_GbsInterpreterExcept3
4474
4474
  Object.defineProperty(exports, "__esModule", {
4475
4475
  value: true
4476
4476
  });
4477
- 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.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_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;
4477
+ 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;
4478
4478
 
4479
4479
  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; }; }();
4480
4480
 
@@ -4508,6 +4508,7 @@ var N_StmtAssignTuple = exports.N_StmtAssignTuple = Symbol.for('N_StmtAssignTupl
4508
4508
  var N_StmtProcedureCall = exports.N_StmtProcedureCall = Symbol.for('N_StmtProcedureCall');
4509
4509
  /* Patterns */
4510
4510
  var N_PatternWildcard = exports.N_PatternWildcard = Symbol.for('N_PatternWildcard');
4511
+ var N_PatternVariable = exports.N_PatternVariable = Symbol.for('N_PatternVariable');
4511
4512
  var N_PatternNumber = exports.N_PatternNumber = Symbol.for('N_PatternNumber');
4512
4513
  var N_PatternStructure = exports.N_PatternStructure = Symbol.for('N_PatternStructure');
4513
4514
  var N_PatternTuple = exports.N_PatternTuple = Symbol.for('N_PatternTuple');
@@ -4935,14 +4936,14 @@ var ASTStmtRepeat = exports.ASTStmtRepeat = function (_ASTNode10) {
4935
4936
  var ASTStmtForeach = exports.ASTStmtForeach = function (_ASTNode11) {
4936
4937
  _inherits(ASTStmtForeach, _ASTNode11);
4937
4938
 
4938
- function ASTStmtForeach(index, range, body) {
4939
+ function ASTStmtForeach(pattern, range, body) {
4939
4940
  _classCallCheck(this, ASTStmtForeach);
4940
4941
 
4941
- return _possibleConstructorReturn(this, (ASTStmtForeach.__proto__ || Object.getPrototypeOf(ASTStmtForeach)).call(this, N_StmtForeach, [index, range, body]));
4942
+ return _possibleConstructorReturn(this, (ASTStmtForeach.__proto__ || Object.getPrototypeOf(ASTStmtForeach)).call(this, N_StmtForeach, [pattern, range, body]));
4942
4943
  }
4943
4944
 
4944
4945
  _createClass(ASTStmtForeach, [{
4945
- key: 'index',
4946
+ key: 'pattern',
4946
4947
  get: function get() {
4947
4948
  return this._children[0];
4948
4949
  }
@@ -5117,7 +5118,7 @@ var ASTPatternWildcard = exports.ASTPatternWildcard = function (_ASTNode18) {
5117
5118
  }
5118
5119
 
5119
5120
  _createClass(ASTPatternWildcard, [{
5120
- key: 'parameters',
5121
+ key: 'boundVariables',
5121
5122
  get: function get() {
5122
5123
  return [];
5123
5124
  }
@@ -5126,8 +5127,32 @@ var ASTPatternWildcard = exports.ASTPatternWildcard = function (_ASTNode18) {
5126
5127
  return ASTPatternWildcard;
5127
5128
  }(ASTNode);
5128
5129
 
5129
- var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode19) {
5130
- _inherits(ASTPatternNumber, _ASTNode19);
5130
+ var ASTPatternVariable = exports.ASTPatternVariable = function (_ASTNode19) {
5131
+ _inherits(ASTPatternVariable, _ASTNode19);
5132
+
5133
+ function ASTPatternVariable(variableName) {
5134
+ _classCallCheck(this, ASTPatternVariable);
5135
+
5136
+ return _possibleConstructorReturn(this, (ASTPatternVariable.__proto__ || Object.getPrototypeOf(ASTPatternVariable)).call(this, N_PatternVariable, [variableName]));
5137
+ }
5138
+
5139
+ _createClass(ASTPatternVariable, [{
5140
+ key: 'variableName',
5141
+ get: function get() {
5142
+ return this._children[0];
5143
+ }
5144
+ }, {
5145
+ key: 'boundVariables',
5146
+ get: function get() {
5147
+ return [this._children[0]];
5148
+ }
5149
+ }]);
5150
+
5151
+ return ASTPatternVariable;
5152
+ }(ASTNode);
5153
+
5154
+ var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode20) {
5155
+ _inherits(ASTPatternNumber, _ASTNode20);
5131
5156
 
5132
5157
  function ASTPatternNumber(number) {
5133
5158
  _classCallCheck(this, ASTPatternNumber);
@@ -5141,7 +5166,7 @@ var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode19) {
5141
5166
  return this._children[0];
5142
5167
  }
5143
5168
  }, {
5144
- key: 'parameters',
5169
+ key: 'boundVariables',
5145
5170
  get: function get() {
5146
5171
  return [];
5147
5172
  }
@@ -5150,8 +5175,8 @@ var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode19) {
5150
5175
  return ASTPatternNumber;
5151
5176
  }(ASTNode);
5152
5177
 
5153
- var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode20) {
5154
- _inherits(ASTPatternStructure, _ASTNode20);
5178
+ var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode21) {
5179
+ _inherits(ASTPatternStructure, _ASTNode21);
5155
5180
 
5156
5181
  function ASTPatternStructure(constructorName, parameters) {
5157
5182
  _classCallCheck(this, ASTPatternStructure);
@@ -5165,7 +5190,7 @@ var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode20) {
5165
5190
  return this._children[0];
5166
5191
  }
5167
5192
  }, {
5168
- key: 'parameters',
5193
+ key: 'boundVariables',
5169
5194
  get: function get() {
5170
5195
  return this._children[1];
5171
5196
  }
@@ -5174,8 +5199,8 @@ var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode20) {
5174
5199
  return ASTPatternStructure;
5175
5200
  }(ASTNode);
5176
5201
 
5177
- var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode21) {
5178
- _inherits(ASTPatternTuple, _ASTNode21);
5202
+ var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode22) {
5203
+ _inherits(ASTPatternTuple, _ASTNode22);
5179
5204
 
5180
5205
  function ASTPatternTuple(parameters) {
5181
5206
  _classCallCheck(this, ASTPatternTuple);
@@ -5184,7 +5209,7 @@ var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode21) {
5184
5209
  }
5185
5210
 
5186
5211
  _createClass(ASTPatternTuple, [{
5187
- key: 'parameters',
5212
+ key: 'boundVariables',
5188
5213
  get: function get() {
5189
5214
  return this._children;
5190
5215
  }
@@ -5193,8 +5218,8 @@ var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode21) {
5193
5218
  return ASTPatternTuple;
5194
5219
  }(ASTNode);
5195
5220
 
5196
- var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode22) {
5197
- _inherits(ASTPatternTimeout, _ASTNode22);
5221
+ var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode23) {
5222
+ _inherits(ASTPatternTimeout, _ASTNode23);
5198
5223
 
5199
5224
  function ASTPatternTimeout(timeout) {
5200
5225
  _classCallCheck(this, ASTPatternTimeout);
@@ -5203,7 +5228,7 @@ var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode22) {
5203
5228
  }
5204
5229
 
5205
5230
  _createClass(ASTPatternTimeout, [{
5206
- key: 'parameters',
5231
+ key: 'boundVariables',
5207
5232
  get: function get() {
5208
5233
  return [];
5209
5234
  }
@@ -5219,8 +5244,8 @@ var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode22) {
5219
5244
 
5220
5245
  /* Expressions */
5221
5246
 
5222
- var ASTExprVariable = exports.ASTExprVariable = function (_ASTNode23) {
5223
- _inherits(ASTExprVariable, _ASTNode23);
5247
+ var ASTExprVariable = exports.ASTExprVariable = function (_ASTNode24) {
5248
+ _inherits(ASTExprVariable, _ASTNode24);
5224
5249
 
5225
5250
  function ASTExprVariable(variableName) {
5226
5251
  _classCallCheck(this, ASTExprVariable);
@@ -5238,8 +5263,8 @@ var ASTExprVariable = exports.ASTExprVariable = function (_ASTNode23) {
5238
5263
  return ASTExprVariable;
5239
5264
  }(ASTNode);
5240
5265
 
5241
- var ASTExprConstantNumber = exports.ASTExprConstantNumber = function (_ASTNode24) {
5242
- _inherits(ASTExprConstantNumber, _ASTNode24);
5266
+ var ASTExprConstantNumber = exports.ASTExprConstantNumber = function (_ASTNode25) {
5267
+ _inherits(ASTExprConstantNumber, _ASTNode25);
5243
5268
 
5244
5269
  function ASTExprConstantNumber(number) {
5245
5270
  _classCallCheck(this, ASTExprConstantNumber);
@@ -5257,8 +5282,8 @@ var ASTExprConstantNumber = exports.ASTExprConstantNumber = function (_ASTNode24
5257
5282
  return ASTExprConstantNumber;
5258
5283
  }(ASTNode);
5259
5284
 
5260
- var ASTExprConstantString = exports.ASTExprConstantString = function (_ASTNode25) {
5261
- _inherits(ASTExprConstantString, _ASTNode25);
5285
+ var ASTExprConstantString = exports.ASTExprConstantString = function (_ASTNode26) {
5286
+ _inherits(ASTExprConstantString, _ASTNode26);
5262
5287
 
5263
5288
  function ASTExprConstantString(string) {
5264
5289
  _classCallCheck(this, ASTExprConstantString);
@@ -5276,8 +5301,8 @@ var ASTExprConstantString = exports.ASTExprConstantString = function (_ASTNode25
5276
5301
  return ASTExprConstantString;
5277
5302
  }(ASTNode);
5278
5303
 
5279
- var ASTExprChoose = exports.ASTExprChoose = function (_ASTNode26) {
5280
- _inherits(ASTExprChoose, _ASTNode26);
5304
+ var ASTExprChoose = exports.ASTExprChoose = function (_ASTNode27) {
5305
+ _inherits(ASTExprChoose, _ASTNode27);
5281
5306
 
5282
5307
  function ASTExprChoose(condition, trueExpr, falseExpr) {
5283
5308
  _classCallCheck(this, ASTExprChoose);
@@ -5305,8 +5330,8 @@ var ASTExprChoose = exports.ASTExprChoose = function (_ASTNode26) {
5305
5330
  return ASTExprChoose;
5306
5331
  }(ASTNode);
5307
5332
 
5308
- var ASTExprList = exports.ASTExprList = function (_ASTNode27) {
5309
- _inherits(ASTExprList, _ASTNode27);
5333
+ var ASTExprList = exports.ASTExprList = function (_ASTNode28) {
5334
+ _inherits(ASTExprList, _ASTNode28);
5310
5335
 
5311
5336
  function ASTExprList(elements) {
5312
5337
  _classCallCheck(this, ASTExprList);
@@ -5324,8 +5349,8 @@ var ASTExprList = exports.ASTExprList = function (_ASTNode27) {
5324
5349
  return ASTExprList;
5325
5350
  }(ASTNode);
5326
5351
 
5327
- var ASTExprRange = exports.ASTExprRange = function (_ASTNode28) {
5328
- _inherits(ASTExprRange, _ASTNode28);
5352
+ var ASTExprRange = exports.ASTExprRange = function (_ASTNode29) {
5353
+ _inherits(ASTExprRange, _ASTNode29);
5329
5354
 
5330
5355
  // Note: second may be null
5331
5356
  function ASTExprRange(first, second, last) {
@@ -5354,8 +5379,8 @@ var ASTExprRange = exports.ASTExprRange = function (_ASTNode28) {
5354
5379
  return ASTExprRange;
5355
5380
  }(ASTNode);
5356
5381
 
5357
- var ASTExprTuple = exports.ASTExprTuple = function (_ASTNode29) {
5358
- _inherits(ASTExprTuple, _ASTNode29);
5382
+ var ASTExprTuple = exports.ASTExprTuple = function (_ASTNode30) {
5383
+ _inherits(ASTExprTuple, _ASTNode30);
5359
5384
 
5360
5385
  function ASTExprTuple(elements) {
5361
5386
  _classCallCheck(this, ASTExprTuple);
@@ -5373,8 +5398,8 @@ var ASTExprTuple = exports.ASTExprTuple = function (_ASTNode29) {
5373
5398
  return ASTExprTuple;
5374
5399
  }(ASTNode);
5375
5400
 
5376
- var ASTExprStructure = exports.ASTExprStructure = function (_ASTNode30) {
5377
- _inherits(ASTExprStructure, _ASTNode30);
5401
+ var ASTExprStructure = exports.ASTExprStructure = function (_ASTNode31) {
5402
+ _inherits(ASTExprStructure, _ASTNode31);
5378
5403
 
5379
5404
  function ASTExprStructure(constructorName, fieldBindings) {
5380
5405
  _classCallCheck(this, ASTExprStructure);
@@ -5428,8 +5453,8 @@ var ASTExprStructure = exports.ASTExprStructure = function (_ASTNode30) {
5428
5453
  return ASTExprStructure;
5429
5454
  }(ASTNode);
5430
5455
 
5431
- var ASTExprStructureUpdate = exports.ASTExprStructureUpdate = function (_ASTNode31) {
5432
- _inherits(ASTExprStructureUpdate, _ASTNode31);
5456
+ var ASTExprStructureUpdate = exports.ASTExprStructureUpdate = function (_ASTNode32) {
5457
+ _inherits(ASTExprStructureUpdate, _ASTNode32);
5433
5458
 
5434
5459
  function ASTExprStructureUpdate(constructorName, original, fieldBindings) {
5435
5460
  _classCallCheck(this, ASTExprStructureUpdate);
@@ -5488,8 +5513,8 @@ var ASTExprStructureUpdate = exports.ASTExprStructureUpdate = function (_ASTNode
5488
5513
  return ASTExprStructureUpdate;
5489
5514
  }(ASTNode);
5490
5515
 
5491
- var ASTExprFunctionCall = exports.ASTExprFunctionCall = function (_ASTNode32) {
5492
- _inherits(ASTExprFunctionCall, _ASTNode32);
5516
+ var ASTExprFunctionCall = exports.ASTExprFunctionCall = function (_ASTNode33) {
5517
+ _inherits(ASTExprFunctionCall, _ASTNode33);
5493
5518
 
5494
5519
  function ASTExprFunctionCall(functionName, args) {
5495
5520
  _classCallCheck(this, ASTExprFunctionCall);
@@ -5512,8 +5537,8 @@ var ASTExprFunctionCall = exports.ASTExprFunctionCall = function (_ASTNode32) {
5512
5537
  return ASTExprFunctionCall;
5513
5538
  }(ASTNode);
5514
5539
 
5515
- var ASTFieldBinding = exports.ASTFieldBinding = function (_ASTNode33) {
5516
- _inherits(ASTFieldBinding, _ASTNode33);
5540
+ var ASTFieldBinding = exports.ASTFieldBinding = function (_ASTNode34) {
5541
+ _inherits(ASTFieldBinding, _ASTNode34);
5517
5542
 
5518
5543
  function ASTFieldBinding(fieldName, value) {
5519
5544
  _classCallCheck(this, ASTFieldBinding);
@@ -5536,8 +5561,8 @@ var ASTFieldBinding = exports.ASTFieldBinding = function (_ASTNode33) {
5536
5561
  return ASTFieldBinding;
5537
5562
  }(ASTNode);
5538
5563
 
5539
- var ASTConstructorDeclaration = exports.ASTConstructorDeclaration = function (_ASTNode34) {
5540
- _inherits(ASTConstructorDeclaration, _ASTNode34);
5564
+ var ASTConstructorDeclaration = exports.ASTConstructorDeclaration = function (_ASTNode35) {
5565
+ _inherits(ASTConstructorDeclaration, _ASTNode35);
5541
5566
 
5542
5567
  function ASTConstructorDeclaration(constructorName, fieldNames) {
5543
5568
  _classCallCheck(this, ASTConstructorDeclaration);
@@ -8498,6 +8523,7 @@ var T_LBRACK = exports.T_LBRACK = Symbol.for('T_LBRACK');
8498
8523
  var T_RBRACK = exports.T_RBRACK = Symbol.for('T_RBRACK');
8499
8524
  var T_COMMA = exports.T_COMMA = Symbol.for('T_COMMA');
8500
8525
  var T_SEMICOLON = exports.T_SEMICOLON = Symbol.for('T_SEMICOLON');
8526
+ var T_ELLIPSIS = exports.T_ELLIPSIS = Symbol.for('T_ELLIPSIS');
8501
8527
  var T_RANGE = exports.T_RANGE = Symbol.for('T_RANGE');
8502
8528
  var T_GETS = exports.T_GETS = Symbol.for('T_GETS');
8503
8529
  var T_PIPE = exports.T_PIPE = Symbol.for('T_PIPE');
@@ -8829,6 +8855,10 @@ var LOCALE_ES = exports.LOCALE_ES = {
8829
8855
  return 'Se encontró un "' + delimiter + '" ' + 'pero no había ' + openingDelimiterName(delimiter) + '.';
8830
8856
  },
8831
8857
 
8858
+ 'errmsg:unknown-language-option': function errmsgUnknownLanguageOption(option) {
8859
+ return 'Opción desconocida. "' + option + '".';
8860
+ },
8861
+
8832
8862
  /* Parser */
8833
8863
  'errmsg:empty-source': 'El programa está vacío.',
8834
8864
 
@@ -8947,6 +8977,10 @@ var LOCALE_ES = exports.LOCALE_ES = {
8947
8977
 
8948
8978
  'errmsg:wildcard-pattern-should-be-last': 'El comodín "_" tiene que ser la última rama del switch.',
8949
8979
 
8980
+ 'errmsg:variable-pattern-should-be-last': function errmsgVariablePatternShouldBeLast(name) {
8981
+ return 'El patrón variable "' + name + '" tiene que ser la última rama del switch.';
8982
+ },
8983
+
8950
8984
  'errmsg:numeric-pattern-repeats-number': function errmsgNumericPatternRepeatsNumber(number) {
8951
8985
  return 'Hay dos ramas distintas para el número "' + number + '".';
8952
8986
  },
@@ -8985,7 +9019,13 @@ var LOCALE_ES = exports.LOCALE_ES = {
8985
9019
  return 'El constructor "' + constructorName + '" corresponde a un ' + 'evento, y solamente se puede manejar implícitamente ' + 'en un programa interactivo (el usuario no puede construir ' + 'instancias).';
8986
9020
  },
8987
9021
 
9022
+ 'errmsg:forbidden-extension-destructuring-foreach': 'El índice de la repetición indexada debe ser un identificador.',
9023
+
9024
+ 'errmsg:patterns-in-foreach-must-not-be-events': 'El patrón de un foreach no puede ser un evento.',
9025
+
8988
9026
  /* Runtime errors (virtual machine) */
9027
+ 'errmsg:ellipsis': 'El programa todavía no está completo.',
9028
+
8989
9029
  'errmsg:undefined-variable': function errmsgUndefinedVariable(variableName) {
8990
9030
  return 'La variable "' + variableName + '" no está definida.';
8991
9031
  },
@@ -9064,6 +9104,8 @@ var LOCALE_ES = exports.LOCALE_ES = {
9064
9104
 
9065
9105
  'errmsg:switch-does-not-match': 'El valor analizado no coincide con ninguna de las ramas del switch.',
9066
9106
 
9107
+ 'errmsg:foreach-pattern-does-not-match': 'El elemento no coincide con el patrón esperado por el foreach.',
9108
+
9067
9109
  'errmsg:cannot-divide-by-zero': 'No se puede dividir por cero.',
9068
9110
 
9069
9111
  'errmsg:list-cannot-be-empty': 'La lista no puede ser vacía.',
@@ -13228,7 +13270,33 @@ var Runner = exports.Runner = function () {
13228
13270
  }, {
13229
13271
  key: 'parse',
13230
13272
  value: function parse(input) {
13231
- this._ast = new _parser.Parser(input).parse();
13273
+ var parser = new _parser.Parser(input);
13274
+ this._ast = parser.parse();
13275
+
13276
+ var _iteratorNormalCompletion = true;
13277
+ var _didIteratorError = false;
13278
+ var _iteratorError = undefined;
13279
+
13280
+ try {
13281
+ for (var _iterator = parser.getLanguageOptions()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
13282
+ var option = _step.value;
13283
+
13284
+ this._setLanguageOption(option);
13285
+ }
13286
+ } catch (err) {
13287
+ _didIteratorError = true;
13288
+ _iteratorError = err;
13289
+ } finally {
13290
+ try {
13291
+ if (!_iteratorNormalCompletion && _iterator.return) {
13292
+ _iterator.return();
13293
+ }
13294
+ } finally {
13295
+ if (_didIteratorError) {
13296
+ throw _iteratorError;
13297
+ }
13298
+ }
13299
+ }
13232
13300
  }
13233
13301
  }, {
13234
13302
  key: 'enableLintCheck',
@@ -13272,10 +13340,22 @@ var Runner = exports.Runner = function () {
13272
13340
  this._result = this._vm.runEventWithTimeout(eventValue, millisecs);
13273
13341
  }
13274
13342
  }, {
13275
- key: 'regionStack',
13343
+ key: '_setLanguageOption',
13344
+
13276
13345
 
13346
+ /* Evaluate language options set by the LANGUAGE pragma */
13347
+ value: function _setLanguageOption(option) {
13348
+ if (option === 'DestructuringForeach') {
13349
+ this.enableLintCheck('forbidden-extension-destructuring-foreach', false);
13350
+ } else {
13351
+ throw Error('Unknown language option: ' + option);
13352
+ }
13353
+ }
13277
13354
 
13278
13355
  /* Dynamic stack of regions */
13356
+
13357
+ }, {
13358
+ key: 'regionStack',
13279
13359
  value: function regionStack() {
13280
13360
  return this._vm.regionStack();
13281
13361
  }
@@ -13289,45 +13369,18 @@ var Runner = exports.Runner = function () {
13289
13369
  var symtable = new _symtable.SymbolTable();
13290
13370
 
13291
13371
  /* Populate symbol table with primitive types */
13292
- var _iteratorNormalCompletion = true;
13293
- var _didIteratorError = false;
13294
- var _iteratorError = undefined;
13295
-
13296
- try {
13297
- for (var _iterator = this._primitives.types()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
13298
- var type = _step.value;
13299
-
13300
- symtable.defType(this._astDefType(type));
13301
- }
13302
-
13303
- /* Populate symbol table with primitive procedures */
13304
- } catch (err) {
13305
- _didIteratorError = true;
13306
- _iteratorError = err;
13307
- } finally {
13308
- try {
13309
- if (!_iteratorNormalCompletion && _iterator.return) {
13310
- _iterator.return();
13311
- }
13312
- } finally {
13313
- if (_didIteratorError) {
13314
- throw _iteratorError;
13315
- }
13316
- }
13317
- }
13318
-
13319
13372
  var _iteratorNormalCompletion2 = true;
13320
13373
  var _didIteratorError2 = false;
13321
13374
  var _iteratorError2 = undefined;
13322
13375
 
13323
13376
  try {
13324
- for (var _iterator2 = this._primitives.procedures()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
13325
- var procedureName = _step2.value;
13377
+ for (var _iterator2 = this._primitives.types()[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
13378
+ var type = _step2.value;
13326
13379
 
13327
- symtable.defProcedure(this._astDefProcedure(procedureName));
13380
+ symtable.defType(this._astDefType(type));
13328
13381
  }
13329
13382
 
13330
- /* Populate symbol table with primitive functions */
13383
+ /* Populate symbol table with primitive procedures */
13331
13384
  } catch (err) {
13332
13385
  _didIteratorError2 = true;
13333
13386
  _iteratorError2 = err;
@@ -13348,11 +13401,13 @@ var Runner = exports.Runner = function () {
13348
13401
  var _iteratorError3 = undefined;
13349
13402
 
13350
13403
  try {
13351
- for (var _iterator3 = this._primitives.functions()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
13352
- var functionName = _step3.value;
13404
+ for (var _iterator3 = this._primitives.procedures()[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
13405
+ var procedureName = _step3.value;
13353
13406
 
13354
- symtable.defFunction(this._astDefFunction(functionName));
13407
+ symtable.defProcedure(this._astDefProcedure(procedureName));
13355
13408
  }
13409
+
13410
+ /* Populate symbol table with primitive functions */
13356
13411
  } catch (err) {
13357
13412
  _didIteratorError3 = true;
13358
13413
  _iteratorError3 = err;
@@ -13368,21 +13423,15 @@ var Runner = exports.Runner = function () {
13368
13423
  }
13369
13424
  }
13370
13425
 
13371
- return symtable;
13372
- }
13373
- }, {
13374
- key: '_astDefType',
13375
- value: function _astDefType(type) {
13376
- var constructorDeclarations = [];
13377
13426
  var _iteratorNormalCompletion4 = true;
13378
13427
  var _didIteratorError4 = false;
13379
13428
  var _iteratorError4 = undefined;
13380
13429
 
13381
13430
  try {
13382
- for (var _iterator4 = this._primitives.typeConstructors(type)[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
13383
- var _constructor = _step4.value;
13431
+ for (var _iterator4 = this._primitives.functions()[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
13432
+ var functionName = _step4.value;
13384
13433
 
13385
- constructorDeclarations.push(this._astConstructorDeclaration(type, _constructor));
13434
+ symtable.defFunction(this._astDefFunction(functionName));
13386
13435
  }
13387
13436
  } catch (err) {
13388
13437
  _didIteratorError4 = true;
@@ -13399,6 +13448,37 @@ var Runner = exports.Runner = function () {
13399
13448
  }
13400
13449
  }
13401
13450
 
13451
+ return symtable;
13452
+ }
13453
+ }, {
13454
+ key: '_astDefType',
13455
+ value: function _astDefType(type) {
13456
+ var constructorDeclarations = [];
13457
+ var _iteratorNormalCompletion5 = true;
13458
+ var _didIteratorError5 = false;
13459
+ var _iteratorError5 = undefined;
13460
+
13461
+ try {
13462
+ for (var _iterator5 = this._primitives.typeConstructors(type)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
13463
+ var _constructor = _step5.value;
13464
+
13465
+ constructorDeclarations.push(this._astConstructorDeclaration(type, _constructor));
13466
+ }
13467
+ } catch (err) {
13468
+ _didIteratorError5 = true;
13469
+ _iteratorError5 = err;
13470
+ } finally {
13471
+ try {
13472
+ if (!_iteratorNormalCompletion5 && _iterator5.return) {
13473
+ _iterator5.return();
13474
+ }
13475
+ } finally {
13476
+ if (_didIteratorError5) {
13477
+ throw _iteratorError5;
13478
+ }
13479
+ }
13480
+ }
13481
+
13402
13482
  return new _ast.ASTDefType(tok(_token.T_UPPERID, type), constructorDeclarations);
13403
13483
  }
13404
13484
  }, {
@@ -13425,27 +13505,27 @@ var Runner = exports.Runner = function () {
13425
13505
  key: '_astConstructorDeclaration',
13426
13506
  value: function _astConstructorDeclaration(type, constructor) {
13427
13507
  var fields = [];
13428
- var _iteratorNormalCompletion5 = true;
13429
- var _didIteratorError5 = false;
13430
- var _iteratorError5 = undefined;
13508
+ var _iteratorNormalCompletion6 = true;
13509
+ var _didIteratorError6 = false;
13510
+ var _iteratorError6 = undefined;
13431
13511
 
13432
13512
  try {
13433
- for (var _iterator5 = this._primitives.constructorFields(type, constructor)[Symbol.iterator](), _step5; !(_iteratorNormalCompletion5 = (_step5 = _iterator5.next()).done); _iteratorNormalCompletion5 = true) {
13434
- var field = _step5.value;
13513
+ for (var _iterator6 = this._primitives.constructorFields(type, constructor)[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
13514
+ var field = _step6.value;
13435
13515
 
13436
13516
  fields.push(tok(_token.T_LOWERID, field));
13437
13517
  }
13438
13518
  } catch (err) {
13439
- _didIteratorError5 = true;
13440
- _iteratorError5 = err;
13519
+ _didIteratorError6 = true;
13520
+ _iteratorError6 = err;
13441
13521
  } finally {
13442
13522
  try {
13443
- if (!_iteratorNormalCompletion5 && _iterator5.return) {
13444
- _iterator5.return();
13523
+ if (!_iteratorNormalCompletion6 && _iterator6.return) {
13524
+ _iterator6.return();
13445
13525
  }
13446
13526
  } finally {
13447
- if (_didIteratorError5) {
13448
- throw _iteratorError5;
13527
+ if (_didIteratorError6) {
13528
+ throw _iteratorError6;
13449
13529
  }
13450
13530
  }
13451
13531
  }
@@ -13639,6 +13719,15 @@ var Parser = exports.Parser = function () {
13639
13719
  return new _ast.ASTMain(definitions);
13640
13720
  }
13641
13721
 
13722
+ /* Return the list of all language options collected by the tokenizer.
13723
+ * Language options are set by the LANGUAGE pragma. */
13724
+
13725
+ }, {
13726
+ key: 'getLanguageOptions',
13727
+ value: function getLanguageOptions() {
13728
+ return this._lexer.getLanguageOptions();
13729
+ }
13730
+
13642
13731
  /** Definitions **/
13643
13732
 
13644
13733
  }, {
@@ -13819,6 +13908,8 @@ var Parser = exports.Parser = function () {
13819
13908
  key: '_parsePureStatement',
13820
13909
  value: function _parsePureStatement() {
13821
13910
  switch (this._currentToken.tag) {
13911
+ case _token.T_ELLIPSIS:
13912
+ return this._parseStmtEllipsis();
13822
13913
  case _token.T_RETURN:
13823
13914
  return this._parseStmtReturn();
13824
13915
  case _token.T_IF:
@@ -13869,6 +13960,16 @@ var Parser = exports.Parser = function () {
13869
13960
  result.endPos = endPos;
13870
13961
  return result;
13871
13962
  }
13963
+ }, {
13964
+ key: '_parseStmtEllipsis',
13965
+ value: function _parseStmtEllipsis() {
13966
+ var startPos = this._currentToken.startPos;
13967
+ this._match(_token.T_ELLIPSIS);
13968
+ var result = new _ast.ASTStmtProcedureCall(new _token.Token(_token.T_UPPERID, (0, _i18n.i18n)('PRIM:BOOM'), startPos, startPos), [new _ast.ASTExprConstantString(new _token.Token(_token.T_STRING, (0, _i18n.i18n)('errmsg:ellipsis')))]);
13969
+ result.startPos = startPos;
13970
+ result.endPos = this._currentToken.startPos;
13971
+ return result;
13972
+ }
13872
13973
  }, {
13873
13974
  key: '_parseStmtReturn',
13874
13975
  value: function _parseStmtReturn() {
@@ -13935,11 +14036,11 @@ var Parser = exports.Parser = function () {
13935
14036
  value: function _parseStmtForeach() {
13936
14037
  var startPos = this._currentToken.startPos;
13937
14038
  this._match(_token.T_FOREACH);
13938
- var index = this._parseLowerid();
14039
+ var pattern = this._parsePattern();
13939
14040
  this._match(_token.T_IN);
13940
14041
  var range = this._parseExpression();
13941
14042
  var body = this._parseStmtBlock();
13942
- var result = new _ast.ASTStmtForeach(index, range, body);
14043
+ var result = new _ast.ASTStmtForeach(pattern, range, body);
13943
14044
  result.startPos = startPos;
13944
14045
  result.endPos = body.endPos;
13945
14046
  return result;
@@ -14048,6 +14149,8 @@ var Parser = exports.Parser = function () {
14048
14149
  switch (this._currentToken.tag) {
14049
14150
  case _token.T_UNDERSCORE:
14050
14151
  return this._parsePatternWildcard();
14152
+ case _token.T_LOWERID:
14153
+ return this._parsePatternVariable();
14051
14154
  case _token.T_NUM:case _token.T_MINUS:
14052
14155
  return this._parsePatternNumber();
14053
14156
  case _token.T_UPPERID:
@@ -14071,6 +14174,16 @@ var Parser = exports.Parser = function () {
14071
14174
  result.endPos = endPos;
14072
14175
  return result;
14073
14176
  }
14177
+ }, {
14178
+ key: '_parsePatternVariable',
14179
+ value: function _parsePatternVariable() {
14180
+ var startPos = this._currentToken.startPos;
14181
+ var id = this._parseLowerid();
14182
+ var result = new _ast.ASTPatternVariable(id);
14183
+ result.startPos = startPos;
14184
+ result.endPos = id.endPos;
14185
+ return result;
14186
+ }
14074
14187
  }, {
14075
14188
  key: '_parsePatternNumber',
14076
14189
  value: function _parsePatternNumber() {
@@ -14258,6 +14371,8 @@ var Parser = exports.Parser = function () {
14258
14371
  key: '_parseExprAtom',
14259
14372
  value: function _parseExprAtom() {
14260
14373
  switch (this._currentToken.tag) {
14374
+ case _token.T_ELLIPSIS:
14375
+ return this._parseExprEllipsis();
14261
14376
  case _token.T_LOWERID:
14262
14377
  return this._parseExprVariableOrFunctionCall();
14263
14378
  case _token.T_NUM:
@@ -14276,6 +14391,16 @@ var Parser = exports.Parser = function () {
14276
14391
  return fail(this._currentToken.startPos, this._currentToken.endPos, 'expected-but-found', [(0, _i18n.i18n)('expression'), (0, _i18n.i18n)(Symbol.keyFor(this._currentToken.tag))]);
14277
14392
  }
14278
14393
  }
14394
+ }, {
14395
+ key: '_parseExprEllipsis',
14396
+ value: function _parseExprEllipsis() {
14397
+ var startPos = this._currentToken.startPos;
14398
+ this._match(_token.T_ELLIPSIS);
14399
+ var result = new _ast.ASTExprFunctionCall(new _token.Token(_token.T_LOWERID, (0, _i18n.i18n)('PRIM:boom'), startPos, startPos), [new _ast.ASTExprConstantString(new _token.Token(_token.T_STRING, (0, _i18n.i18n)('errmsg:ellipsis')))]);
14400
+ result.startPos = startPos;
14401
+ result.endPos = this._currentToken.startPos;
14402
+ return result;
14403
+ }
14279
14404
  }, {
14280
14405
  key: '_parseExprVariableOrFunctionCall',
14281
14406
  value: function _parseExprVariableOrFunctionCall() {
@@ -14829,7 +14954,7 @@ KEYWORDS[(0, _i18n.i18n)('CONS:TIMEOUT')] = _token.T_TIMEOUT;
14829
14954
  var SYMBOLS = [
14830
14955
  /* Various delimiters */
14831
14956
  ['(', _token.T_LPAREN], [')', _token.T_RPAREN], ['{', _token.T_LBRACE], ['}', _token.T_RBRACE], ['[', _token.T_LBRACK], // For lists and ranges
14832
- [']', _token.T_RBRACK], [',', _token.T_COMMA], [';', _token.T_SEMICOLON],
14957
+ [']', _token.T_RBRACK], [',', _token.T_COMMA], [';', _token.T_SEMICOLON], ['...', _token.T_ELLIPSIS], // For intentionally incomplete programs
14833
14958
  /* Range operator */
14834
14959
  ['..', _token.T_RANGE],
14835
14960
  /* Assignment */
@@ -14846,6 +14971,9 @@ var SYMBOLS = [
14846
14971
  /* Functions */
14847
14972
  ['++', _token.T_CONCAT], ['+', _token.T_PLUS], ['-', _token.T_MINUS], ['*', _token.T_TIMES], ['^', _token.T_POW]];
14848
14973
 
14974
+ /* Valid language options accepted by the LANGUAGE pragma */
14975
+ var LANGUAGE_OPTIONS = ['DestructuringForeach'];
14976
+
14849
14977
  function leadingZeroes(string) {
14850
14978
  return string.length >= 0 && string[0] === '0';
14851
14979
  }
@@ -14890,6 +15018,12 @@ var Lexer = exports.Lexer = function () {
14890
15018
  * Pending attributes are used by the parser to decorate any procedure
14891
15019
  * or function definition. */
14892
15020
  this._pendingAttributes = {};
15021
+
15022
+ /* A list of language options, enabled by the LANGUAGE pragma.
15023
+ * Language options are interpreted by the runner to initialize.
15024
+ * the remaining modules (linter, compiler, runtime, ...)
15025
+ * accordingly. */
15026
+ this._languageOptions = [];
14893
15027
  }
14894
15028
 
14895
15029
  /* Return the next token from the input */
@@ -15217,6 +15351,9 @@ var Lexer = exports.Lexer = function () {
15217
15351
  var key = pragma[1];
15218
15352
  var value = pragma.slice(2, pragma.length).join('@');
15219
15353
  this.setAttribute(key, value);
15354
+ } else if (pragma[0] === 'LANGUAGE' && pragma.length === 2) {
15355
+ var languageOption = pragma[1];
15356
+ this.addLanguageOption(languageOption);
15220
15357
  } else {
15221
15358
  this._emitWarning(startPos, this._reader, 'unknown-pragma', [pragma[0]]);
15222
15359
  }
@@ -15275,6 +15412,30 @@ var Lexer = exports.Lexer = function () {
15275
15412
  value: function setAttribute(key, value) {
15276
15413
  this._pendingAttributes[key] = value;
15277
15414
  }
15415
+
15416
+ /*
15417
+ * Interface for handling language options.
15418
+ *
15419
+ * The pragma LANGUAGE@option sets the given option.
15420
+ *
15421
+ * The runner module reads these options to initialize the
15422
+ * linter/compiler/runtime.
15423
+ */
15424
+
15425
+ }, {
15426
+ key: 'getLanguageOptions',
15427
+ value: function getLanguageOptions() {
15428
+ return this._languageOptions;
15429
+ }
15430
+ }, {
15431
+ key: 'addLanguageOption',
15432
+ value: function addLanguageOption(option) {
15433
+ if (LANGUAGE_OPTIONS.indexOf(option) !== -1) {
15434
+ this._languageOptions.push(option);
15435
+ } else {
15436
+ fail(this._reader, this._reader, 'unknown-language-option', [option]);
15437
+ }
15438
+ }
15278
15439
  }]);
15279
15440
 
15280
15441
  return Lexer;
@@ -15343,17 +15504,20 @@ var Linter = exports.Linter = function () {
15343
15504
  * If a check is disabled, it does not produce a syntax error.
15344
15505
  */
15345
15506
  this._enabledLinterChecks = {
15507
+ // Linter options
15346
15508
  'source-should-have-a-program-definition': true,
15347
15509
  'procedure-should-not-have-return': true,
15348
15510
  'function-should-have-return': true,
15349
15511
  'return-statement-not-allowed-here': true,
15350
15512
  'wildcard-pattern-should-be-last': true,
15513
+ 'variable-pattern-should-be-last': true,
15351
15514
  'structure-pattern-repeats-constructor': true,
15352
15515
  'structure-pattern-repeats-tuple-arity': true,
15353
15516
  'structure-pattern-repeats-timeout': true,
15354
15517
  'pattern-does-not-match-type': true,
15355
15518
  'patterns-in-interactive-program-must-be-events': true,
15356
15519
  'patterns-in-switch-must-not-be-events': true,
15520
+ 'patterns-in-foreach-must-not-be-events': true,
15357
15521
  'repeated-variable-in-tuple-assignment': true,
15358
15522
  'constructor-used-as-procedure': true,
15359
15523
  'undefined-procedure': true,
@@ -15368,7 +15532,9 @@ var Linter = exports.Linter = function () {
15368
15532
  'function-arity-mismatch': true,
15369
15533
  'type-used-as-constructor': true,
15370
15534
  'procedure-used-as-constructor': true,
15371
- 'undeclared-constructor': true
15535
+ 'undeclared-constructor': true,
15536
+ // Extensions
15537
+ 'forbidden-extension-destructuring-foreach': true
15372
15538
  };
15373
15539
  }
15374
15540
 
@@ -15694,37 +15860,17 @@ var Linter = exports.Linter = function () {
15694
15860
  }, {
15695
15861
  key: '_lintStmtForeach',
15696
15862
  value: function _lintStmtForeach(statement) {
15863
+ this._lintStmtForeachPattern(statement.pattern);
15697
15864
  this._lintExpression(statement.range);
15698
- this._symtable.addNewLocalName(statement.index, _symtable.LocalIndex);
15699
- this._lintStatement(statement.body);
15700
- this._symtable.removeLocalName(statement.index);
15701
- }
15702
- }, {
15703
- key: '_lintStmtWhile',
15704
- value: function _lintStmtWhile(statement) {
15705
- this._lintExpression(statement.condition);
15706
- this._lintStatement(statement.body);
15707
- }
15708
- }, {
15709
- key: '_lintStmtSwitch',
15710
- value: function _lintStmtSwitch(statement) {
15711
- this._lintExpression(statement.subject);
15712
- this._lintSwitchBranches(statement.branches, false /* !isInteractiveProgram */
15713
- );
15714
- }
15715
- }, {
15716
- key: '_lintSwitchBranches',
15717
- value: function _lintSwitchBranches(branches, isInteractiveProgram) {
15718
- /* Check that each pattern is well-formed */
15719
15865
  var _iteratorNormalCompletion6 = true;
15720
15866
  var _didIteratorError6 = false;
15721
15867
  var _iteratorError6 = undefined;
15722
15868
 
15723
15869
  try {
15724
- for (var _iterator6 = branches[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
15725
- var branch = _step6.value;
15870
+ for (var _iterator6 = statement.pattern.boundVariables[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
15871
+ var variable = _step6.value;
15726
15872
 
15727
- this._lintPattern(branch.pattern);
15873
+ this._symtable.addNewLocalName(variable, _symtable.LocalIndex);
15728
15874
  }
15729
15875
  } catch (err) {
15730
15876
  _didIteratorError6 = true;
@@ -15741,25 +15887,16 @@ var Linter = exports.Linter = function () {
15741
15887
  }
15742
15888
  }
15743
15889
 
15744
- this._switchBranchesCheckWildcard(branches);
15745
- this._switchBranchesCheckNoRepeats(branches);
15746
- this._switchBranchesCheckCompatible(branches);
15747
- if (isInteractiveProgram) {
15748
- this._switchBranchesCheckTypeEvent(branches);
15749
- } else {
15750
- this._switchBranchesCheckTypeNotEvent(branches);
15751
- }
15752
-
15753
- /* Lint recursively each branch */
15890
+ this._lintStatement(statement.body);
15754
15891
  var _iteratorNormalCompletion7 = true;
15755
15892
  var _didIteratorError7 = false;
15756
15893
  var _iteratorError7 = undefined;
15757
15894
 
15758
15895
  try {
15759
- for (var _iterator7 = branches[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
15760
- var _branch = _step7.value;
15896
+ for (var _iterator7 = statement.pattern.boundVariables[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
15897
+ var _variable = _step7.value;
15761
15898
 
15762
- this._lintSwitchBranchBody(_branch);
15899
+ this._symtable.removeLocalName(_variable);
15763
15900
  }
15764
15901
  } catch (err) {
15765
15902
  _didIteratorError7 = true;
@@ -15776,14 +15913,41 @@ var Linter = exports.Linter = function () {
15776
15913
  }
15777
15914
  }
15778
15915
  }
15916
+ }, {
15917
+ key: '_lintStmtForeachPattern',
15918
+ value: function _lintStmtForeachPattern(pattern) {
15919
+ /* If "DestructuringForeach" is disabled, forbid complex patterns.
15920
+ * Allow only variable patterns (indices). */
15921
+ if (pattern.tag !== _ast.N_PatternVariable) {
15922
+ this._lintCheck(pattern.startPos, pattern.endPos, 'forbidden-extension-destructuring-foreach', []);
15923
+ }
15779
15924
 
15780
- /* Check that there is at most one wildcard at the end */
15925
+ /* Check that the pattern itself is well-formed */
15926
+ this._lintPattern(pattern);
15781
15927
 
15928
+ /* The pattern in a foreach cannot be an event */
15929
+ var patternType = this._patternType(pattern);
15930
+ if (patternType === (0, _i18n.i18n)('TYPE:Event')) {
15931
+ this._lintCheck(pattern.startPos, pattern.endPos, 'patterns-in-foreach-must-not-be-events', []);
15932
+ }
15933
+ }
15782
15934
  }, {
15783
- key: '_switchBranchesCheckWildcard',
15784
- value: function _switchBranchesCheckWildcard(branches) {
15785
- var i = 0;
15786
- var n = branches.length;
15935
+ key: '_lintStmtWhile',
15936
+ value: function _lintStmtWhile(statement) {
15937
+ this._lintExpression(statement.condition);
15938
+ this._lintStatement(statement.body);
15939
+ }
15940
+ }, {
15941
+ key: '_lintStmtSwitch',
15942
+ value: function _lintStmtSwitch(statement) {
15943
+ this._lintExpression(statement.subject);
15944
+ this._lintSwitchBranches(statement.branches, false /* !isInteractiveProgram */
15945
+ );
15946
+ }
15947
+ }, {
15948
+ key: '_lintSwitchBranches',
15949
+ value: function _lintSwitchBranches(branches, isInteractiveProgram) {
15950
+ /* Check that each pattern is well-formed */
15787
15951
  var _iteratorNormalCompletion8 = true;
15788
15952
  var _didIteratorError8 = false;
15789
15953
  var _iteratorError8 = undefined;
@@ -15792,11 +15956,7 @@ var Linter = exports.Linter = function () {
15792
15956
  for (var _iterator8 = branches[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
15793
15957
  var branch = _step8.value;
15794
15958
 
15795
- if (branch.pattern.tag === _ast.N_PatternWildcard && i !== n - 1) {
15796
-
15797
- this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'wildcard-pattern-should-be-last', []);
15798
- }
15799
- i++;
15959
+ this._lintPattern(branch.pattern);
15800
15960
  }
15801
15961
  } catch (err) {
15802
15962
  _didIteratorError8 = true;
@@ -15812,60 +15972,26 @@ var Linter = exports.Linter = function () {
15812
15972
  }
15813
15973
  }
15814
15974
  }
15815
- }
15816
15975
 
15817
- /* Check that there are no repeated constructors in a sequence
15818
- * of branches. */
15976
+ this._switchBranchesCheckWildcardAndVariable(branches);
15977
+ this._switchBranchesCheckNoRepeats(branches);
15978
+ this._switchBranchesCheckCompatible(branches);
15979
+ if (isInteractiveProgram) {
15980
+ this._switchBranchesCheckTypeEvent(branches);
15981
+ } else {
15982
+ this._switchBranchesCheckTypeNotEvent(branches);
15983
+ }
15819
15984
 
15820
- }, {
15821
- key: '_switchBranchesCheckNoRepeats',
15822
- value: function _switchBranchesCheckNoRepeats(branches) {
15823
- var coveredNumbers = {};
15824
- var coveredConstructors = {};
15825
- var coveredTuples = {};
15826
- var coveredTimeout = false;
15985
+ /* Lint recursively each branch */
15827
15986
  var _iteratorNormalCompletion9 = true;
15828
15987
  var _didIteratorError9 = false;
15829
15988
  var _iteratorError9 = undefined;
15830
15989
 
15831
15990
  try {
15832
15991
  for (var _iterator9 = branches[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
15833
- var branch = _step9.value;
15992
+ var _branch = _step9.value;
15834
15993
 
15835
- switch (branch.pattern.tag) {
15836
- case _ast.N_PatternWildcard:
15837
- /* Already checked in _switchBranchesCheckWildcard */
15838
- break;
15839
- case _ast.N_PatternNumber:
15840
- var number = branch.pattern.number.value;
15841
- if (number in coveredNumbers) {
15842
- this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'numeric-pattern-repeats-number', [number]);
15843
- }
15844
- coveredNumbers[number] = true;
15845
- break;
15846
- case _ast.N_PatternStructure:
15847
- var constructorName = branch.pattern.constructorName.value;
15848
- if (constructorName in coveredConstructors) {
15849
- this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'structure-pattern-repeats-constructor', [constructorName]);
15850
- }
15851
- coveredConstructors[constructorName] = true;
15852
- break;
15853
- case _ast.N_PatternTuple:
15854
- var arity = branch.pattern.parameters.length;
15855
- if (arity in coveredTuples) {
15856
- this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'structure-pattern-repeats-tuple-arity', [arity]);
15857
- }
15858
- coveredTuples[arity] = true;
15859
- break;
15860
- case _ast.N_PatternTimeout:
15861
- if (coveredTimeout) {
15862
- this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'structure-pattern-repeats-timeout', []);
15863
- }
15864
- coveredTimeout = true;
15865
- break;
15866
- default:
15867
- throw Error('Linter: pattern "' + Symbol.keyFor(branch.pattern.tag) + '" not implemented.');
15868
- }
15994
+ this._lintSwitchBranchBody(_branch);
15869
15995
  }
15870
15996
  } catch (err) {
15871
15997
  _didIteratorError9 = true;
@@ -15883,13 +16009,13 @@ var Linter = exports.Linter = function () {
15883
16009
  }
15884
16010
  }
15885
16011
 
15886
- /* Check that constructors are compatible,
15887
- * i.e. that they belong to the same type */
16012
+ /* Check that there is at most one wildcard/variable pattern at the end */
15888
16013
 
15889
16014
  }, {
15890
- key: '_switchBranchesCheckCompatible',
15891
- value: function _switchBranchesCheckCompatible(branches) {
15892
- var expectedType = null;
16015
+ key: '_switchBranchesCheckWildcardAndVariable',
16016
+ value: function _switchBranchesCheckWildcardAndVariable(branches) {
16017
+ var i = 0;
16018
+ var n = branches.length;
15893
16019
  var _iteratorNormalCompletion10 = true;
15894
16020
  var _didIteratorError10 = false;
15895
16021
  var _iteratorError10 = undefined;
@@ -15898,12 +16024,13 @@ var Linter = exports.Linter = function () {
15898
16024
  for (var _iterator10 = branches[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
15899
16025
  var branch = _step10.value;
15900
16026
 
15901
- var patternType = this._patternType(branch.pattern);
15902
- if (expectedType === null) {
15903
- expectedType = patternType;
15904
- } else if (patternType !== null && expectedType !== patternType) {
15905
- this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'pattern-does-not-match-type', [(0, _i18n.i18n)('<pattern-type>')(expectedType), (0, _i18n.i18n)('<pattern-type>')(patternType)]);
16027
+ if (branch.pattern.tag === _ast.N_PatternWildcard && i !== n - 1) {
16028
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'wildcard-pattern-should-be-last', []);
16029
+ }
16030
+ if (branch.pattern.tag === _ast.N_PatternVariable && i !== n - 1) {
16031
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'variable-pattern-should-be-last', [branch.pattern.variableName.value]);
15906
16032
  }
16033
+ i++;
15907
16034
  }
15908
16035
  } catch (err) {
15909
16036
  _didIteratorError10 = true;
@@ -15921,11 +16048,16 @@ var Linter = exports.Linter = function () {
15921
16048
  }
15922
16049
  }
15923
16050
 
15924
- /* Check that there are patterns are of type Event */
16051
+ /* Check that there are no repeated constructors in a sequence
16052
+ * of branches. */
15925
16053
 
15926
16054
  }, {
15927
- key: '_switchBranchesCheckTypeEvent',
15928
- value: function _switchBranchesCheckTypeEvent(branches) {
16055
+ key: '_switchBranchesCheckNoRepeats',
16056
+ value: function _switchBranchesCheckNoRepeats(branches) {
16057
+ var coveredNumbers = {};
16058
+ var coveredConstructors = {};
16059
+ var coveredTuples = {};
16060
+ var coveredTimeout = false;
15929
16061
  var _iteratorNormalCompletion11 = true;
15930
16062
  var _didIteratorError11 = false;
15931
16063
  var _iteratorError11 = undefined;
@@ -15934,9 +16066,39 @@ var Linter = exports.Linter = function () {
15934
16066
  for (var _iterator11 = branches[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
15935
16067
  var branch = _step11.value;
15936
16068
 
15937
- var patternType = this._patternType(branch.pattern);
15938
- if (patternType !== null && patternType !== (0, _i18n.i18n)('TYPE:Event')) {
15939
- this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'patterns-in-interactive-program-must-be-events', []);
16069
+ switch (branch.pattern.tag) {
16070
+ case _ast.N_PatternWildcard:case _ast.N_PatternVariable:
16071
+ /* Already checked in _switchBranchesCheckWildcardAndVariable */
16072
+ break;
16073
+ case _ast.N_PatternNumber:
16074
+ var number = branch.pattern.number.value;
16075
+ if (number in coveredNumbers) {
16076
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'numeric-pattern-repeats-number', [number]);
16077
+ }
16078
+ coveredNumbers[number] = true;
16079
+ break;
16080
+ case _ast.N_PatternStructure:
16081
+ var constructorName = branch.pattern.constructorName.value;
16082
+ if (constructorName in coveredConstructors) {
16083
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'structure-pattern-repeats-constructor', [constructorName]);
16084
+ }
16085
+ coveredConstructors[constructorName] = true;
16086
+ break;
16087
+ case _ast.N_PatternTuple:
16088
+ var arity = branch.pattern.boundVariables.length;
16089
+ if (arity in coveredTuples) {
16090
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'structure-pattern-repeats-tuple-arity', [arity]);
16091
+ }
16092
+ coveredTuples[arity] = true;
16093
+ break;
16094
+ case _ast.N_PatternTimeout:
16095
+ if (coveredTimeout) {
16096
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'structure-pattern-repeats-timeout', []);
16097
+ }
16098
+ coveredTimeout = true;
16099
+ break;
16100
+ default:
16101
+ throw Error('Linter: pattern "' + Symbol.keyFor(branch.pattern.tag) + '" not implemented.');
15940
16102
  }
15941
16103
  }
15942
16104
  } catch (err) {
@@ -15955,11 +16117,13 @@ var Linter = exports.Linter = function () {
15955
16117
  }
15956
16118
  }
15957
16119
 
15958
- /* Check that there are no patterns of type Event */
16120
+ /* Check that constructors are compatible,
16121
+ * i.e. that they belong to the same type */
15959
16122
 
15960
16123
  }, {
15961
- key: '_switchBranchesCheckTypeNotEvent',
15962
- value: function _switchBranchesCheckTypeNotEvent(branches) {
16124
+ key: '_switchBranchesCheckCompatible',
16125
+ value: function _switchBranchesCheckCompatible(branches) {
16126
+ var expectedType = null;
15963
16127
  var _iteratorNormalCompletion12 = true;
15964
16128
  var _didIteratorError12 = false;
15965
16129
  var _iteratorError12 = undefined;
@@ -15969,8 +16133,10 @@ var Linter = exports.Linter = function () {
15969
16133
  var branch = _step12.value;
15970
16134
 
15971
16135
  var patternType = this._patternType(branch.pattern);
15972
- if (patternType === (0, _i18n.i18n)('TYPE:Event')) {
15973
- this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'patterns-in-switch-must-not-be-events', []);
16136
+ if (expectedType === null) {
16137
+ expectedType = patternType;
16138
+ } else if (patternType !== null && expectedType !== patternType) {
16139
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'pattern-does-not-match-type', [(0, _i18n.i18n)('<pattern-type>')(expectedType), (0, _i18n.i18n)('<pattern-type>')(patternType)]);
15974
16140
  }
15975
16141
  }
15976
16142
  } catch (err) {
@@ -15989,20 +16155,23 @@ var Linter = exports.Linter = function () {
15989
16155
  }
15990
16156
  }
15991
16157
 
15992
- /* Recursively lint the body of each branch. Locally bind parameters. */
16158
+ /* Check that there are patterns are of type Event */
15993
16159
 
15994
16160
  }, {
15995
- key: '_lintSwitchBranchBody',
15996
- value: function _lintSwitchBranchBody(branch) {
16161
+ key: '_switchBranchesCheckTypeEvent',
16162
+ value: function _switchBranchesCheckTypeEvent(branches) {
15997
16163
  var _iteratorNormalCompletion13 = true;
15998
16164
  var _didIteratorError13 = false;
15999
16165
  var _iteratorError13 = undefined;
16000
16166
 
16001
16167
  try {
16002
- for (var _iterator13 = branch.pattern.parameters[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
16003
- var parameter = _step13.value;
16168
+ for (var _iterator13 = branches[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
16169
+ var branch = _step13.value;
16004
16170
 
16005
- this._symtable.addNewLocalName(parameter, _symtable.LocalParameter);
16171
+ var patternType = this._patternType(branch.pattern);
16172
+ if (patternType !== null && patternType !== (0, _i18n.i18n)('TYPE:Event')) {
16173
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'patterns-in-interactive-program-must-be-events', []);
16174
+ }
16006
16175
  }
16007
16176
  } catch (err) {
16008
16177
  _didIteratorError13 = true;
@@ -16018,17 +16187,25 @@ var Linter = exports.Linter = function () {
16018
16187
  }
16019
16188
  }
16020
16189
  }
16190
+ }
16021
16191
 
16022
- this._lintStatement(branch.body);
16192
+ /* Check that there are no patterns of type Event */
16193
+
16194
+ }, {
16195
+ key: '_switchBranchesCheckTypeNotEvent',
16196
+ value: function _switchBranchesCheckTypeNotEvent(branches) {
16023
16197
  var _iteratorNormalCompletion14 = true;
16024
16198
  var _didIteratorError14 = false;
16025
16199
  var _iteratorError14 = undefined;
16026
16200
 
16027
16201
  try {
16028
- for (var _iterator14 = branch.pattern.parameters[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
16029
- var _parameter = _step14.value;
16202
+ for (var _iterator14 = branches[Symbol.iterator](), _step14; !(_iteratorNormalCompletion14 = (_step14 = _iterator14.next()).done); _iteratorNormalCompletion14 = true) {
16203
+ var branch = _step14.value;
16030
16204
 
16031
- this._symtable.removeLocalName(_parameter);
16205
+ var patternType = this._patternType(branch.pattern);
16206
+ if (patternType === (0, _i18n.i18n)('TYPE:Event')) {
16207
+ this._lintCheck(branch.pattern.startPos, branch.pattern.endPos, 'patterns-in-switch-must-not-be-events', []);
16208
+ }
16032
16209
  }
16033
16210
  } catch (err) {
16034
16211
  _didIteratorError14 = true;
@@ -16046,20 +16223,77 @@ var Linter = exports.Linter = function () {
16046
16223
  }
16047
16224
  }
16048
16225
 
16226
+ /* Recursively lint the body of each branch. Locally bind variables. */
16227
+
16228
+ }, {
16229
+ key: '_lintSwitchBranchBody',
16230
+ value: function _lintSwitchBranchBody(branch) {
16231
+ var _iteratorNormalCompletion15 = true;
16232
+ var _didIteratorError15 = false;
16233
+ var _iteratorError15 = undefined;
16234
+
16235
+ try {
16236
+ for (var _iterator15 = branch.pattern.boundVariables[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
16237
+ var variable = _step15.value;
16238
+
16239
+ this._symtable.addNewLocalName(variable, _symtable.LocalParameter);
16240
+ }
16241
+ } catch (err) {
16242
+ _didIteratorError15 = true;
16243
+ _iteratorError15 = err;
16244
+ } finally {
16245
+ try {
16246
+ if (!_iteratorNormalCompletion15 && _iterator15.return) {
16247
+ _iterator15.return();
16248
+ }
16249
+ } finally {
16250
+ if (_didIteratorError15) {
16251
+ throw _iteratorError15;
16252
+ }
16253
+ }
16254
+ }
16255
+
16256
+ this._lintStatement(branch.body);
16257
+ var _iteratorNormalCompletion16 = true;
16258
+ var _didIteratorError16 = false;
16259
+ var _iteratorError16 = undefined;
16260
+
16261
+ try {
16262
+ for (var _iterator16 = branch.pattern.boundVariables[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {
16263
+ var _variable2 = _step16.value;
16264
+
16265
+ this._symtable.removeLocalName(_variable2);
16266
+ }
16267
+ } catch (err) {
16268
+ _didIteratorError16 = true;
16269
+ _iteratorError16 = err;
16270
+ } finally {
16271
+ try {
16272
+ if (!_iteratorNormalCompletion16 && _iterator16.return) {
16273
+ _iterator16.return();
16274
+ }
16275
+ } finally {
16276
+ if (_didIteratorError16) {
16277
+ throw _iteratorError16;
16278
+ }
16279
+ }
16280
+ }
16281
+ }
16282
+
16049
16283
  /* Return a description of the type of a pattern */
16050
16284
 
16051
16285
  }, {
16052
16286
  key: '_patternType',
16053
16287
  value: function _patternType(pattern) {
16054
16288
  switch (pattern.tag) {
16055
- case _ast.N_PatternWildcard:
16289
+ case _ast.N_PatternWildcard:case _ast.N_PatternVariable:
16056
16290
  return null;
16057
16291
  case _ast.N_PatternNumber:
16058
16292
  return (0, _i18n.i18n)('TYPE:Integer');
16059
16293
  case _ast.N_PatternStructure:
16060
16294
  return this._symtable.constructorType(pattern.constructorName.value);
16061
16295
  case _ast.N_PatternTuple:
16062
- return '_TUPLE_' + pattern.parameters.length.toString();
16296
+ return '_TUPLE_' + pattern.boundVariables.length.toString();
16063
16297
  case _ast.N_PatternTimeout:
16064
16298
  return (0, _i18n.i18n)('TYPE:Event');
16065
16299
  default:
@@ -16076,13 +16310,13 @@ var Linter = exports.Linter = function () {
16076
16310
  key: '_lintStmtAssignTuple',
16077
16311
  value: function _lintStmtAssignTuple(statement) {
16078
16312
  var variables = {};
16079
- var _iteratorNormalCompletion15 = true;
16080
- var _didIteratorError15 = false;
16081
- var _iteratorError15 = undefined;
16313
+ var _iteratorNormalCompletion17 = true;
16314
+ var _didIteratorError17 = false;
16315
+ var _iteratorError17 = undefined;
16082
16316
 
16083
16317
  try {
16084
- for (var _iterator15 = statement.variables[Symbol.iterator](), _step15; !(_iteratorNormalCompletion15 = (_step15 = _iterator15.next()).done); _iteratorNormalCompletion15 = true) {
16085
- var variable = _step15.value;
16318
+ for (var _iterator17 = statement.variables[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {
16319
+ var variable = _step17.value;
16086
16320
 
16087
16321
  this._symtable.setLocalName(variable, _symtable.LocalVariable);
16088
16322
  if (variable.value in variables) {
@@ -16091,16 +16325,16 @@ var Linter = exports.Linter = function () {
16091
16325
  variables[variable.value] = true;
16092
16326
  }
16093
16327
  } catch (err) {
16094
- _didIteratorError15 = true;
16095
- _iteratorError15 = err;
16328
+ _didIteratorError17 = true;
16329
+ _iteratorError17 = err;
16096
16330
  } finally {
16097
16331
  try {
16098
- if (!_iteratorNormalCompletion15 && _iterator15.return) {
16099
- _iterator15.return();
16332
+ if (!_iteratorNormalCompletion17 && _iterator17.return) {
16333
+ _iterator17.return();
16100
16334
  }
16101
16335
  } finally {
16102
- if (_didIteratorError15) {
16103
- throw _iteratorError15;
16336
+ if (_didIteratorError17) {
16337
+ throw _iteratorError17;
16104
16338
  }
16105
16339
  }
16106
16340
  }
@@ -16129,27 +16363,27 @@ var Linter = exports.Linter = function () {
16129
16363
  }
16130
16364
 
16131
16365
  /* Check all the arguments */
16132
- var _iteratorNormalCompletion16 = true;
16133
- var _didIteratorError16 = false;
16134
- var _iteratorError16 = undefined;
16366
+ var _iteratorNormalCompletion18 = true;
16367
+ var _didIteratorError18 = false;
16368
+ var _iteratorError18 = undefined;
16135
16369
 
16136
16370
  try {
16137
- for (var _iterator16 = statement.args[Symbol.iterator](), _step16; !(_iteratorNormalCompletion16 = (_step16 = _iterator16.next()).done); _iteratorNormalCompletion16 = true) {
16138
- var argument = _step16.value;
16371
+ for (var _iterator18 = statement.args[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {
16372
+ var argument = _step18.value;
16139
16373
 
16140
16374
  this._lintExpression(argument);
16141
16375
  }
16142
16376
  } catch (err) {
16143
- _didIteratorError16 = true;
16144
- _iteratorError16 = err;
16377
+ _didIteratorError18 = true;
16378
+ _iteratorError18 = err;
16145
16379
  } finally {
16146
16380
  try {
16147
- if (!_iteratorNormalCompletion16 && _iterator16.return) {
16148
- _iterator16.return();
16381
+ if (!_iteratorNormalCompletion18 && _iterator18.return) {
16382
+ _iterator18.return();
16149
16383
  }
16150
16384
  } finally {
16151
- if (_didIteratorError16) {
16152
- throw _iteratorError16;
16385
+ if (_didIteratorError18) {
16386
+ throw _iteratorError18;
16153
16387
  }
16154
16388
  }
16155
16389
  }
@@ -16163,6 +16397,8 @@ var Linter = exports.Linter = function () {
16163
16397
  switch (pattern.tag) {
16164
16398
  case _ast.N_PatternWildcard:
16165
16399
  return this._lintPatternWildcard(pattern);
16400
+ case _ast.N_PatternVariable:
16401
+ return this._lintPatternVariable(pattern);
16166
16402
  case _ast.N_PatternNumber:
16167
16403
  return this._lintPatternNumber(pattern);
16168
16404
  case _ast.N_PatternStructure:
@@ -16180,6 +16416,11 @@ var Linter = exports.Linter = function () {
16180
16416
  value: function _lintPatternWildcard(pattern) {
16181
16417
  /* No restrictions */
16182
16418
  }
16419
+ }, {
16420
+ key: '_lintPatternVariable',
16421
+ value: function _lintPatternVariable(pattern) {
16422
+ /* No restrictions */
16423
+ }
16183
16424
  }, {
16184
16425
  key: '_lintPatternNumber',
16185
16426
  value: function _lintPatternNumber(pattern) {
@@ -16201,7 +16442,7 @@ var Linter = exports.Linter = function () {
16201
16442
  * Note: constructor patterns with 0 arguments are always allowed.
16202
16443
  */
16203
16444
  var expected = this._symtable.constructorFields(name).length;
16204
- var received = pattern.parameters.length;
16445
+ var received = pattern.boundVariables.length;
16205
16446
  if (received > 0 && expected !== received) {
16206
16447
  this._lintCheck(pattern.startPos, pattern.endPos, 'structure-pattern-arity-mismatch', [name, expected, received]);
16207
16448
  }
@@ -16274,27 +16515,27 @@ var Linter = exports.Linter = function () {
16274
16515
  }, {
16275
16516
  key: '_lintExprList',
16276
16517
  value: function _lintExprList(expression) {
16277
- var _iteratorNormalCompletion17 = true;
16278
- var _didIteratorError17 = false;
16279
- var _iteratorError17 = undefined;
16518
+ var _iteratorNormalCompletion19 = true;
16519
+ var _didIteratorError19 = false;
16520
+ var _iteratorError19 = undefined;
16280
16521
 
16281
16522
  try {
16282
- for (var _iterator17 = expression.elements[Symbol.iterator](), _step17; !(_iteratorNormalCompletion17 = (_step17 = _iterator17.next()).done); _iteratorNormalCompletion17 = true) {
16283
- var element = _step17.value;
16523
+ for (var _iterator19 = expression.elements[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {
16524
+ var element = _step19.value;
16284
16525
 
16285
16526
  this._lintExpression(element);
16286
16527
  }
16287
16528
  } catch (err) {
16288
- _didIteratorError17 = true;
16289
- _iteratorError17 = err;
16529
+ _didIteratorError19 = true;
16530
+ _iteratorError19 = err;
16290
16531
  } finally {
16291
16532
  try {
16292
- if (!_iteratorNormalCompletion17 && _iterator17.return) {
16293
- _iterator17.return();
16533
+ if (!_iteratorNormalCompletion19 && _iterator19.return) {
16534
+ _iterator19.return();
16294
16535
  }
16295
16536
  } finally {
16296
- if (_didIteratorError17) {
16297
- throw _iteratorError17;
16537
+ if (_didIteratorError19) {
16538
+ throw _iteratorError19;
16298
16539
  }
16299
16540
  }
16300
16541
  }
@@ -16311,27 +16552,27 @@ var Linter = exports.Linter = function () {
16311
16552
  }, {
16312
16553
  key: '_lintExprTuple',
16313
16554
  value: function _lintExprTuple(expression) {
16314
- var _iteratorNormalCompletion18 = true;
16315
- var _didIteratorError18 = false;
16316
- var _iteratorError18 = undefined;
16555
+ var _iteratorNormalCompletion20 = true;
16556
+ var _didIteratorError20 = false;
16557
+ var _iteratorError20 = undefined;
16317
16558
 
16318
16559
  try {
16319
- for (var _iterator18 = expression.elements[Symbol.iterator](), _step18; !(_iteratorNormalCompletion18 = (_step18 = _iterator18.next()).done); _iteratorNormalCompletion18 = true) {
16320
- var element = _step18.value;
16560
+ for (var _iterator20 = expression.elements[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {
16561
+ var element = _step20.value;
16321
16562
 
16322
16563
  this._lintExpression(element);
16323
16564
  }
16324
16565
  } catch (err) {
16325
- _didIteratorError18 = true;
16326
- _iteratorError18 = err;
16566
+ _didIteratorError20 = true;
16567
+ _iteratorError20 = err;
16327
16568
  } finally {
16328
16569
  try {
16329
- if (!_iteratorNormalCompletion18 && _iterator18.return) {
16330
- _iterator18.return();
16570
+ if (!_iteratorNormalCompletion20 && _iterator20.return) {
16571
+ _iterator20.return();
16331
16572
  }
16332
16573
  } finally {
16333
- if (_didIteratorError18) {
16334
- throw _iteratorError18;
16574
+ if (_didIteratorError20) {
16575
+ throw _iteratorError20;
16335
16576
  }
16336
16577
  }
16337
16578
  }
@@ -16380,27 +16621,27 @@ var Linter = exports.Linter = function () {
16380
16621
  }
16381
16622
 
16382
16623
  /* Recursively check expressions in field bindings */
16383
- var _iteratorNormalCompletion19 = true;
16384
- var _didIteratorError19 = false;
16385
- var _iteratorError19 = undefined;
16624
+ var _iteratorNormalCompletion21 = true;
16625
+ var _didIteratorError21 = false;
16626
+ var _iteratorError21 = undefined;
16386
16627
 
16387
16628
  try {
16388
- for (var _iterator19 = expression.fieldBindings[Symbol.iterator](), _step19; !(_iteratorNormalCompletion19 = (_step19 = _iterator19.next()).done); _iteratorNormalCompletion19 = true) {
16389
- var fieldBinding = _step19.value;
16629
+ for (var _iterator21 = expression.fieldBindings[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {
16630
+ var fieldBinding = _step21.value;
16390
16631
 
16391
16632
  this._lintExpression(fieldBinding.value);
16392
16633
  }
16393
16634
  } catch (err) {
16394
- _didIteratorError19 = true;
16395
- _iteratorError19 = err;
16635
+ _didIteratorError21 = true;
16636
+ _iteratorError21 = err;
16396
16637
  } finally {
16397
16638
  try {
16398
- if (!_iteratorNormalCompletion19 && _iterator19.return) {
16399
- _iterator19.return();
16639
+ if (!_iteratorNormalCompletion21 && _iterator21.return) {
16640
+ _iterator21.return();
16400
16641
  }
16401
16642
  } finally {
16402
- if (_didIteratorError19) {
16403
- throw _iteratorError19;
16643
+ if (_didIteratorError21) {
16644
+ throw _iteratorError21;
16404
16645
  }
16405
16646
  }
16406
16647
  }
@@ -16414,13 +16655,13 @@ var Linter = exports.Linter = function () {
16414
16655
  value: function _checkStructureNoRepeatedFields(constructorName, expression) {
16415
16656
  var declaredFields = expression.fieldNames();
16416
16657
  var seen = {};
16417
- var _iteratorNormalCompletion20 = true;
16418
- var _didIteratorError20 = false;
16419
- var _iteratorError20 = undefined;
16658
+ var _iteratorNormalCompletion22 = true;
16659
+ var _didIteratorError22 = false;
16660
+ var _iteratorError22 = undefined;
16420
16661
 
16421
16662
  try {
16422
- for (var _iterator20 = declaredFields[Symbol.iterator](), _step20; !(_iteratorNormalCompletion20 = (_step20 = _iterator20.next()).done); _iteratorNormalCompletion20 = true) {
16423
- var fieldName = _step20.value;
16663
+ for (var _iterator22 = declaredFields[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
16664
+ var fieldName = _step22.value;
16424
16665
 
16425
16666
  if (fieldName in seen) {
16426
16667
  this._lintCheck(expression.startPos, expression.endPos, 'structure-construction-repeated-field', [constructorName, fieldName]);
@@ -16428,16 +16669,16 @@ var Linter = exports.Linter = function () {
16428
16669
  seen[fieldName] = true;
16429
16670
  }
16430
16671
  } catch (err) {
16431
- _didIteratorError20 = true;
16432
- _iteratorError20 = err;
16672
+ _didIteratorError22 = true;
16673
+ _iteratorError22 = err;
16433
16674
  } finally {
16434
16675
  try {
16435
- if (!_iteratorNormalCompletion20 && _iterator20.return) {
16436
- _iterator20.return();
16676
+ if (!_iteratorNormalCompletion22 && _iterator22.return) {
16677
+ _iterator22.return();
16437
16678
  }
16438
16679
  } finally {
16439
- if (_didIteratorError20) {
16440
- throw _iteratorError20;
16680
+ if (_didIteratorError22) {
16681
+ throw _iteratorError22;
16441
16682
  }
16442
16683
  }
16443
16684
  }
@@ -16451,29 +16692,29 @@ var Linter = exports.Linter = function () {
16451
16692
  value: function _checkStructureBindingsCorrect(constructorName, expression) {
16452
16693
  var declaredFields = expression.fieldNames();
16453
16694
  var constructorFields = this._symtable.constructorFields(constructorName);
16454
- var _iteratorNormalCompletion21 = true;
16455
- var _didIteratorError21 = false;
16456
- var _iteratorError21 = undefined;
16695
+ var _iteratorNormalCompletion23 = true;
16696
+ var _didIteratorError23 = false;
16697
+ var _iteratorError23 = undefined;
16457
16698
 
16458
16699
  try {
16459
- for (var _iterator21 = declaredFields[Symbol.iterator](), _step21; !(_iteratorNormalCompletion21 = (_step21 = _iterator21.next()).done); _iteratorNormalCompletion21 = true) {
16460
- var fieldName = _step21.value;
16700
+ for (var _iterator23 = declaredFields[Symbol.iterator](), _step23; !(_iteratorNormalCompletion23 = (_step23 = _iterator23.next()).done); _iteratorNormalCompletion23 = true) {
16701
+ var fieldName = _step23.value;
16461
16702
 
16462
16703
  if (constructorFields.indexOf(fieldName) === -1) {
16463
16704
  this._lintCheck(expression.startPos, expression.endPos, 'structure-construction-invalid-field', [constructorName, fieldName]);
16464
16705
  }
16465
16706
  }
16466
16707
  } catch (err) {
16467
- _didIteratorError21 = true;
16468
- _iteratorError21 = err;
16708
+ _didIteratorError23 = true;
16709
+ _iteratorError23 = err;
16469
16710
  } finally {
16470
16711
  try {
16471
- if (!_iteratorNormalCompletion21 && _iterator21.return) {
16472
- _iterator21.return();
16712
+ if (!_iteratorNormalCompletion23 && _iterator23.return) {
16713
+ _iterator23.return();
16473
16714
  }
16474
16715
  } finally {
16475
- if (_didIteratorError21) {
16476
- throw _iteratorError21;
16716
+ if (_didIteratorError23) {
16717
+ throw _iteratorError23;
16477
16718
  }
16478
16719
  }
16479
16720
  }
@@ -16487,29 +16728,29 @@ var Linter = exports.Linter = function () {
16487
16728
  value: function _checkStructureBindingsComplete(constructorName, expression) {
16488
16729
  var declaredFields = expression.fieldNames();
16489
16730
  var constructorFields = this._symtable.constructorFields(constructorName);
16490
- var _iteratorNormalCompletion22 = true;
16491
- var _didIteratorError22 = false;
16492
- var _iteratorError22 = undefined;
16731
+ var _iteratorNormalCompletion24 = true;
16732
+ var _didIteratorError24 = false;
16733
+ var _iteratorError24 = undefined;
16493
16734
 
16494
16735
  try {
16495
- for (var _iterator22 = constructorFields[Symbol.iterator](), _step22; !(_iteratorNormalCompletion22 = (_step22 = _iterator22.next()).done); _iteratorNormalCompletion22 = true) {
16496
- var fieldName = _step22.value;
16736
+ for (var _iterator24 = constructorFields[Symbol.iterator](), _step24; !(_iteratorNormalCompletion24 = (_step24 = _iterator24.next()).done); _iteratorNormalCompletion24 = true) {
16737
+ var fieldName = _step24.value;
16497
16738
 
16498
16739
  if (declaredFields.indexOf(fieldName) === -1) {
16499
16740
  this._lintCheck(expression.startPos, expression.endPos, 'structure-construction-missing-field', [constructorName, fieldName]);
16500
16741
  }
16501
16742
  }
16502
16743
  } catch (err) {
16503
- _didIteratorError22 = true;
16504
- _iteratorError22 = err;
16744
+ _didIteratorError24 = true;
16745
+ _iteratorError24 = err;
16505
16746
  } finally {
16506
16747
  try {
16507
- if (!_iteratorNormalCompletion22 && _iterator22.return) {
16508
- _iterator22.return();
16748
+ if (!_iteratorNormalCompletion24 && _iterator24.return) {
16749
+ _iterator24.return();
16509
16750
  }
16510
16751
  } finally {
16511
- if (_didIteratorError22) {
16512
- throw _iteratorError22;
16752
+ if (_didIteratorError24) {
16753
+ throw _iteratorError24;
16513
16754
  }
16514
16755
  }
16515
16756
  }
@@ -16550,27 +16791,27 @@ var Linter = exports.Linter = function () {
16550
16791
  }
16551
16792
 
16552
16793
  /* Recursively check arguments */
16553
- var _iteratorNormalCompletion23 = true;
16554
- var _didIteratorError23 = false;
16555
- var _iteratorError23 = undefined;
16794
+ var _iteratorNormalCompletion25 = true;
16795
+ var _didIteratorError25 = false;
16796
+ var _iteratorError25 = undefined;
16556
16797
 
16557
16798
  try {
16558
- for (var _iterator23 = expression.args[Symbol.iterator](), _step23; !(_iteratorNormalCompletion23 = (_step23 = _iterator23.next()).done); _iteratorNormalCompletion23 = true) {
16559
- var argument = _step23.value;
16799
+ for (var _iterator25 = expression.args[Symbol.iterator](), _step25; !(_iteratorNormalCompletion25 = (_step25 = _iterator25.next()).done); _iteratorNormalCompletion25 = true) {
16800
+ var argument = _step25.value;
16560
16801
 
16561
16802
  this._lintExpression(argument);
16562
16803
  }
16563
16804
  } catch (err) {
16564
- _didIteratorError23 = true;
16565
- _iteratorError23 = err;
16805
+ _didIteratorError25 = true;
16806
+ _iteratorError25 = err;
16566
16807
  } finally {
16567
16808
  try {
16568
- if (!_iteratorNormalCompletion23 && _iterator23.return) {
16569
- _iterator23.return();
16809
+ if (!_iteratorNormalCompletion25 && _iterator25.return) {
16810
+ _iterator25.return();
16570
16811
  }
16571
16812
  } finally {
16572
- if (_didIteratorError23) {
16573
- throw _iteratorError23;
16813
+ if (_didIteratorError25) {
16814
+ throw _iteratorError25;
16574
16815
  }
16575
16816
  }
16576
16817
  }
@@ -16968,10 +17209,10 @@ var Compiler = exports.Compiler = function () {
16968
17209
  * PrimitiveCall "<", 2 ;|
16969
17210
  * JumpIfFalse labelEnd ;/
16970
17211
  *
16971
- * PushVariable _list ;\ get the `pos`-th element of the
16972
- * PushVariable _pos ;| list and store it in the local
16973
- * PrimitiveCall "_unsafeListNth", 2 ;| variable "<index>"
16974
- * SetVariable <index> ;/
17212
+ * PushVariable _list ;\ get the `pos`-th element of the
17213
+ * PushVariable _pos ;| list and match the value
17214
+ * PrimitiveCall "_unsafeListNth", 2 ;| with the pattern of the foreach
17215
+ * [match with the pattern or fail] ;/
16975
17216
  *
16976
17217
  * <body>
16977
17218
  *
@@ -16985,7 +17226,7 @@ var Compiler = exports.Compiler = function () {
16985
17226
  * UnsetVariable _list
16986
17227
  * UnsetVariable _n
16987
17228
  * UnsetVariable _pos
16988
- * UnsetVariable <index>
17229
+ * [unset all the variables bound by the pattern]
16989
17230
  */
16990
17231
 
16991
17232
  }, {
@@ -16999,9 +17240,45 @@ var Compiler = exports.Compiler = function () {
16999
17240
 
17000
17241
  this._compileExpression(statement.range);
17001
17242
  this._produceList(statement.range.startPos, statement.range.endPos, [new _instruction.ITypeCheck(new _value.TypeList(new _value.TypeAny())), new _instruction.ISetVariable(list), new _instruction.IPushVariable(list), new _instruction.IPrimitiveCall('_unsafeListLength', 1), new _instruction.ISetVariable(n)]);
17002
- this._produceList(statement.startPos, statement.endPos, [new _instruction.IPushInteger(0), new _instruction.ISetVariable(pos), new _instruction.ILabel(labelStart), new _instruction.IPushVariable(pos), new _instruction.IPushVariable(n), new _instruction.IPrimitiveCall('<', 2), new _instruction.IJumpIfFalse(labelEnd), new _instruction.IPushVariable(list), new _instruction.IPushVariable(pos), new _instruction.IPrimitiveCall('_unsafeListNth', 2), new _instruction.ISetVariable(statement.index.value)]);
17243
+ this._produceList(statement.startPos, statement.endPos, [new _instruction.IPushInteger(0), new _instruction.ISetVariable(pos), new _instruction.ILabel(labelStart), new _instruction.IPushVariable(pos), new _instruction.IPushVariable(n), new _instruction.IPrimitiveCall('<', 2), new _instruction.IJumpIfFalse(labelEnd), new _instruction.IPushVariable(list), new _instruction.IPushVariable(pos), new _instruction.IPrimitiveCall('_unsafeListNth', 2)]);
17244
+ this._compileMatchForeachPatternOrFail(statement.pattern);
17003
17245
  this._compileStatement(statement.body);
17004
- this._produceList(statement.startPos, statement.endPos, [new _instruction.IPushVariable(pos), new _instruction.IPushInteger(1), new _instruction.IPrimitiveCall('+', 2), new _instruction.ISetVariable(pos), new _instruction.IJump(labelStart), new _instruction.ILabel(labelEnd), new _instruction.IUnsetVariable(list), new _instruction.IUnsetVariable(n), new _instruction.IUnsetVariable(pos), new _instruction.IUnsetVariable(statement.index.value)]);
17246
+ this._produceList(statement.startPos, statement.endPos, [new _instruction.IPushVariable(pos), new _instruction.IPushInteger(1), new _instruction.IPrimitiveCall('+', 2), new _instruction.ISetVariable(pos), new _instruction.IJump(labelStart), new _instruction.ILabel(labelEnd), new _instruction.IUnsetVariable(list), new _instruction.IUnsetVariable(n), new _instruction.IUnsetVariable(pos)]);
17247
+ this._compilePatternUnbind(statement.pattern);
17248
+ }
17249
+
17250
+ /* Attempt to match the pattern against the top of the stack.
17251
+ * If the pattern matches, bind its variables.
17252
+ * Otherwise, issue an error message.
17253
+ * Always pops the top of the stack.
17254
+ */
17255
+
17256
+ }, {
17257
+ key: '_compileMatchForeachPatternOrFail',
17258
+ value: function _compileMatchForeachPatternOrFail(pattern) {
17259
+ switch (pattern.tag) {
17260
+ case _ast.N_PatternWildcard:
17261
+ this._produce(pattern.startPos, pattern.endPos, new _instruction.IPop());
17262
+ return;
17263
+ case _ast.N_PatternVariable:
17264
+ this._produce(pattern.startPos, pattern.endPos, new _instruction.ISetVariable(pattern.variableName.value));
17265
+ return;
17266
+ default:
17267
+ /* Attempt to match, issuing an error message if there is no match:
17268
+ *
17269
+ * [if subject matches pattern, jump to L]
17270
+ * [error message: no match]
17271
+ * L:
17272
+ * [bind pattern to subject]
17273
+ * [pop subject]
17274
+ */
17275
+ var label = this._freshLabel();
17276
+ this._compilePatternCheck(pattern, label);
17277
+ this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IPushString('foreach-pattern-does-not-match'), new _instruction.IPrimitiveCall('_FAIL', 1), new _instruction.ILabel(label)]);
17278
+ this._compilePatternBind(pattern);
17279
+ this._produce(pattern.startPos, pattern.endPos, new _instruction.IPop());
17280
+ return;
17281
+ }
17005
17282
  }
17006
17283
 
17007
17284
  /* labelStart:
@@ -17204,6 +17481,8 @@ var Compiler = exports.Compiler = function () {
17204
17481
  switch (pattern.tag) {
17205
17482
  case _ast.N_PatternWildcard:
17206
17483
  return this._compilePatternCheckWildcard(pattern, targetLabel);
17484
+ case _ast.N_PatternVariable:
17485
+ return this._compilePatternCheckVariable(pattern, targetLabel);
17207
17486
  case _ast.N_PatternNumber:
17208
17487
  return this._compilePatternCheckNumber(pattern, targetLabel);
17209
17488
  case _ast.N_PatternStructure:
@@ -17221,6 +17500,11 @@ var Compiler = exports.Compiler = function () {
17221
17500
  value: function _compilePatternCheckWildcard(pattern, targetLabel) {
17222
17501
  this._produce(pattern.startPos, pattern.endPos, new _instruction.IJump(targetLabel));
17223
17502
  }
17503
+ }, {
17504
+ key: '_compilePatternCheckVariable',
17505
+ value: function _compilePatternCheckVariable(pattern, targetLabel) {
17506
+ this._produce(pattern.startPos, pattern.endPos, new _instruction.IJump(targetLabel));
17507
+ }
17224
17508
  }, {
17225
17509
  key: '_compilePatternCheckNumber',
17226
17510
  value: function _compilePatternCheckNumber(pattern, targetLabel) {
@@ -17245,14 +17529,14 @@ var Compiler = exports.Compiler = function () {
17245
17529
  /* Check that the type of the value coincides with the type
17246
17530
  * of the tuple */
17247
17531
  var anys = [];
17248
- for (var i = 0; i < pattern.parameters.length; i++) {
17532
+ for (var i = 0; i < pattern.boundVariables.length; i++) {
17249
17533
  anys.push(new _value.TypeAny());
17250
17534
  }
17251
17535
  var expectedType = new _value.TypeTuple(anys);
17252
17536
  this._produce(pattern.startPos, pattern.endPos, new _instruction.ITypeCheck(expectedType));
17253
17537
 
17254
17538
  /* Jump if the value matches */
17255
- this._produce(pattern.startPos, pattern.endPos, new _instruction.IJumpIfTuple(pattern.parameters.length, targetLabel));
17539
+ this._produce(pattern.startPos, pattern.endPos, new _instruction.IJumpIfTuple(pattern.boundVariables.length, targetLabel));
17256
17540
  }
17257
17541
  }, {
17258
17542
  key: '_compilePatternCheckTimeout',
@@ -17262,7 +17546,8 @@ var Compiler = exports.Compiler = function () {
17262
17546
 
17263
17547
  /* Pattern binding are instructions that bind the parameters
17264
17548
  * of a pattern to the corresponding parts of the value currently
17265
- * at the top of the stack.
17549
+ * at the top of the stack. The value at the top of the stack
17550
+ * is never popped (it must be duplicated if necessary).
17266
17551
  */
17267
17552
 
17268
17553
  }, {
@@ -17271,6 +17556,9 @@ var Compiler = exports.Compiler = function () {
17271
17556
  switch (pattern.tag) {
17272
17557
  case _ast.N_PatternWildcard:
17273
17558
  return; /* No parameters to bind */
17559
+ case _ast.N_PatternVariable:
17560
+ this._compilePatternBindVariable(pattern);
17561
+ return;
17274
17562
  case _ast.N_PatternNumber:
17275
17563
  return; /* No parameters to bind */
17276
17564
  case _ast.N_PatternStructure:
@@ -17285,29 +17573,34 @@ var Compiler = exports.Compiler = function () {
17285
17573
  throw Error('Compiler: Pattern binding not implemented: ' + Symbol.keyFor(pattern.tag));
17286
17574
  }
17287
17575
  }
17576
+ }, {
17577
+ key: '_compilePatternBindVariable',
17578
+ value: function _compilePatternBindVariable(pattern) {
17579
+ this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IDup(), new _instruction.ISetVariable(pattern.variableName.value)]);
17580
+ }
17288
17581
  }, {
17289
17582
  key: '_compilePatternBindStructure',
17290
17583
  value: function _compilePatternBindStructure(pattern) {
17291
- /* Allow pattern with no parameters, even if the constructor
17584
+ /* Allow structure pattern with no parameters, even if the constructor
17292
17585
  * has parameters */
17293
- if (pattern.parameters.length === 0) {
17586
+ if (pattern.boundVariables.length === 0) {
17294
17587
  return;
17295
17588
  }
17296
17589
 
17297
17590
  var constructorName = pattern.constructorName.value;
17298
17591
  var fieldNames = this._symtable.constructorFields(constructorName);
17299
17592
  for (var i = 0; i < fieldNames.length; i++) {
17300
- var parameter = pattern.parameters[i];
17593
+ var variable = pattern.boundVariables[i];
17301
17594
  var fieldName = fieldNames[i];
17302
- this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IReadStructureField(fieldName), new _instruction.ISetVariable(parameter.value)]);
17595
+ this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IReadStructureField(fieldName), new _instruction.ISetVariable(variable.value)]);
17303
17596
  }
17304
17597
  }
17305
17598
  }, {
17306
17599
  key: '_compilePatternBindTuple',
17307
17600
  value: function _compilePatternBindTuple(pattern) {
17308
- for (var index = 0; index < pattern.parameters.length; index++) {
17309
- var parameter = pattern.parameters[index];
17310
- this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IReadTupleComponent(index), new _instruction.ISetVariable(parameter.value)]);
17601
+ for (var index = 0; index < pattern.boundVariables.length; index++) {
17602
+ var variable = pattern.boundVariables[index];
17603
+ this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IReadTupleComponent(index), new _instruction.ISetVariable(variable.value)]);
17311
17604
  }
17312
17605
  }
17313
17606
 
@@ -17317,35 +17610,15 @@ var Compiler = exports.Compiler = function () {
17317
17610
  }, {
17318
17611
  key: '_compilePatternUnbind',
17319
17612
  value: function _compilePatternUnbind(pattern) {
17320
- switch (pattern.tag) {
17321
- case _ast.N_PatternWildcard:
17322
- return; /* No parameters to unbind */
17323
- case _ast.N_PatternNumber:
17324
- return; /* No parameters to unbind */
17325
- case _ast.N_PatternStructure:
17326
- this._compilePatternUnbindStructure(pattern);
17327
- return;
17328
- case _ast.N_PatternTuple:
17329
- this._compilePatternUnbindTuple(pattern);
17330
- return;
17331
- case _ast.N_PatternTimeout:
17332
- return; /* No parameters to unbind */
17333
- default:
17334
- throw Error('Compiler: Pattern unbinding not implemented: ' + Symbol.keyFor(pattern.tag));
17335
- }
17336
- }
17337
- }, {
17338
- key: '_compilePatternUnbindStructure',
17339
- value: function _compilePatternUnbindStructure(pattern) {
17340
17613
  var _iteratorNormalCompletion6 = true;
17341
17614
  var _didIteratorError6 = false;
17342
17615
  var _iteratorError6 = undefined;
17343
17616
 
17344
17617
  try {
17345
- for (var _iterator6 = pattern.parameters[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
17346
- var parameter = _step6.value;
17618
+ for (var _iterator6 = pattern.boundVariables[Symbol.iterator](), _step6; !(_iteratorNormalCompletion6 = (_step6 = _iterator6.next()).done); _iteratorNormalCompletion6 = true) {
17619
+ var variable = _step6.value;
17347
17620
 
17348
- this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IUnsetVariable(parameter.value)]);
17621
+ this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IUnsetVariable(variable.value)]);
17349
17622
  }
17350
17623
  } catch (err) {
17351
17624
  _didIteratorError6 = true;
@@ -17362,34 +17635,6 @@ var Compiler = exports.Compiler = function () {
17362
17635
  }
17363
17636
  }
17364
17637
  }
17365
- }, {
17366
- key: '_compilePatternUnbindTuple',
17367
- value: function _compilePatternUnbindTuple(pattern) {
17368
- var _iteratorNormalCompletion7 = true;
17369
- var _didIteratorError7 = false;
17370
- var _iteratorError7 = undefined;
17371
-
17372
- try {
17373
- for (var _iterator7 = pattern.parameters[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
17374
- var parameter = _step7.value;
17375
-
17376
- this._produceList(pattern.startPos, pattern.endPos, [new _instruction.IUnsetVariable(parameter.value)]);
17377
- }
17378
- } catch (err) {
17379
- _didIteratorError7 = true;
17380
- _iteratorError7 = err;
17381
- } finally {
17382
- try {
17383
- if (!_iteratorNormalCompletion7 && _iterator7.return) {
17384
- _iterator7.return();
17385
- }
17386
- } finally {
17387
- if (_didIteratorError7) {
17388
- throw _iteratorError7;
17389
- }
17390
- }
17391
- }
17392
- }
17393
17638
 
17394
17639
  /* Expressions are compiled to instructions that make the size
17395
17640
  * of the local stack grow in exactly one.
@@ -17489,27 +17734,27 @@ var Compiler = exports.Compiler = function () {
17489
17734
  }, {
17490
17735
  key: '_compileExprList',
17491
17736
  value: function _compileExprList(expression) {
17492
- var _iteratorNormalCompletion8 = true;
17493
- var _didIteratorError8 = false;
17494
- var _iteratorError8 = undefined;
17737
+ var _iteratorNormalCompletion7 = true;
17738
+ var _didIteratorError7 = false;
17739
+ var _iteratorError7 = undefined;
17495
17740
 
17496
17741
  try {
17497
- for (var _iterator8 = expression.elements[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
17498
- var element = _step8.value;
17742
+ for (var _iterator7 = expression.elements[Symbol.iterator](), _step7; !(_iteratorNormalCompletion7 = (_step7 = _iterator7.next()).done); _iteratorNormalCompletion7 = true) {
17743
+ var element = _step7.value;
17499
17744
 
17500
17745
  this._compileExpression(element);
17501
17746
  }
17502
17747
  } catch (err) {
17503
- _didIteratorError8 = true;
17504
- _iteratorError8 = err;
17748
+ _didIteratorError7 = true;
17749
+ _iteratorError7 = err;
17505
17750
  } finally {
17506
17751
  try {
17507
- if (!_iteratorNormalCompletion8 && _iterator8.return) {
17508
- _iterator8.return();
17752
+ if (!_iteratorNormalCompletion7 && _iterator7.return) {
17753
+ _iterator7.return();
17509
17754
  }
17510
17755
  } finally {
17511
- if (_didIteratorError8) {
17512
- throw _iteratorError8;
17756
+ if (_didIteratorError7) {
17757
+ throw _iteratorError7;
17513
17758
  }
17514
17759
  }
17515
17760
  }
@@ -17539,27 +17784,27 @@ var Compiler = exports.Compiler = function () {
17539
17784
  }, {
17540
17785
  key: '_compileExprTuple',
17541
17786
  value: function _compileExprTuple(expression) {
17542
- var _iteratorNormalCompletion9 = true;
17543
- var _didIteratorError9 = false;
17544
- var _iteratorError9 = undefined;
17787
+ var _iteratorNormalCompletion8 = true;
17788
+ var _didIteratorError8 = false;
17789
+ var _iteratorError8 = undefined;
17545
17790
 
17546
17791
  try {
17547
- for (var _iterator9 = expression.elements[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
17548
- var element = _step9.value;
17792
+ for (var _iterator8 = expression.elements[Symbol.iterator](), _step8; !(_iteratorNormalCompletion8 = (_step8 = _iterator8.next()).done); _iteratorNormalCompletion8 = true) {
17793
+ var element = _step8.value;
17549
17794
 
17550
17795
  this._compileExpression(element);
17551
17796
  }
17552
17797
  } catch (err) {
17553
- _didIteratorError9 = true;
17554
- _iteratorError9 = err;
17798
+ _didIteratorError8 = true;
17799
+ _iteratorError8 = err;
17555
17800
  } finally {
17556
17801
  try {
17557
- if (!_iteratorNormalCompletion9 && _iterator9.return) {
17558
- _iterator9.return();
17802
+ if (!_iteratorNormalCompletion8 && _iterator8.return) {
17803
+ _iterator8.return();
17559
17804
  }
17560
17805
  } finally {
17561
- if (_didIteratorError9) {
17562
- throw _iteratorError9;
17806
+ if (_didIteratorError8) {
17807
+ throw _iteratorError8;
17563
17808
  }
17564
17809
  }
17565
17810
  }
@@ -17570,28 +17815,28 @@ var Compiler = exports.Compiler = function () {
17570
17815
  key: '_compileExprStructure',
17571
17816
  value: function _compileExprStructure(expression) {
17572
17817
  var fieldNames = [];
17573
- var _iteratorNormalCompletion10 = true;
17574
- var _didIteratorError10 = false;
17575
- var _iteratorError10 = undefined;
17818
+ var _iteratorNormalCompletion9 = true;
17819
+ var _didIteratorError9 = false;
17820
+ var _iteratorError9 = undefined;
17576
17821
 
17577
17822
  try {
17578
- for (var _iterator10 = expression.fieldBindings[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
17579
- var fieldBinding = _step10.value;
17823
+ for (var _iterator9 = expression.fieldBindings[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
17824
+ var fieldBinding = _step9.value;
17580
17825
 
17581
17826
  this._compileExpression(fieldBinding.value);
17582
17827
  fieldNames.push(fieldBinding.fieldName.value);
17583
17828
  }
17584
17829
  } catch (err) {
17585
- _didIteratorError10 = true;
17586
- _iteratorError10 = err;
17830
+ _didIteratorError9 = true;
17831
+ _iteratorError9 = err;
17587
17832
  } finally {
17588
17833
  try {
17589
- if (!_iteratorNormalCompletion10 && _iterator10.return) {
17590
- _iterator10.return();
17834
+ if (!_iteratorNormalCompletion9 && _iterator9.return) {
17835
+ _iterator9.return();
17591
17836
  }
17592
17837
  } finally {
17593
- if (_didIteratorError10) {
17594
- throw _iteratorError10;
17838
+ if (_didIteratorError9) {
17839
+ throw _iteratorError9;
17595
17840
  }
17596
17841
  }
17597
17842
  }
@@ -17605,28 +17850,28 @@ var Compiler = exports.Compiler = function () {
17605
17850
  value: function _compileExprStructureUpdate(expression) {
17606
17851
  this._compileExpression(expression.original);
17607
17852
  var fieldNames = [];
17608
- var _iteratorNormalCompletion11 = true;
17609
- var _didIteratorError11 = false;
17610
- var _iteratorError11 = undefined;
17853
+ var _iteratorNormalCompletion10 = true;
17854
+ var _didIteratorError10 = false;
17855
+ var _iteratorError10 = undefined;
17611
17856
 
17612
17857
  try {
17613
- for (var _iterator11 = expression.fieldBindings[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
17614
- var fieldBinding = _step11.value;
17858
+ for (var _iterator10 = expression.fieldBindings[Symbol.iterator](), _step10; !(_iteratorNormalCompletion10 = (_step10 = _iterator10.next()).done); _iteratorNormalCompletion10 = true) {
17859
+ var fieldBinding = _step10.value;
17615
17860
 
17616
17861
  this._compileExpression(fieldBinding.value);
17617
17862
  fieldNames.push(fieldBinding.fieldName.value);
17618
17863
  }
17619
17864
  } catch (err) {
17620
- _didIteratorError11 = true;
17621
- _iteratorError11 = err;
17865
+ _didIteratorError10 = true;
17866
+ _iteratorError10 = err;
17622
17867
  } finally {
17623
17868
  try {
17624
- if (!_iteratorNormalCompletion11 && _iterator11.return) {
17625
- _iterator11.return();
17869
+ if (!_iteratorNormalCompletion10 && _iterator10.return) {
17870
+ _iterator10.return();
17626
17871
  }
17627
17872
  } finally {
17628
- if (_didIteratorError11) {
17629
- throw _iteratorError11;
17873
+ if (_didIteratorError10) {
17874
+ throw _iteratorError10;
17630
17875
  }
17631
17876
  }
17632
17877
  }
@@ -17653,27 +17898,27 @@ var Compiler = exports.Compiler = function () {
17653
17898
  } else if (functionName === '||') {
17654
17899
  this._compileExprFunctionCallOr(expression);
17655
17900
  } else {
17656
- var _iteratorNormalCompletion12 = true;
17657
- var _didIteratorError12 = false;
17658
- var _iteratorError12 = undefined;
17901
+ var _iteratorNormalCompletion11 = true;
17902
+ var _didIteratorError11 = false;
17903
+ var _iteratorError11 = undefined;
17659
17904
 
17660
17905
  try {
17661
- for (var _iterator12 = expression.args[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
17662
- var argument = _step12.value;
17906
+ for (var _iterator11 = expression.args[Symbol.iterator](), _step11; !(_iteratorNormalCompletion11 = (_step11 = _iterator11.next()).done); _iteratorNormalCompletion11 = true) {
17907
+ var argument = _step11.value;
17663
17908
 
17664
17909
  this._compileExpression(argument);
17665
17910
  }
17666
17911
  } catch (err) {
17667
- _didIteratorError12 = true;
17668
- _iteratorError12 = err;
17912
+ _didIteratorError11 = true;
17913
+ _iteratorError11 = err;
17669
17914
  } finally {
17670
17915
  try {
17671
- if (!_iteratorNormalCompletion12 && _iterator12.return) {
17672
- _iterator12.return();
17916
+ if (!_iteratorNormalCompletion11 && _iterator11.return) {
17917
+ _iterator11.return();
17673
17918
  }
17674
17919
  } finally {
17675
- if (_didIteratorError12) {
17676
- throw _iteratorError12;
17920
+ if (_didIteratorError11) {
17921
+ throw _iteratorError11;
17677
17922
  }
17678
17923
  }
17679
17924
  }
@@ -17762,27 +18007,27 @@ var Compiler = exports.Compiler = function () {
17762
18007
  }, {
17763
18008
  key: '_produceList',
17764
18009
  value: function _produceList(startPos, endPos, instructions) {
17765
- var _iteratorNormalCompletion13 = true;
17766
- var _didIteratorError13 = false;
17767
- var _iteratorError13 = undefined;
18010
+ var _iteratorNormalCompletion12 = true;
18011
+ var _didIteratorError12 = false;
18012
+ var _iteratorError12 = undefined;
17768
18013
 
17769
18014
  try {
17770
- for (var _iterator13 = instructions[Symbol.iterator](), _step13; !(_iteratorNormalCompletion13 = (_step13 = _iterator13.next()).done); _iteratorNormalCompletion13 = true) {
17771
- var instruction = _step13.value;
18015
+ for (var _iterator12 = instructions[Symbol.iterator](), _step12; !(_iteratorNormalCompletion12 = (_step12 = _iterator12.next()).done); _iteratorNormalCompletion12 = true) {
18016
+ var instruction = _step12.value;
17772
18017
 
17773
18018
  this._produce(startPos, endPos, instruction);
17774
18019
  }
17775
18020
  } catch (err) {
17776
- _didIteratorError13 = true;
17777
- _iteratorError13 = err;
18021
+ _didIteratorError12 = true;
18022
+ _iteratorError12 = err;
17778
18023
  } finally {
17779
18024
  try {
17780
- if (!_iteratorNormalCompletion13 && _iterator13.return) {
17781
- _iterator13.return();
18025
+ if (!_iteratorNormalCompletion12 && _iterator12.return) {
18026
+ _iterator12.return();
17782
18027
  }
17783
18028
  } finally {
17784
- if (_didIteratorError13) {
17785
- throw _iteratorError13;
18029
+ if (_didIteratorError12) {
18030
+ throw _iteratorError12;
17786
18031
  }
17787
18032
  }
17788
18033
  }