21 lines
941 B
Plaintext
21 lines
941 B
Plaintext
# tomllib - TOML parser producing a json.JsonValue tree.
|
|
#
|
|
# TOML and JSON share the same structural model (object / array / scalar), so a document parses
|
|
# directly into json.JsonValue and can be re-emitted with json.write. See __parser.vp for the
|
|
# supported subset and for the constructs that are deliberately rejected (date-time, inf/nan).
|
|
#
|
|
# Error convention (identical to json.parse):
|
|
# - a JSON_NULL node => the source is malformed or uses a rejected construct;
|
|
# - None => the memory pool is exhausted.
|
|
# Callers must test `doc == None or doc.vtype == json.JSON_NULL` before walking the tree.
|
|
#
|
|
# Usage:
|
|
# import tomllib
|
|
# import json
|
|
# doc: json.JsonValue* = tomllib.parse(pool, text)
|
|
# if doc == None or doc.vtype == json.JSON_NULL: return -1 # 解析失败
|
|
# name: json.JsonValue* = doc["project"]["name"]
|
|
# if name != None: stdio.printf("name=%s\n", name.str_val)
|
|
|
|
from .__parser import parse
|