numenor
Version:
Customizable, safe evaluator of JavaScript-like expressions.
33 lines (27 loc) • 1.14 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.InvalidArgumentList = exports.InvalidLeftHandSide = exports.UnexpectedToken = exports.UnknownToken = void 0;
function str(tokenType) {
// Symbol(Foo) -> Foo
return tokenType.toString().replace(/^.+?\((.+?)\)/, '$1');
}
var UnknownToken = function UnknownToken(_ref) {
var lexeme = _ref.lexeme,
line = _ref.line,
col = _ref.col;
return "Unexpected ".concat(JSON.stringify(lexeme), " at line ").concat(line, ":").concat(col);
};
exports.UnknownToken = UnknownToken;
var UnexpectedToken = function UnexpectedToken(tokenType, _ref2) {
var lexeme = _ref2.lexeme,
line = _ref2.line,
col = _ref2.col;
return "Expected ".concat(str(tokenType), " but found ").concat(JSON.stringify(lexeme), " at line ").concat(line, ":").concat(col);
};
exports.UnexpectedToken = UnexpectedToken;
var InvalidLeftHandSide = "Invalid left-hand side in assignment";
exports.InvalidLeftHandSide = InvalidLeftHandSide;
var InvalidArgumentList = "Invalid argument list in lambda expression";
exports.InvalidArgumentList = InvalidArgumentList;