blob: 30a6a9e502f4e8bfce38f974a9f3bcb9bb815dec (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
"use strict";
exports.__esModule = true;
var _location = require("../util/location");
var _context = require("./context");
var _types = require("./types");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var State = function () {
function State() {
_classCallCheck(this, State);
}
State.prototype.init = function init(options, input) {
this.strict = options.strictMode === false ? false : options.sourceType === "module";
this.input = input;
this.potentialArrowAt = -1;
this.inMethod = this.inFunction = this.inGenerator = this.inAsync = false;
this.labels = [];
this.decorators = [];
this.tokens = [];
this.comments = [];
this.trailingComments = [];
this.leadingComments = [];
this.commentStack = [];
this.pos = this.lineStart = 0;
this.curLine = 1;
this.type = _types.types.eof;
this.value = null;
this.start = this.end = this.pos;
this.startLoc = this.endLoc = this.curPosition();
this.lastTokEndLoc = this.lastTokStartLoc = null;
this.lastTokStart = this.lastTokEnd = this.pos;
this.context = [_context.types.braceStatement];
this.exprAllowed = true;
this.containsEsc = this.containsOctal = false;
this.octalPosition = null;
this.exportedIdentifiers = [];
return this;
};
// TODO
// TODO
// Used to signify the start of a potential arrow function
// Flags to track whether we are in a function, a generator.
// Labels in scope.
// Leading decorators.
// Token store.
// Comment store.
// Comment attachment store
// The current position of the tokenizer in the input.
// Properties of the current token:
// Its type
// For tokens that include more information than their type, the value
// Its start and end offset
// And, if locations are used, the {line, column} object
// corresponding to those offsets
// Position information for the previous token
// The context stack is used to superficially track syntactic
// context to predict whether a regular expression is allowed in a
// given position.
// Used to signal to callers of `readWord1` whether the word
// contained any escape sequences. This is needed because words with
// escape sequences must not be interpreted as keywords.
// TODO
// Names of exports store. `default` is stored as a name for both
// `export default foo;` and `export { foo as default };`.
State.prototype.curPosition = function curPosition() {
return new _location.Position(this.curLine, this.pos - this.lineStart);
};
State.prototype.clone = function clone(skipArrays) {
var state = new State();
for (var key in this) {
var val = this[key];
if ((!skipArrays || key === "context") && Array.isArray(val)) {
val = val.slice();
}
state[key] = val;
}
return state;
};
return State;
}();
exports.default = State;
|