1 | var Token = (function () {
|
2 | function Token(offset, type, language) {
|
3 | this.offset = offset | 0;
|
4 | this.type = type;
|
5 | this.language = language;
|
6 | this.mods = 0;
|
7 | this.value = null;
|
8 | this.stack = null;
|
9 | }
|
10 | Token.prototype.toString = function () {
|
11 | return this.value || '';
|
12 | };
|
13 | Object.defineProperty(Token.prototype, "span", {
|
14 | get: function () {
|
15 | return { offset: this.offset, length: (this.value ? this.value.length : 0) };
|
16 | },
|
17 | enumerable: true,
|
18 | configurable: true
|
19 | });
|
20 | Object.defineProperty(Token.prototype, "indent", {
|
21 | get: function () {
|
22 | return 0;
|
23 | },
|
24 | enumerable: true,
|
25 | configurable: true
|
26 | });
|
27 | Token.prototype.match = function (val) {
|
28 | if (typeof val == 'string') {
|
29 | if (val.indexOf(' ') > 0) {
|
30 | val = val.split(' ');
|
31 | }
|
32 | else {
|
33 | var idx = this.type.indexOf(val);
|
34 | return (val[0] == '.') ? idx >= 0 : idx == 0;
|
35 | }
|
36 | }
|
37 | if (val instanceof Array) {
|
38 | for (var _i = 0, val_1 = val; _i < val_1.length; _i++) {
|
39 | var item = val_1[_i];
|
40 | var idx = this.type.indexOf(item);
|
41 | var hit = (item[0] == '.') ? idx >= 0 : idx == 0;
|
42 | if (hit)
|
43 | return true;
|
44 | }
|
45 | }
|
46 | if (val instanceof RegExp) {
|
47 | return val.test(this.type);
|
48 | }
|
49 | return false;
|
50 | };
|
51 | return Token;
|
52 | }());
|
53 | export { Token };
|
54 | var TokenizationResult = (function () {
|
55 | function TokenizationResult(tokens, endState) {
|
56 | this.tokens = tokens;
|
57 | this.endState = endState;
|
58 | }
|
59 | return TokenizationResult;
|
60 | }());
|
61 | export { TokenizationResult };
|