(indent = 0)
| 34628 | } |
| 34629 | |
| 34630 | parse(indent = 0) { |
| 34631 | const obj = (0, (_map || _load_map()).default)(); |
| 34632 | |
| 34633 | while (true) { |
| 34634 | const propToken = this.token; |
| 34635 | |
| 34636 | if (propToken.type === TOKEN_TYPES.newline) { |
| 34637 | const nextToken = this.next(); |
| 34638 | if (!indent) { |
| 34639 | // if we have 0 indentation then the next token doesn't matter |
| 34640 | continue; |
| 34641 | } |
| 34642 | |
| 34643 | if (nextToken.type !== TOKEN_TYPES.indent) { |
| 34644 | // if we have no indentation after a newline then we've gone down a level |
| 34645 | break; |
| 34646 | } |
| 34647 | |
| 34648 | if (nextToken.value === indent) { |
| 34649 | // all is good, the indent is on our level |
| 34650 | this.next(); |
| 34651 | } else { |
| 34652 | // the indentation is less than our level |
| 34653 | break; |
| 34654 | } |
| 34655 | } else if (propToken.type === TOKEN_TYPES.indent) { |
| 34656 | if (propToken.value === indent) { |
| 34657 | this.next(); |
| 34658 | } else { |
| 34659 | break; |
| 34660 | } |
| 34661 | } else if (propToken.type === TOKEN_TYPES.eof) { |
| 34662 | break; |
| 34663 | } else if (propToken.type === TOKEN_TYPES.string) { |
| 34664 | // property key |
| 34665 | const key = propToken.value; |
| 34666 | (0, (_invariant || _load_invariant()).default)(key, 'Expected a key'); |
| 34667 | |
| 34668 | const keys = [key]; |
| 34669 | this.next(); |
| 34670 | |
| 34671 | // support multiple keys |
| 34672 | while (this.token.type === TOKEN_TYPES.comma) { |
| 34673 | this.next(); // skip comma |
| 34674 | |
| 34675 | const keyToken = this.token; |
| 34676 | if (keyToken.type !== TOKEN_TYPES.string) { |
| 34677 | this.unexpected('Expected string'); |
| 34678 | } |
| 34679 | |
| 34680 | const key = keyToken.value; |
| 34681 | (0, (_invariant || _load_invariant()).default)(key, 'Expected a key'); |
| 34682 | keys.push(key); |
| 34683 | this.next(); |
| 34684 | } |
| 34685 | |
| 34686 | const wasColon = this.token.type === TOKEN_TYPES.colon; |
| 34687 | if (wasColon) { |
no test coverage detected