Assisted-by: GLM 5.3 Flash
This commit is contained in:
+21
@@ -97,6 +97,27 @@ interface flags the decoder and encoder resolve through are built once and
|
||||
cached, so the first document pays the cost instead of the hot path. A `T`
|
||||
that is not a struct warms nothing.
|
||||
|
||||
### `func Statements(r io.Reader) iter.Seq2[Statement, error]`
|
||||
|
||||
Iterates the top-level statements of the document r carries, in written
|
||||
order: key/value statements, a `[table]` header as one statement carrying
|
||||
its `Table` node, and an `[[array of tables]]` as one statement per element
|
||||
with the element's node and its `Index`. Iteration stops at the first error
|
||||
and at a false yield, so a caller looking for one section reads no further.
|
||||
The reader is consumed in full before the first yield, because the parser
|
||||
scans the source in place.
|
||||
|
||||
```go
|
||||
for stmt, err := range interpres.Statements(file) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if stmt.Table != nil {
|
||||
fmt.Println(stmt.Key, stmt.Table.Keys())
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Documents
|
||||
|
||||
`Parse` returns a `Document`: the value tree together with what a map cannot
|
||||
|
||||
Reference in New Issue
Block a user