()
| 79 | } |
| 80 | |
| 81 | private parseArray(): any[] { |
| 82 | const arr: any[] = []; |
| 83 | this.expectChar('['); |
| 84 | this.skipWhitespace(); |
| 85 | // Empty array? |
| 86 | if (this.currentChar() === ']') { |
| 87 | this.index++; // consume "]" |
| 88 | return arr; |
| 89 | } |
| 90 | while (true) { |
| 91 | this.skipWhitespace(); |
| 92 | arr.push(this.parseValue()); |
| 93 | this.skipWhitespace(); |
| 94 | if (this.currentChar() === ',') { |
| 95 | this.index++; // consume comma |
| 96 | this.skipWhitespace(); |
| 97 | // Allow trailing comma: |
| 98 | if (this.currentChar() === ']') { |
| 99 | this.index++; |
| 100 | break; |
| 101 | } |
| 102 | } else if (this.currentChar() === ']') { |
| 103 | this.index++; // consume "]" |
| 104 | break; |
| 105 | } else { |
| 106 | throw this.error( |
| 107 | `Expected ',' or ']' in array but found '${this.currentChar()}'` |
| 108 | ); |
| 109 | } |
| 110 | } |
| 111 | return arr; |
| 112 | } |
| 113 | |
| 114 | private parseString(): string { |
| 115 | const quote = this.currentChar(); |
no test coverage detected