()
| 222 | } |
| 223 | |
| 224 | tokenize(): void { |
| 225 | while (this._cursor.peek() !== chars.$EOF) { |
| 226 | const start = this._cursor.clone(); |
| 227 | try { |
| 228 | if (this._attemptCharCode(chars.$LT)) { |
| 229 | if (this._attemptCharCode(chars.$BANG)) { |
| 230 | if (this._attemptCharCode(chars.$LBRACKET)) { |
| 231 | this._consumeCdata(start); |
| 232 | } else if (this._attemptCharCode(chars.$MINUS)) { |
| 233 | this._consumeComment(start); |
| 234 | } else { |
| 235 | this._consumeDocType(start); |
| 236 | } |
| 237 | } else if (this._attemptCharCode(chars.$SLASH)) { |
| 238 | this._consumeTagClose(start); |
| 239 | } else { |
| 240 | this._consumeTagOpen(start); |
| 241 | } |
| 242 | } else if ( |
| 243 | this._tokenizeLet && |
| 244 | // Use `peek` instead of `attempCharCode` since we |
| 245 | // don't want to advance in case it's not `@let`. |
| 246 | this._cursor.peek() === chars.$AT && |
| 247 | !this._inInterpolation && |
| 248 | this._isLetStart() |
| 249 | ) { |
| 250 | this._consumeLetDeclaration(start); |
| 251 | } else if (this._tokenizeBlocks && this._isBlockStart()) { |
| 252 | this._consumeBlockStart(start); |
| 253 | } else if ( |
| 254 | this._tokenizeBlocks && |
| 255 | !this._inInterpolation && |
| 256 | !this._isInExpansionCase() && |
| 257 | !this._isInExpansionForm() && |
| 258 | this._attemptCharCode(chars.$RBRACE) |
| 259 | ) { |
| 260 | this._consumeBlockEnd(start); |
| 261 | } else if (!(this._tokenizeIcu && this._tokenizeExpansionForm())) { |
| 262 | // In (possibly interpolated) text the end of the text is given by `isTextEnd()`, while |
| 263 | // the premature end of an interpolation is given by the start of a new HTML element. |
| 264 | this._consumeWithInterpolation( |
| 265 | TokenType.TEXT, |
| 266 | TokenType.INTERPOLATION, |
| 267 | () => this._isTextEnd(), |
| 268 | () => this._isTagStart(), |
| 269 | ); |
| 270 | } |
| 271 | } catch (e) { |
| 272 | this.handleError(e); |
| 273 | } |
| 274 | } |
| 275 | this._beginToken(TokenType.EOF); |
| 276 | this._endToken([]); |
| 277 | } |
| 278 | |
| 279 | private _getBlockName(): string { |
| 280 | // This allows us to capture up something like `@else if`, but not `@ if`. |
no test coverage detected