UNPKG

@cucumber/gherkin

Version:
32 lines 1.36 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UnexpectedEOFException = exports.UnexpectedTokenException = void 0; const Errors_1 = require("./Errors"); class UnexpectedTokenException extends Errors_1.GherkinException { static create(token, expectedTokenTypes) { const message = `expected: ${expectedTokenTypes.join(', ')}, got '${token .getTokenValue() .trim()}'`; const location = tokenLocation(token); return UnexpectedTokenException._create(message, location); } } exports.UnexpectedTokenException = UnexpectedTokenException; class UnexpectedEOFException extends Errors_1.GherkinException { static create(token, expectedTokenTypes) { const message = `unexpected end of file, expected: ${expectedTokenTypes.join(', ')}`; const location = tokenLocation(token); return UnexpectedEOFException._create(message, location); } } exports.UnexpectedEOFException = UnexpectedEOFException; function tokenLocation(token) { var _a; return ((_a = token.location) === null || _a === void 0 ? void 0 : _a.line) && token.line && token.line.indent !== undefined ? { line: token.location.line, column: token.line.indent + 1, } : token.location; } //# sourceMappingURL=TokenExceptions.js.map