-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCaseInsensitiveInputStream.js
67 lines (54 loc) · 1.68 KB
/
CaseInsensitiveInputStream.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//
/* Copyright (c) 2012-2017 The ANTLR Project. All rights reserved.
* Use of this file is governed by the BSD 3-clause license that
* can be found in the LICENSE.txt file in the project root.
*/
//
function CaseInsensitiveInputStream(stream, upper) {
this._stream = stream;
this._case = upper ? String.prototype.toUpperCase : String.prototype.toLowerCase;
return this;
}
Object.defineProperty(CaseInsensitiveInputStream.prototype, 'index', {
get: function() {
return this._stream.index;
}
});
Object.defineProperty(CaseInsensitiveInputStream.prototype, 'size', {
get: function() {
return this._stream.size;
}
});
CaseInsensitiveInputStream.prototype.LA = function (offset) {
const cp = this._stream.LA(offset);
if (cp <= 0) {
return cp;
}
const c = this._case.call(String.fromCodePoint(cp));
return c.codePointAt(0);
};
CaseInsensitiveInputStream.prototype.reset = function() {
this._stream.reset();
};
CaseInsensitiveInputStream.prototype.consume = function() {
this._stream.consume();
};
CaseInsensitiveInputStream.prototype.LT = function(offset) {
return this._stream.LT(offset);
};
CaseInsensitiveInputStream.prototype.mark = function() {
return this._stream.mark();
};
CaseInsensitiveInputStream.prototype.release = function(marker) {
this._stream.release(marker);
};
CaseInsensitiveInputStream.prototype.seek = function(index) {
this._stream.seek(index);
};
CaseInsensitiveInputStream.prototype.getText = function(start, stop) {
return this._stream.getText(start, stop);
};
CaseInsensitiveInputStream.prototype.toString = function() {
return this._stream.toString();
};
exports.CaseInsensitiveInputStream = CaseInsensitiveInputStream;