app/assets/htmls/gobstones-code-runner.html in gobstones-code-runner-0.5.4 vs app/assets/htmls/gobstones-code-runner.html in gobstones-code-runner-0.6.0
- old
+ new
@@ -4470,11 +4470,11 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
-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;
+exports.ASTConstructorDeclaration = exports.ASTFieldBinding = exports.ASTExprFunctionCall = exports.ASTExprStructureUpdate = exports.ASTExprStructure = exports.ASTExprTuple = exports.ASTExprRange = exports.ASTExprList = exports.ASTExprMatching = exports.ASTExprChoose = exports.ASTExprConstantString = exports.ASTExprConstantNumber = exports.ASTExprVariable = exports.ASTPatternTimeout = exports.ASTPatternTuple = exports.ASTPatternStructure = exports.ASTPatternNumber = exports.ASTPatternVariable = exports.ASTPatternWildcard = exports.ASTStmtProcedureCall = exports.ASTStmtAssignTuple = exports.ASTStmtAssignVariable = exports.ASTMatchingBranch = exports.ASTSwitchBranch = exports.ASTStmtSwitch = exports.ASTStmtWhile = exports.ASTStmtForeach = exports.ASTStmtRepeat = exports.ASTStmtIf = exports.ASTStmtReturn = exports.ASTStmtBlock = exports.ASTDefType = exports.ASTDefFunction = exports.ASTDefProcedure = exports.ASTDefInteractiveProgram = exports.ASTDefProgram = exports.ASTMain = exports.ASTNode = exports.N_ConstructorDeclaration = exports.N_FieldBinding = exports.N_MatchingBranch = exports.N_SwitchBranch = exports.N_ExprFunctionCall = exports.N_ExprStructureUpdate = exports.N_ExprStructure = exports.N_ExprTuple = exports.N_ExprRange = exports.N_ExprList = exports.N_ExprMatching = exports.N_ExprChoose = exports.N_ExprConstantString = exports.N_ExprConstantNumber = exports.N_ExprVariable = exports.N_PatternTimeout = exports.N_PatternTuple = exports.N_PatternStructure = exports.N_PatternNumber = exports.N_PatternVariable = exports.N_PatternWildcard = exports.N_StmtProcedureCall = exports.N_StmtAssignTuple = exports.N_StmtAssignVariable = exports.N_StmtSwitch = exports.N_StmtWhile = exports.N_StmtForeach = exports.N_StmtRepeat = exports.N_StmtIf = exports.N_StmtReturn = exports.N_StmtBlock = exports.N_DefType = exports.N_DefFunction = exports.N_DefProcedure = exports.N_DefInteractiveProgram = exports.N_DefProgram = exports.N_Main = undefined;
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; }; }();
var _reader = __webpack_require__(6);
@@ -4514,18 +4514,21 @@
/* Expressions */
var N_ExprVariable = exports.N_ExprVariable = Symbol.for('N_ExprVariable');
var N_ExprConstantNumber = exports.N_ExprConstantNumber = Symbol.for('N_ExprConstantNumber');
var N_ExprConstantString = exports.N_ExprConstantString = Symbol.for('N_ExprConstantString');
var N_ExprChoose = exports.N_ExprChoose = Symbol.for('N_ExprChoose');
+var N_ExprMatching = exports.N_ExprMatching = Symbol.for('N_ExprMatching');
var N_ExprList = exports.N_ExprList = Symbol.for('N_ExprList');
var N_ExprRange = exports.N_ExprRange = Symbol.for('N_ExprRange');
var N_ExprTuple = exports.N_ExprTuple = Symbol.for('N_ExprTuple');
var N_ExprStructure = exports.N_ExprStructure = Symbol.for('N_ExprStructure');
var N_ExprStructureUpdate = exports.N_ExprStructureUpdate = Symbol.for('N_ExprStructureUpdate');
var N_ExprFunctionCall = exports.N_ExprFunctionCall = Symbol.for('N_ExprFunctionCall');
/* SwitchBranch: pattern -> body */
var N_SwitchBranch = exports.N_SwitchBranch = Symbol.for('N_SwitchBranch');
+/* MatchingBranch: pattern -> body */
+var N_MatchingBranch = exports.N_MatchingBranch = Symbol.for('N_MatchingBranch');
/* FieldBinding: fieldName <- value */
var N_FieldBinding = exports.N_FieldBinding = Symbol.for('N_FieldBinding');
/* ConstructorDeclaration */
var N_ConstructorDeclaration = exports.N_ConstructorDeclaration = Symbol.for('N_ConstructorDeclaration');
@@ -5030,13 +5033,37 @@
}]);
return ASTSwitchBranch;
}(ASTNode);
-var ASTStmtAssignVariable = exports.ASTStmtAssignVariable = function (_ASTNode15) {
- _inherits(ASTStmtAssignVariable, _ASTNode15);
+var ASTMatchingBranch = exports.ASTMatchingBranch = function (_ASTNode15) {
+ _inherits(ASTMatchingBranch, _ASTNode15);
+ function ASTMatchingBranch(pattern, body) {
+ _classCallCheck(this, ASTMatchingBranch);
+
+ return _possibleConstructorReturn(this, (ASTMatchingBranch.__proto__ || Object.getPrototypeOf(ASTMatchingBranch)).call(this, N_MatchingBranch, [pattern, body]));
+ }
+
+ _createClass(ASTMatchingBranch, [{
+ key: 'pattern',
+ get: function get() {
+ return this._children[0];
+ }
+ }, {
+ key: 'body',
+ get: function get() {
+ return this._children[1];
+ }
+ }]);
+
+ return ASTMatchingBranch;
+}(ASTNode);
+
+var ASTStmtAssignVariable = exports.ASTStmtAssignVariable = function (_ASTNode16) {
+ _inherits(ASTStmtAssignVariable, _ASTNode16);
+
function ASTStmtAssignVariable(variable, value) {
_classCallCheck(this, ASTStmtAssignVariable);
return _possibleConstructorReturn(this, (ASTStmtAssignVariable.__proto__ || Object.getPrototypeOf(ASTStmtAssignVariable)).call(this, N_StmtAssignVariable, [variable, value]));
}
@@ -5054,12 +5081,12 @@
}]);
return ASTStmtAssignVariable;
}(ASTNode);
-var ASTStmtAssignTuple = exports.ASTStmtAssignTuple = function (_ASTNode16) {
- _inherits(ASTStmtAssignTuple, _ASTNode16);
+var ASTStmtAssignTuple = exports.ASTStmtAssignTuple = function (_ASTNode17) {
+ _inherits(ASTStmtAssignTuple, _ASTNode17);
function ASTStmtAssignTuple(variables, value) {
_classCallCheck(this, ASTStmtAssignTuple);
return _possibleConstructorReturn(this, (ASTStmtAssignTuple.__proto__ || Object.getPrototypeOf(ASTStmtAssignTuple)).call(this, N_StmtAssignTuple, [variables, value]));
@@ -5078,12 +5105,12 @@
}]);
return ASTStmtAssignTuple;
}(ASTNode);
-var ASTStmtProcedureCall = exports.ASTStmtProcedureCall = function (_ASTNode17) {
- _inherits(ASTStmtProcedureCall, _ASTNode17);
+var ASTStmtProcedureCall = exports.ASTStmtProcedureCall = function (_ASTNode18) {
+ _inherits(ASTStmtProcedureCall, _ASTNode18);
function ASTStmtProcedureCall(procedureName, args) {
_classCallCheck(this, ASTStmtProcedureCall);
return _possibleConstructorReturn(this, (ASTStmtProcedureCall.__proto__ || Object.getPrototypeOf(ASTStmtProcedureCall)).call(this, N_StmtProcedureCall, [procedureName, args]));
@@ -5104,12 +5131,12 @@
return ASTStmtProcedureCall;
}(ASTNode);
/* Patterns */
-var ASTPatternWildcard = exports.ASTPatternWildcard = function (_ASTNode18) {
- _inherits(ASTPatternWildcard, _ASTNode18);
+var ASTPatternWildcard = exports.ASTPatternWildcard = function (_ASTNode19) {
+ _inherits(ASTPatternWildcard, _ASTNode19);
function ASTPatternWildcard() {
_classCallCheck(this, ASTPatternWildcard);
return _possibleConstructorReturn(this, (ASTPatternWildcard.__proto__ || Object.getPrototypeOf(ASTPatternWildcard)).call(this, N_PatternWildcard, []));
@@ -5123,12 +5150,12 @@
}]);
return ASTPatternWildcard;
}(ASTNode);
-var ASTPatternVariable = exports.ASTPatternVariable = function (_ASTNode19) {
- _inherits(ASTPatternVariable, _ASTNode19);
+var ASTPatternVariable = exports.ASTPatternVariable = function (_ASTNode20) {
+ _inherits(ASTPatternVariable, _ASTNode20);
function ASTPatternVariable(variableName) {
_classCallCheck(this, ASTPatternVariable);
return _possibleConstructorReturn(this, (ASTPatternVariable.__proto__ || Object.getPrototypeOf(ASTPatternVariable)).call(this, N_PatternVariable, [variableName]));
@@ -5147,12 +5174,12 @@
}]);
return ASTPatternVariable;
}(ASTNode);
-var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode20) {
- _inherits(ASTPatternNumber, _ASTNode20);
+var ASTPatternNumber = exports.ASTPatternNumber = function (_ASTNode21) {
+ _inherits(ASTPatternNumber, _ASTNode21);
function ASTPatternNumber(number) {
_classCallCheck(this, ASTPatternNumber);
return _possibleConstructorReturn(this, (ASTPatternNumber.__proto__ || Object.getPrototypeOf(ASTPatternNumber)).call(this, N_PatternNumber, [number]));
@@ -5171,12 +5198,12 @@
}]);
return ASTPatternNumber;
}(ASTNode);
-var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode21) {
- _inherits(ASTPatternStructure, _ASTNode21);
+var ASTPatternStructure = exports.ASTPatternStructure = function (_ASTNode22) {
+ _inherits(ASTPatternStructure, _ASTNode22);
function ASTPatternStructure(constructorName, parameters) {
_classCallCheck(this, ASTPatternStructure);
return _possibleConstructorReturn(this, (ASTPatternStructure.__proto__ || Object.getPrototypeOf(ASTPatternStructure)).call(this, N_PatternStructure, [constructorName, parameters]));
@@ -5195,12 +5222,12 @@
}]);
return ASTPatternStructure;
}(ASTNode);
-var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode22) {
- _inherits(ASTPatternTuple, _ASTNode22);
+var ASTPatternTuple = exports.ASTPatternTuple = function (_ASTNode23) {
+ _inherits(ASTPatternTuple, _ASTNode23);
function ASTPatternTuple(parameters) {
_classCallCheck(this, ASTPatternTuple);
return _possibleConstructorReturn(this, (ASTPatternTuple.__proto__ || Object.getPrototypeOf(ASTPatternTuple)).call(this, N_PatternTuple, parameters));
@@ -5214,12 +5241,12 @@
}]);
return ASTPatternTuple;
}(ASTNode);
-var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode23) {
- _inherits(ASTPatternTimeout, _ASTNode23);
+var ASTPatternTimeout = exports.ASTPatternTimeout = function (_ASTNode24) {
+ _inherits(ASTPatternTimeout, _ASTNode24);
function ASTPatternTimeout(timeout) {
_classCallCheck(this, ASTPatternTimeout);
return _possibleConstructorReturn(this, (ASTPatternTimeout.__proto__ || Object.getPrototypeOf(ASTPatternTimeout)).call(this, N_PatternTimeout, [timeout]));
@@ -5240,12 +5267,12 @@
return ASTPatternTimeout;
}(ASTNode);
/* Expressions */
-var ASTExprVariable = exports.ASTExprVariable = function (_ASTNode24) {
- _inherits(ASTExprVariable, _ASTNode24);
+var ASTExprVariable = exports.ASTExprVariable = function (_ASTNode25) {
+ _inherits(ASTExprVariable, _ASTNode25);
function ASTExprVariable(variableName) {
_classCallCheck(this, ASTExprVariable);
return _possibleConstructorReturn(this, (ASTExprVariable.__proto__ || Object.getPrototypeOf(ASTExprVariable)).call(this, N_ExprVariable, [variableName]));
@@ -5259,12 +5286,12 @@
}]);
return ASTExprVariable;
}(ASTNode);
-var ASTExprConstantNumber = exports.ASTExprConstantNumber = function (_ASTNode25) {
- _inherits(ASTExprConstantNumber, _ASTNode25);
+var ASTExprConstantNumber = exports.ASTExprConstantNumber = function (_ASTNode26) {
+ _inherits(ASTExprConstantNumber, _ASTNode26);
function ASTExprConstantNumber(number) {
_classCallCheck(this, ASTExprConstantNumber);
return _possibleConstructorReturn(this, (ASTExprConstantNumber.__proto__ || Object.getPrototypeOf(ASTExprConstantNumber)).call(this, N_ExprConstantNumber, [number]));
@@ -5278,12 +5305,12 @@
}]);
return ASTExprConstantNumber;
}(ASTNode);
-var ASTExprConstantString = exports.ASTExprConstantString = function (_ASTNode26) {
- _inherits(ASTExprConstantString, _ASTNode26);
+var ASTExprConstantString = exports.ASTExprConstantString = function (_ASTNode27) {
+ _inherits(ASTExprConstantString, _ASTNode27);
function ASTExprConstantString(string) {
_classCallCheck(this, ASTExprConstantString);
return _possibleConstructorReturn(this, (ASTExprConstantString.__proto__ || Object.getPrototypeOf(ASTExprConstantString)).call(this, N_ExprConstantString, [string]));
@@ -5297,12 +5324,12 @@
}]);
return ASTExprConstantString;
}(ASTNode);
-var ASTExprChoose = exports.ASTExprChoose = function (_ASTNode27) {
- _inherits(ASTExprChoose, _ASTNode27);
+var ASTExprChoose = exports.ASTExprChoose = function (_ASTNode28) {
+ _inherits(ASTExprChoose, _ASTNode28);
function ASTExprChoose(condition, trueExpr, falseExpr) {
_classCallCheck(this, ASTExprChoose);
return _possibleConstructorReturn(this, (ASTExprChoose.__proto__ || Object.getPrototypeOf(ASTExprChoose)).call(this, N_ExprChoose, [condition, trueExpr, falseExpr]));
@@ -5326,13 +5353,37 @@
}]);
return ASTExprChoose;
}(ASTNode);
-var ASTExprList = exports.ASTExprList = function (_ASTNode28) {
- _inherits(ASTExprList, _ASTNode28);
+var ASTExprMatching = exports.ASTExprMatching = function (_ASTNode29) {
+ _inherits(ASTExprMatching, _ASTNode29);
+ function ASTExprMatching(subject, branches) {
+ _classCallCheck(this, ASTExprMatching);
+
+ return _possibleConstructorReturn(this, (ASTExprMatching.__proto__ || Object.getPrototypeOf(ASTExprMatching)).call(this, N_ExprMatching, [subject, branches]));
+ }
+
+ _createClass(ASTExprMatching, [{
+ key: 'subject',
+ get: function get() {
+ return this._children[0];
+ }
+ }, {
+ key: 'branches',
+ get: function get() {
+ return this._children[1];
+ }
+ }]);
+
+ return ASTExprMatching;
+}(ASTNode);
+
+var ASTExprList = exports.ASTExprList = function (_ASTNode30) {
+ _inherits(ASTExprList, _ASTNode30);
+
function ASTExprList(elements) {
_classCallCheck(this, ASTExprList);
return _possibleConstructorReturn(this, (ASTExprList.__proto__ || Object.getPrototypeOf(ASTExprList)).call(this, N_ExprList, elements));
}
@@ -5345,12 +5396,12 @@
}]);
return ASTExprList;
}(ASTNode);
-var ASTExprRange = exports.ASTExprRange = function (_ASTNode29) {
- _inherits(ASTExprRange, _ASTNode29);
+var ASTExprRange = exports.ASTExprRange = function (_ASTNode31) {
+ _inherits(ASTExprRange, _ASTNode31);
// Note: second may be null
function ASTExprRange(first, second, last) {
_classCallCheck(this, ASTExprRange);
@@ -5375,12 +5426,12 @@
}]);
return ASTExprRange;
}(ASTNode);
-var ASTExprTuple = exports.ASTExprTuple = function (_ASTNode30) {
- _inherits(ASTExprTuple, _ASTNode30);
+var ASTExprTuple = exports.ASTExprTuple = function (_ASTNode32) {
+ _inherits(ASTExprTuple, _ASTNode32);
function ASTExprTuple(elements) {
_classCallCheck(this, ASTExprTuple);
return _possibleConstructorReturn(this, (ASTExprTuple.__proto__ || Object.getPrototypeOf(ASTExprTuple)).call(this, N_ExprTuple, elements));
@@ -5394,12 +5445,12 @@
}]);
return ASTExprTuple;
}(ASTNode);
-var ASTExprStructure = exports.ASTExprStructure = function (_ASTNode31) {
- _inherits(ASTExprStructure, _ASTNode31);
+var ASTExprStructure = exports.ASTExprStructure = function (_ASTNode33) {
+ _inherits(ASTExprStructure, _ASTNode33);
function ASTExprStructure(constructorName, fieldBindings) {
_classCallCheck(this, ASTExprStructure);
return _possibleConstructorReturn(this, (ASTExprStructure.__proto__ || Object.getPrototypeOf(ASTExprStructure)).call(this, N_ExprStructure, [constructorName, fieldBindings]));
@@ -5449,12 +5500,12 @@
}]);
return ASTExprStructure;
}(ASTNode);
-var ASTExprStructureUpdate = exports.ASTExprStructureUpdate = function (_ASTNode32) {
- _inherits(ASTExprStructureUpdate, _ASTNode32);
+var ASTExprStructureUpdate = exports.ASTExprStructureUpdate = function (_ASTNode34) {
+ _inherits(ASTExprStructureUpdate, _ASTNode34);
function ASTExprStructureUpdate(constructorName, original, fieldBindings) {
_classCallCheck(this, ASTExprStructureUpdate);
return _possibleConstructorReturn(this, (ASTExprStructureUpdate.__proto__ || Object.getPrototypeOf(ASTExprStructureUpdate)).call(this, N_ExprStructureUpdate, [constructorName, original, fieldBindings]));
@@ -5509,12 +5560,12 @@
}]);
return ASTExprStructureUpdate;
}(ASTNode);
-var ASTExprFunctionCall = exports.ASTExprFunctionCall = function (_ASTNode33) {
- _inherits(ASTExprFunctionCall, _ASTNode33);
+var ASTExprFunctionCall = exports.ASTExprFunctionCall = function (_ASTNode35) {
+ _inherits(ASTExprFunctionCall, _ASTNode35);
function ASTExprFunctionCall(functionName, args) {
_classCallCheck(this, ASTExprFunctionCall);
return _possibleConstructorReturn(this, (ASTExprFunctionCall.__proto__ || Object.getPrototypeOf(ASTExprFunctionCall)).call(this, N_ExprFunctionCall, [functionName, args]));
@@ -5533,12 +5584,12 @@
}]);
return ASTExprFunctionCall;
}(ASTNode);
-var ASTFieldBinding = exports.ASTFieldBinding = function (_ASTNode34) {
- _inherits(ASTFieldBinding, _ASTNode34);
+var ASTFieldBinding = exports.ASTFieldBinding = function (_ASTNode36) {
+ _inherits(ASTFieldBinding, _ASTNode36);
function ASTFieldBinding(fieldName, value) {
_classCallCheck(this, ASTFieldBinding);
return _possibleConstructorReturn(this, (ASTFieldBinding.__proto__ || Object.getPrototypeOf(ASTFieldBinding)).call(this, N_FieldBinding, [fieldName, value]));
@@ -5557,12 +5608,12 @@
}]);
return ASTFieldBinding;
}(ASTNode);
-var ASTConstructorDeclaration = exports.ASTConstructorDeclaration = function (_ASTNode35) {
- _inherits(ASTConstructorDeclaration, _ASTNode35);
+var ASTConstructorDeclaration = exports.ASTConstructorDeclaration = function (_ASTNode37) {
+ _inherits(ASTConstructorDeclaration, _ASTNode37);
function ASTConstructorDeclaration(constructorName, fieldNames) {
_classCallCheck(this, ASTConstructorDeclaration);
return _possibleConstructorReturn(this, (ASTConstructorDeclaration.__proto__ || Object.getPrototypeOf(ASTConstructorDeclaration)).call(this, N_ConstructorDeclaration, [constructorName, fieldNames]));
@@ -5616,10 +5667,13 @@
var T_ELSEIF = exports.T_ELSEIF = Symbol.for('T_ELSEIF');
var T_ELSE = exports.T_ELSE = Symbol.for('T_ELSE');
var T_CHOOSE = exports.T_CHOOSE = Symbol.for('T_CHOOSE');
var T_WHEN = exports.T_WHEN = Symbol.for('T_WHEN');
var T_OTHERWISE = exports.T_OTHERWISE = Symbol.for('T_OTHERWISE');
+var T_MATCHING = exports.T_MATCHING = Symbol.for('T_MATCHING');
+var T_SELECT = exports.T_SELECT = Symbol.for('T_SELECT');
+var T_ON = exports.T_ON = Symbol.for('T_ON');
var T_REPEAT = exports.T_REPEAT = Symbol.for('T_REPEAT');
var T_FOREACH = exports.T_FOREACH = Symbol.for('T_FOREACH');
var T_IN = exports.T_IN = Symbol.for('T_IN');
var T_WHILE = exports.T_WHILE = Symbol.for('T_WHILE');
var T_SWITCH = exports.T_SWITCH = Symbol.for('T_SWITCH');
@@ -8838,10 +8892,16 @@
'T_NOT': keyword('not'),
'T_DIV': keyword('div'),
'T_MOD': keyword('mod'),
'T_TYPE': keyword('type'),
'T_IS': keyword('is'),
+ 'T_CHOOSE': keyword('choose'),
+ 'T_WHEN': keyword('when'),
+ 'T_OTHERWISE': keyword('otherwise'),
+ 'T_MATCHING': keyword('matching'),
+ 'T_SELECT': keyword('select'),
+ 'T_ON': keyword('on'),
'T_RECORD': keyword('record'),
'T_VARIANT': keyword('variant'),
'T_CASE': keyword('case'),
'T_FIELD': keyword('field'),
'T_UNDERSCORE': 'un guión bajo ("_")',
@@ -9031,14 +9091,14 @@
'errmsg:undeclared-constructor': function errmsgUndeclaredConstructor(name) {
return 'El constructor "' + name + '" no está definido.';
},
- 'errmsg:wildcard-pattern-should-be-last': 'El comodín "_" tiene que ser la última rama del switch.',
+ 'errmsg:wildcard-pattern-should-be-last': 'El comodín "_" debe estar en la última rama.',
'errmsg:variable-pattern-should-be-last': function errmsgVariablePatternShouldBeLast(name) {
- return 'El patrón variable "' + name + '" tiene que ser la última rama del switch.';
+ return 'El patrón variable "' + name + '" tiene debe estar en la última rama.';
},
'errmsg:numeric-pattern-repeats-number': function errmsgNumericPatternRepeatsNumber(number) {
return 'Hay dos ramas distintas para el número "' + number + '".';
},
@@ -9057,11 +9117,11 @@
return 'Los patrones tienen que ser todos del mismo tipo. ' + 'El patrón debería ser de tipo ' + expectedType + 'pero es de tipo ' + patternType + '.';
},
'errmsg:patterns-in-interactive-program-must-be-events': 'Los patrones de un "interactive program" deben ser eventos.',
- 'errmsg:patterns-in-switch-must-not-be-events': 'Los patrones de un "switch" no pueden ser eventos.',
+ 'errmsg:patterns-in-switch-must-not-be-events': 'El patrón no puede ser un evento.',
'errmsg:structure-construction-repeated-field': function errmsgStructureConstructionRepeatedField(constructorName, fieldName) {
return 'El campo "' + fieldName + '" está repetido en ' + 'la instanciación del constructor "' + constructorName + '".';
},
@@ -14478,10 +14538,12 @@
return this._parseExprConstantNumber();
case _token.T_STRING:
return this._parseExprConstantString();
case _token.T_CHOOSE:
return this._parseExprChoose(true /* expectInitialChoose */);
+ case _token.T_MATCHING:
+ return this._parseExprMatching();
case _token.T_UPPERID:
return this._parseExprStructureOrStructureUpdate();
case _token.T_LPAREN:
return this._parseExprTuple(true /* possiblyEmpty */);
case _token.T_LBRACK:
@@ -14564,10 +14626,25 @@
expr1.startPos = startPos;
expr1.endPos = endPos;
return expr1;
}
}
+ }, {
+ key: '_parseExprMatching',
+ value: function _parseExprMatching() {
+ var startPos = this._currentToken.startPos;
+ this._match(_token.T_MATCHING);
+ this._match(_token.T_LPAREN);
+ var subject = this._parseExpression();
+ this._match(_token.T_RPAREN);
+ this._match(_token.T_SELECT);
+ var branches = this._parseMatchingBranches();
+ var result = new _ast.ASTExprMatching(subject, branches);
+ result.startPos = startPos;
+ result.endPos = result.endPos;
+ return result;
+ }
/*
* Parse any of the following constructions:
* (1) Structure with no arguments: "Norte"
* (2) Structure with no arguments and explicit parentheses: "Nil()"
@@ -14824,10 +14901,51 @@
result.startPos = pattern.startPos;
result.endPos = body.endPos;
return result;
}
+ /** MatchingBranch **/
+
+ }, {
+ key: '_parseMatchingBranches',
+ value: function _parseMatchingBranches() {
+ var branches = [];
+ while (this._currentToken.tag !== _token.T_OTHERWISE) {
+ branches.push(this._parseMatchingBranch());
+ }
+ this._match(_token.T_OTHERWISE);
+ return branches;
+ }
+ }, {
+ key: '_parseMatchingBranch',
+ value: function _parseMatchingBranch() {
+ var body = this._parseExpression();
+ switch (this._currentToken.tag) {
+ case _token.T_ON:
+ {
+ this._match(_token.T_ON);
+ var pattern = this._parsePattern();
+ var result = new _ast.ASTMatchingBranch(pattern, body);
+ result.startPos = body.startPos;
+ result.endPos = pattern.endPos;
+ return result;
+ }
+ case _token.T_OTHERWISE:
+ {
+ var _pattern = new _ast.ASTPatternWildcard();
+ _pattern.startPos = this._currentToken.startPos;
+ _pattern.endPos = this._currentToken.endPos;
+ var _result2 = new _ast.ASTMatchingBranch(_pattern, body);
+ _result2.startPos = body.startPos;
+ _result2.endPos = this._currentToken.endPos;
+ return _result2;
+ }
+ default:
+ return fail(this._currentToken.startPos, this._currentToken.endPos, 'expected-but-found', [(0, _i18n.i18n)('<alternative>')([(0, _i18n.i18n)('T_ON'), (0, _i18n.i18n)('T_OTHERWISE')]), (0, _i18n.i18n)(Symbol.keyFor(this._currentToken.tag))]);
+ }
+ }
+
/** FieldBinding **/
}, {
key: '_parseFieldBinding',
value: function _parseFieldBinding() {
@@ -15031,10 +15149,13 @@
'foreach': _token.T_FOREACH,
'in': _token.T_IN,
'while': _token.T_WHILE,
'switch': _token.T_SWITCH,
'to': _token.T_TO,
+ 'matching': _token.T_MATCHING,
+ 'select': _token.T_SELECT,
+ 'on': _token.T_ON,
/* Assignment */
'let': _token.T_LET,
/* Operators */
'not': _token.T_NOT,
'div': _token.T_DIV,
@@ -16055,10 +16176,15 @@
);
}
}, {
key: '_lintSwitchBranches',
value: function _lintSwitchBranches(branches, isInteractiveProgram) {
+ this._lintBranches(branches, isInteractiveProgram, false /* isMatching */);
+ }
+ }, {
+ key: '_lintBranches',
+ value: function _lintBranches(branches, isInteractiveProgram, isMatching) {
/* Check that each pattern is well-formed */
var _iteratorNormalCompletion8 = true;
var _didIteratorError8 = false;
var _iteratorError8 = undefined;
@@ -16081,17 +16207,17 @@
throw _iteratorError8;
}
}
}
- this._switchBranchesCheckWildcardAndVariable(branches);
- this._switchBranchesCheckNoRepeats(branches);
- this._switchBranchesCheckCompatible(branches);
+ this._branchesCheckWildcardAndVariable(branches);
+ this._branchesCheckNoRepeats(branches);
+ this._branchesCheckCompatible(branches);
if (isInteractiveProgram) {
- this._switchBranchesCheckTypeEvent(branches);
+ this._branchesCheckTypeEvent(branches);
} else {
- this._switchBranchesCheckTypeNotEvent(branches);
+ this._branchesCheckTypeNotEvent(branches);
}
/* Lint recursively each branch */
var _iteratorNormalCompletion9 = true;
var _didIteratorError9 = false;
@@ -16099,11 +16225,11 @@
try {
for (var _iterator9 = branches[Symbol.iterator](), _step9; !(_iteratorNormalCompletion9 = (_step9 = _iterator9.next()).done); _iteratorNormalCompletion9 = true) {
var _branch = _step9.value;
- this._lintSwitchBranchBody(_branch);
+ this._lintBranchBody(_branch, isMatching);
}
} catch (err) {
_didIteratorError9 = true;
_iteratorError9 = err;
} finally {
@@ -16120,12 +16246,12 @@
}
/* Check that there is at most one wildcard/variable pattern at the end */
}, {
- key: '_switchBranchesCheckWildcardAndVariable',
- value: function _switchBranchesCheckWildcardAndVariable(branches) {
+ key: '_branchesCheckWildcardAndVariable',
+ value: function _branchesCheckWildcardAndVariable(branches) {
var i = 0;
var n = branches.length;
var _iteratorNormalCompletion10 = true;
var _didIteratorError10 = false;
var _iteratorError10 = undefined;
@@ -16160,12 +16286,12 @@
/* Check that there are no repeated constructors in a sequence
* of branches. */
}, {
- key: '_switchBranchesCheckNoRepeats',
- value: function _switchBranchesCheckNoRepeats(branches) {
+ key: '_branchesCheckNoRepeats',
+ value: function _branchesCheckNoRepeats(branches) {
var coveredNumbers = {};
var coveredConstructors = {};
var coveredTuples = {};
var coveredTimeout = false;
var _iteratorNormalCompletion11 = true;
@@ -16229,12 +16355,12 @@
/* Check that constructors are compatible,
* i.e. that they belong to the same type */
}, {
- key: '_switchBranchesCheckCompatible',
- value: function _switchBranchesCheckCompatible(branches) {
+ key: '_branchesCheckCompatible',
+ value: function _branchesCheckCompatible(branches) {
var expectedType = null;
var _iteratorNormalCompletion12 = true;
var _didIteratorError12 = false;
var _iteratorError12 = undefined;
@@ -16266,12 +16392,12 @@
}
/* Check that there are patterns are of type Event */
}, {
- key: '_switchBranchesCheckTypeEvent',
- value: function _switchBranchesCheckTypeEvent(branches) {
+ key: '_branchesCheckTypeEvent',
+ value: function _branchesCheckTypeEvent(branches) {
var _iteratorNormalCompletion13 = true;
var _didIteratorError13 = false;
var _iteratorError13 = undefined;
try {
@@ -16300,12 +16426,12 @@
}
/* Check that there are no patterns of type Event */
}, {
- key: '_switchBranchesCheckTypeNotEvent',
- value: function _switchBranchesCheckTypeNotEvent(branches) {
+ key: '_branchesCheckTypeNotEvent',
+ value: function _branchesCheckTypeNotEvent(branches) {
var _iteratorNormalCompletion14 = true;
var _didIteratorError14 = false;
var _iteratorError14 = undefined;
try {
@@ -16334,12 +16460,12 @@
}
/* Recursively lint the body of each branch. Locally bind variables. */
}, {
- key: '_lintSwitchBranchBody',
- value: function _lintSwitchBranchBody(branch) {
+ key: '_lintBranchBody',
+ value: function _lintBranchBody(branch, isMatching) {
var _iteratorNormalCompletion15 = true;
var _didIteratorError15 = false;
var _iteratorError15 = undefined;
try {
@@ -16361,11 +16487,15 @@
throw _iteratorError15;
}
}
}
- this._lintStatement(branch.body);
+ if (isMatching) {
+ this._lintExpression(branch.body);
+ } else {
+ this._lintStatement(branch.body);
+ }
var _iteratorNormalCompletion16 = true;
var _didIteratorError16 = false;
var _iteratorError16 = undefined;
try {
@@ -16580,10 +16710,12 @@
return this._lintExprConstantNumber(expression);
case _ast.N_ExprConstantString:
return this._lintExprConstantString(expression);
case _ast.N_ExprChoose:
return this._lintExprChoose(expression);
+ case _ast.N_ExprMatching:
+ return this._lintExprMatching(expression);
case _ast.N_ExprList:
return this._lintExprList(expression);
case _ast.N_ExprRange:
return this._lintExprRange(expression);
case _ast.N_ExprTuple:
@@ -16621,10 +16753,23 @@
this._lintExpression(expression.condition);
this._lintExpression(expression.trueExpr);
this._lintExpression(expression.falseExpr);
}
}, {
+ key: '_lintExprMatching',
+ value: function _lintExprMatching(expression) {
+ this._lintExpression(expression.subject);
+ this._lintMatchingBranches(expression.branches);
+ }
+ }, {
+ key: '_lintMatchingBranches',
+ value: function _lintMatchingBranches(branches) {
+ this._lintBranches(branches, false /* !isInteractiveProgram */
+ , true /* isMatching */
+ );
+ }
+ }, {
key: '_lintExprList',
value: function _lintExprList(expression) {
var _iteratorNormalCompletion19 = true;
var _didIteratorError19 = false;
var _iteratorError19 = undefined;
@@ -17320,11 +17465,11 @@
* followed by a Return instruction. */
}, {
key: '_compileDefInteractiveProgram',
value: function _compileDefInteractiveProgram(definition) {
- this._compileMatchSwitchBranches(definition);
+ this._compileMatchBranches(definition, false /* isMatching */);
this._produce(definition.startPos, definition.endPos, new _instruction.IReturn());
}
/* A procedure definition:
*
@@ -17671,15 +17816,15 @@
}, {
key: '_compileStmtSwitch',
value: function _compileStmtSwitch(statement) {
/* Compile the subject */
this._compileExpression(statement.subject);
- this._compileMatchSwitchBranches(statement);
+ this._compileMatchBranches(statement, false /* !isMatching */);
}
}, {
- key: '_compileMatchSwitchBranches',
- value: function _compileMatchSwitchBranches(statement) {
+ key: '_compileMatchBranches',
+ value: function _compileMatchBranches(statement, isMatching) {
var branchLabels = [];
/* Attempt to match each pattern */
var _iteratorNormalCompletion4 = true;
var _didIteratorError4 = false;
var _iteratorError4 = undefined;
@@ -17717,11 +17862,15 @@
var branch = statement.branches[i];
var label = branchLabels[i];
this._produce(branch.startPos, branch.endPos, new _instruction.ILabel(label));
this._compilePatternBind(branch.pattern);
this._produce(branch.startPos, branch.endPos, new _instruction.IPop());
- this._compileStatement(branch.body);
+ if (isMatching) {
+ this._compileExpression(branch.body);
+ } else {
+ this._compileStatement(branch.body);
+ }
this._compilePatternUnbind(branch.pattern);
this._produce(branch.startPos, branch.endPos, new _instruction.IJump(labelEnd));
}
this._produce(statement.startPos, statement.endPos, new _instruction.ILabel(labelEnd));
}
@@ -17993,10 +18142,12 @@
return this._compileExprConstantNumber(expression);
case _ast.N_ExprConstantString:
return this._compileExprConstantString(expression);
case _ast.N_ExprChoose:
return this._compileExprChoose(expression);
+ case _ast.N_ExprMatching:
+ return this._compileExprMatching(expression);
case _ast.N_ExprList:
return this._compileExprList(expression);
case _ast.N_ExprRange:
return this._compileExprRange(expression);
case _ast.N_ExprTuple:
@@ -18066,9 +18217,15 @@
this._compileExpression(expression.trueExpr);
var labelEnd = this._freshLabel();
this._produceList(expression.startPos, expression.endPos, [new _instruction.IJump(labelEnd), new _instruction.ILabel(labelOtherwise)]);
this._compileExpression(expression.falseExpr);
this._produce(expression.startPos, expression.endPos, new _instruction.ILabel(labelEnd));
+ }
+ }, {
+ key: '_compileExprMatching',
+ value: function _compileExprMatching(expression) {
+ this._compileExpression(expression.subject);
+ this._compileMatchBranches(expression, true /* isMatching */);
}
}, {
key: '_compileExprList',
value: function _compileExprList(expression) {
var _iteratorNormalCompletion7 = true;
\ No newline at end of file