(
nestingLevel: number,
expectingCloseTag: boolean,
value: string,
openingBracePosition: Position
)
| 633 | } |
| 634 | |
| 635 | private parseArgumentOptions( |
| 636 | nestingLevel: number, |
| 637 | expectingCloseTag: boolean, |
| 638 | value: string, |
| 639 | openingBracePosition: Position |
| 640 | ): Result<MessageFormatElement, ParserError> { |
| 641 | // Parse this range: |
| 642 | // {name, type, style} |
| 643 | // ^---^ |
| 644 | let typeStartPosition = this.clonePosition() |
| 645 | let argType = this.parseIdentifierIfPossible().value |
| 646 | let typeEndPosition = this.clonePosition() |
| 647 | |
| 648 | switch (argType) { |
| 649 | case '': |
| 650 | // Expecting a style string number, date, time, plural, selectordinal, or select. |
| 651 | return this.error( |
| 652 | ErrorKind.EXPECT_ARGUMENT_TYPE, |
| 653 | createLocation(typeStartPosition, typeEndPosition) |
| 654 | ) |
| 655 | case 'number': |
| 656 | case 'date': |
| 657 | case 'time': { |
| 658 | // Parse this range: |
| 659 | // {name, number, style} |
| 660 | // ^-------^ |
| 661 | this.bumpSpace() |
| 662 | let styleAndLocation: { |
| 663 | style: string |
| 664 | styleLocation: Location |
| 665 | } | null = null |
| 666 | |
| 667 | if (this.bumpIf(',')) { |
| 668 | this.bumpSpace() |
| 669 | |
| 670 | const styleStartPosition = this.clonePosition() |
| 671 | const result = this.parseSimpleArgStyleIfPossible() |
| 672 | if (result.err) { |
| 673 | return result |
| 674 | } |
| 675 | const style = trimEnd(result.val) |
| 676 | |
| 677 | if (style.length === 0) { |
| 678 | return this.error( |
| 679 | ErrorKind.EXPECT_ARGUMENT_STYLE, |
| 680 | createLocation(this.clonePosition(), this.clonePosition()) |
| 681 | ) |
| 682 | } |
| 683 | |
| 684 | const styleLocation = createLocation( |
| 685 | styleStartPosition, |
| 686 | this.clonePosition() |
| 687 | ) |
| 688 | styleAndLocation = {style, styleLocation} |
| 689 | } |
| 690 | |
| 691 | const argCloseResult = this.tryParseArgumentClose(openingBracePosition) |
| 692 | if (argCloseResult.err) { |
no test coverage detected