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