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