()
| 788 | } |
| 789 | |
| 790 | parseObjectPropertyKey(): Node.PropertyKey { |
| 791 | const node = this.createNode(); |
| 792 | const token = this.nextToken(); |
| 793 | |
| 794 | let key: Node.PropertyKey; |
| 795 | switch (token.type) { |
| 796 | case Token.StringLiteral: |
| 797 | case Token.NumericLiteral: |
| 798 | if (this.context.strict && token.octal) { |
| 799 | this.tolerateUnexpectedToken(token, Messages.StrictOctalLiteral); |
| 800 | } |
| 801 | const raw = this.getTokenRaw(token); |
| 802 | key = this.finalize(node, new Node.Literal(token.value as string, raw)); |
| 803 | break; |
| 804 | |
| 805 | case Token.Identifier: |
| 806 | case Token.BooleanLiteral: |
| 807 | case Token.NullLiteral: |
| 808 | case Token.Keyword: |
| 809 | key = this.finalize(node, new Node.Identifier(token.value)); |
| 810 | break; |
| 811 | |
| 812 | case Token.Punctuator: |
| 813 | if (token.value === '[') { |
| 814 | key = this.isolateCoverGrammar(this.parseAssignmentExpression); |
| 815 | this.expect(']'); |
| 816 | } else { |
| 817 | key = this.throwUnexpectedToken(token); |
| 818 | } |
| 819 | break; |
| 820 | |
| 821 | default: |
| 822 | key = this.throwUnexpectedToken(token); |
| 823 | } |
| 824 | |
| 825 | return key; |
| 826 | } |
| 827 | |
| 828 | isPropertyKey(key, value) { |
| 829 | return (key.type === Syntax.Identifier && key.name === value) || |
no test coverage detected