| 163 | } |
| 164 | |
| 165 | private assign(target: Table, keys: ReadonlyArray<string>, value: unknown): void { |
| 166 | let table = target |
| 167 | for (let index = 0; index < keys.length - 1; index++) { |
| 168 | const key = keys[index] |
| 169 | const existing = table[key] |
| 170 | if (existing === undefined) { |
| 171 | const child = makeTable() |
| 172 | table[key] = child |
| 173 | table = child |
| 174 | } else if (isTable(existing) && !this.explicitTables.has(existing) && !this.inlineValues.has(existing)) { |
| 175 | table = existing |
| 176 | } else { |
| 177 | this.fail(`Cannot redefine existing key '${keys.slice(0, index + 1).join(".")}'`) |
| 178 | } |
| 179 | this.dottedTables.add(table) |
| 180 | } |
| 181 | const key = keys[keys.length - 1] |
| 182 | if (hasOwn.call(table, key)) { |
| 183 | this.fail(`Cannot redefine existing key '${keys.join(".")}'`) |
| 184 | } |
| 185 | table[key] = value |
| 186 | } |
| 187 | |
| 188 | private parseKeyPath(stop: "=" | "]"): Array<string> { |
| 189 | const keys: Array<string> = [] |