()
| 126 | } |
| 127 | |
| 128 | getNextToken() { |
| 129 | if (this.buffer.length === 0) { |
| 130 | |
| 131 | const comments: Comment[] = this.scanner.scanComments(); |
| 132 | if (this.scanner.trackComment) { |
| 133 | for (let i = 0; i < comments.length; ++i) { |
| 134 | const e: Comment = comments[i]; |
| 135 | const value = this.scanner.source.slice(e.slice[0], e.slice[1]); |
| 136 | const comment: BufferEntry = { |
| 137 | type: e.multiLine ? 'BlockComment' : 'LineComment', |
| 138 | value: value |
| 139 | }; |
| 140 | if (this.trackRange) { |
| 141 | comment.range = e.range; |
| 142 | } |
| 143 | if (this.trackLoc) { |
| 144 | comment.loc = e.loc; |
| 145 | } |
| 146 | this.buffer.push(comment); |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | if (!this.scanner.eof()) { |
| 151 | let loc; |
| 152 | |
| 153 | if (this.trackLoc) { |
| 154 | loc = { |
| 155 | start: { |
| 156 | line: this.scanner.lineNumber, |
| 157 | column: this.scanner.index - this.scanner.lineStart |
| 158 | }, |
| 159 | end: {} |
| 160 | }; |
| 161 | } |
| 162 | |
| 163 | const startRegex = (this.scanner.source[this.scanner.index] === '/') && this.reader.isRegexStart(); |
| 164 | const token = startRegex ? this.scanner.scanRegExp() : this.scanner.lex(); |
| 165 | this.reader.push(token); |
| 166 | |
| 167 | const entry: BufferEntry = { |
| 168 | type: TokenName[token.type], |
| 169 | value: this.scanner.source.slice(token.start, token.end) |
| 170 | }; |
| 171 | if (this.trackRange) { |
| 172 | entry.range = [token.start, token.end]; |
| 173 | } |
| 174 | if (this.trackLoc) { |
| 175 | loc.end = { |
| 176 | line: this.scanner.lineNumber, |
| 177 | column: this.scanner.index - this.scanner.lineStart |
| 178 | }; |
| 179 | entry.loc = loc; |
| 180 | } |
| 181 | if (token.type === Token.RegularExpression) { |
| 182 | const pattern = token.pattern as string; |
| 183 | const flags = token.flags as string; |
| 184 | entry.regex = { pattern, flags }; |
| 185 | } |
no test coverage detected