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