mirror of
https://github.com/tiennm99/MTTools.git
synced 2026-10-14 04:16:25 +00:00
Init
This commit is contained in:
1 parent
b5c881f56f
commit
6ba2247509
4280 files changed
+484929
No files matched your search
+43
@@ -0,0 +1,43 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.getLineInfo = getLineInfo;
|
||||
exports.SourceLocation = exports.Position = void 0;
|
||||
|
||||
var _whitespace = require("./whitespace");
|
||||
|
||||
class Position {
|
||||
constructor(line, col) {
|
||||
this.line = line;
|
||||
this.column = col;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.Position = Position;
|
||||
|
||||
class SourceLocation {
|
||||
constructor(start, end) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
exports.SourceLocation = SourceLocation;
|
||||
|
||||
function getLineInfo(input, offset) {
|
||||
let line = 1;
|
||||
let lineStart = 0;
|
||||
let match;
|
||||
_whitespace.lineBreakG.lastIndex = 0;
|
||||
|
||||
while ((match = _whitespace.lineBreakG.exec(input)) && match.index < offset) {
|
||||
line++;
|
||||
lineStart = _whitespace.lineBreakG.lastIndex;
|
||||
}
|
||||
|
||||
return new Position(line, offset - lineStart);
|
||||
}
|
||||
Reference in new issue
Block a user