Skip to documentation
SLOP

tiny.preserves.parse

Reference tiny.preserves parse

Defined in tiny.preserves.

Returns the one value text holds, allocated with alloc.

Called byCallsNo direct callsprivate sourcelib.preserves.src.text.parsercheckOwnedParseAllocationFailuresprivate sourcelib.preserves.src.text.parserexpectDuplicateWithAllocatortest sourcelib.preserves.src.text.parsertest: parse trailing content releases...tiny.preservesparse
Static calls · unresolved targets: 0 · external targets: 3.

Source

Source: lib/preserves/src/text/parser.zig:30

zig
/// Returns the one value `text` holds, allocated with `alloc`. Code reading hand-written text calls/// it for a value with comments allowed, sets and dictionaries sorted, and `#:` embedded values/// read in place. The value owns all its memory, so `text` may be freed at once, and the caller/// frees the value with `deinit`. On any error the call frees everything it allocated. Whitespace/// and commas separate values, and a `#` followed by a space or tab starts a comment that runs to/// the end of the line. An annotation `@a v` is read, checked and dropped, so the call returns `v`./// Sets and dictionaries are sorted by the package's value order after they are read. `#:v` becomes/// an embedded value that owns `v` and compares, hashes, copies and frees through it. A bare token/// becomes an integer only when `looksLikeInteger` accepts its optional sign and digits. `parse`/// tries `parseFloat` to produce a double only when `looksLikeFloat` accepts the token. If/// `parseFloat` fails, `parse` falls through to a symbol. Strings and symbols are checked as UTF-8,/// the shared escape reader accepts `\'`, and a `\u` escape reads one code unit, so surrogate pairs/// fail. The call returns a `ParseError` naming the kind of bad input, and/// `error.NestingLimitExceeded` past 256 levels. Its repeated-item checks compare each element or/// key with every earlier one, so their cost grows with the square of the count.pub fn parse(alloc: Allocator, text: []const u8) ParseError!Value {    var parser = Parser{ .text = text, .pos = 0, .alloc = alloc };    var value = try parser.readValue(nesting.root);    errdefer value.deinit(alloc);    parser.skipWhitespace();    if (parser.pos < parser.text.len) return ParseError.TrailingContent;    return value;}

Source: lib/preserves/src/root.zig:303

zig
pub const parse = text.parse;

Also reachable as

text.parse.

Audit

Definitions1
Public names2
Members0
Version26.7.0
Revisiondaab053ee433