(src: str, pos: Pos, out: Output)
| 282 | |
| 283 | |
| 284 | def create_dict_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]: |
| 285 | pos += 1 # Skip "[" |
| 286 | pos = skip_chars(src, pos, TOML_WS) |
| 287 | pos, key = parse_key(src, pos) |
| 288 | |
| 289 | if out.flags.is_(key, Flags.EXPLICIT_NEST) or out.flags.is_(key, Flags.FROZEN): |
| 290 | raise suffixed_err(src, pos, f"Cannot declare {key} twice") |
| 291 | out.flags.set(key, Flags.EXPLICIT_NEST, recursive=False) |
| 292 | try: |
| 293 | out.data.get_or_create_nest(key) |
| 294 | except KeyError: |
| 295 | raise suffixed_err(src, pos, "Cannot overwrite a value") from None |
| 296 | |
| 297 | if not src.startswith("]", pos): |
| 298 | raise suffixed_err(src, pos, "Expected ']' at the end of a table declaration") |
| 299 | return pos + 1, key |
| 300 | |
| 301 | |
| 302 | def create_list_rule(src: str, pos: Pos, out: Output) -> tuple[Pos, Key]: |
no test coverage detected