# eb-local.toml ::::{zig:module} eb-local.toml :file: src/toml.zig :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig The part of TOML 1.0 that eb-local's configuration uses: tables (`[a.b]`), dotted keys, basic and literal strings, integers, booleans and arrays, which may span lines. Floats, dates, inline tables and arrays of tables are refused by name rather than misread. A duplicate key, a table defined twice, or a key used both as a value and as a table is an error naming its line. :::: ## Types ::::{zig:type} eb-local.toml.Value :signature: pub const Value = union(enum) :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L11 A value as the file wrote it: one of the kinds this parser accepts. :::{zig:field} eb-local.toml.Value.string :signature: string: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L12 ::: :::{zig:field} eb-local.toml.Value.int :signature: int: i64 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L13 ::: :::{zig:field} eb-local.toml.Value.boolean :signature: boolean: bool :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L14 ::: :::{zig:field} eb-local.toml.Value.array :signature: array: []const Value :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L15 ::: :::{zig:field} eb-local.toml.Value.table :signature: table: *Table :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L16 ::: :::{zig:function} eb-local.toml.Value.kindName :signature: pub fn kindName(v: Value) []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L20 The kind of `v` with its article, as an error message names it: "a string", "an integer". ::: :::: ::::{zig:type} eb-local.toml.Entry :signature: pub const Entry = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L32 One key of a table, its value, and the line that set it. :::{zig:field} eb-local.toml.Entry.key :signature: key: []const u8 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L33 ::: :::{zig:field} eb-local.toml.Entry.value :signature: value: Value :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L34 ::: :::{zig:field} eb-local.toml.Entry.line :signature: line: usize :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L35 ::: :::: ::::{zig:type} eb-local.toml.Table :signature: pub const Table = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L39 A table's keys in the order the file gives them. :::{zig:field} eb-local.toml.Table.entries :signature: entries: std.ArrayList(Entry) = .empty :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L40 ::: :::{zig:field} eb-local.toml.Table.explicit :signature: explicit: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L42 Defined by a `[header]` (not only implied by a dotted name). ::: :::{zig:field} eb-local.toml.Table.dotted :signature: dotted: bool = false :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L44 Defined via dotted keys (cannot be reopened by `[header]`). ::: :::{zig:field} eb-local.toml.Table.line :signature: line: usize = 0 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L45 ::: :::{zig:function} eb-local.toml.Table.get :signature: pub fn get(t: *const Table, key: []const u8) ?*const Entry :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L48 The entry for `key`, or null when the table has none. ::: :::: ::::{zig:type} eb-local.toml.Diagnostic :signature: pub const Diagnostic = struct :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L60 Where and why the text is not accepted. :::{zig:field} eb-local.toml.Diagnostic.line :signature: line: usize = 0 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L61 ::: :::{zig:field} eb-local.toml.Diagnostic.message :signature: message: []const u8 = "" :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L62 ::: :::: ## Error sets ::::{zig:errorset} eb-local.toml.Error :signature: pub const Error = error{Invalid} || Allocator.Error :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L67 `error.Invalid` when the text is not accepted, with the line and reason in the `Diagnostic`. :::: ## Functions :::{zig:function} eb-local.toml.parse :signature: pub fn parse(a: Allocator, src: []const u8, diag: *Diagnostic) Error!*Table :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L496 Parse `src`. Everything is allocated with `a` (an arena is expected). ::: ## Constants :::{zig:constant} eb-local.toml.max_depth :signature: pub const max_depth = 32 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L70 Deepest nesting of arrays accepted. ::: :::{zig:constant} eb-local.toml.max_entries :signature: pub const max_entries = 10_000 :source: https://github.com/stackhands/eb-local/blob/629c1ef39cdece5bfa2145cc8e2e89ae7583d197/src/toml.zig#L72 Most keys and array items, counted together, one file may hold. :::