(start: CharacterCursor)
| 397 | } |
| 398 | |
| 399 | private _consumeLetDeclaration(start: CharacterCursor) { |
| 400 | this._requireStr('@let'); |
| 401 | this._beginToken(TokenType.LET_START, start); |
| 402 | |
| 403 | // Require at least one white space after the `@let`. |
| 404 | if (chars.isWhitespace(this._cursor.peek())) { |
| 405 | this._attemptCharCodeUntilFn(isNotWhitespace); |
| 406 | } else { |
| 407 | const token = this._endToken([this._cursor.getChars(start)]); |
| 408 | token.type = TokenType.INCOMPLETE_LET; |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | const startToken = this._endToken([this._getLetDeclarationName()]); |
| 413 | |
| 414 | // Skip over white space before the equals character. |
| 415 | this._attemptCharCodeUntilFn(isNotWhitespace); |
| 416 | |
| 417 | // Expect an equals sign. |
| 418 | if (!this._attemptCharCode(chars.$EQ)) { |
| 419 | startToken.type = TokenType.INCOMPLETE_LET; |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | // Skip spaces after the equals. |
| 424 | this._attemptCharCodeUntilFn((code) => isNotWhitespace(code) && !chars.isNewLine(code)); |
| 425 | this._consumeLetDeclarationValue(); |
| 426 | |
| 427 | // Terminate the `@let` with a semicolon. |
| 428 | const endChar = this._cursor.peek(); |
| 429 | if (endChar === chars.$SEMICOLON) { |
| 430 | this._beginToken(TokenType.LET_END); |
| 431 | this._cursor.advance(); |
| 432 | this._endToken([]); |
| 433 | } else { |
| 434 | startToken.type = TokenType.INCOMPLETE_LET; |
| 435 | startToken.sourceSpan = this._cursor.getSpan(start); |
| 436 | } |
| 437 | } |
| 438 | |
| 439 | private _getLetDeclarationName(): string { |
| 440 | const nameCursor = this._cursor.clone(); |
no test coverage detected