xast
Version:
AST parsing library
29 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.readComment = void 0;
const TokenKind_1 = require("../TokenKind");
const createToken_1 = require("../createToken");
const characterClasses_1 = require("../characterClasses");
const readComment = (lexer, start) => {
const body = lexer.source.body;
const bodyLength = body.length;
let position = start + 1;
while (position < bodyLength) {
const code = body.charCodeAt(position);
if (code === 0x000a || code === 0x000d) {
break;
}
if ((0, characterClasses_1.isUnicodeScalarValue)(code)) {
++position;
}
else if ((0, characterClasses_1.isSupplementaryCodePoint)(body, position)) {
position += 2;
}
else {
break;
}
}
return (0, createToken_1.createToken)(lexer, TokenKind_1.TokenKind.COMMENT, start, position, body.slice(start + 1, position));
};
exports.readComment = readComment;
//# sourceMappingURL=readComment.js.map