| 34206 | } |
| 34207 | |
| 34208 | parse(indent = 0) { |
| 34209 | const obj = (0, (_map || _load_map()).default)(); |
| 34210 | |
| 34211 | while (true) { |
| 34212 | const propToken = this.token; |
| 34213 | |
| 34214 | if (propToken.type === TOKEN_TYPES.newline) { |
| 34215 | const nextToken = this.next(); |
| 34216 | if (!indent) { |
| 34217 | // if we have 0 indentation then the next token doesn't matter |
| 34218 | continue; |
| 34219 | } |
| 34220 | |
| 34221 | if (nextToken.type !== TOKEN_TYPES.indent) { |
| 34222 | // if we have no indentation after a newline then we've gone down a level |
| 34223 | break; |
| 34224 | } |
| 34225 | |
| 34226 | if (nextToken.value === indent) { |
| 34227 | // all is good, the indent is on our level |
| 34228 | this.next(); |
| 34229 | } else { |
| 34230 | // the indentation is less than our level |
| 34231 | break; |
| 34232 | } |
| 34233 | } else if (propToken.type === TOKEN_TYPES.indent) { |
| 34234 | if (propToken.value === indent) { |
| 34235 | this.next(); |
| 34236 | } else { |
| 34237 | break; |
| 34238 | } |
| 34239 | } else if (propToken.type === TOKEN_TYPES.eof) { |
| 34240 | break; |
| 34241 | } else if (propToken.type === TOKEN_TYPES.string) { |
| 34242 | // property key |
| 34243 | const key = propToken.value; |
| 34244 | (0, (_invariant || _load_invariant()).default)(key, 'Expected a key'); |
| 34245 | |
| 34246 | const keys = [key]; |
| 34247 | this.next(); |
| 34248 | |
| 34249 | // support multiple keys |
| 34250 | while (this.token.type === TOKEN_TYPES.comma) { |
| 34251 | this.next(); // skip comma |
| 34252 | |
| 34253 | const keyToken = this.token; |
| 34254 | if (keyToken.type !== TOKEN_TYPES.string) { |
| 34255 | this.unexpected('Expected string'); |
| 34256 | } |
| 34257 | |
| 34258 | const key = keyToken.value; |
| 34259 | (0, (_invariant || _load_invariant()).default)(key, 'Expected a key'); |
| 34260 | keys.push(key); |
| 34261 | this.next(); |
| 34262 | } |
| 34263 | |
| 34264 | const valToken = this.token; |
| 34265 | |