nx_yaml_subset.nx
buildroot/runtime/nx_yaml_subset.nx
about
nx_yaml_subset.nx -- bits-up YAML subset parser.
Mirrors the YAML subset that nishi-pages/build/build.py accepted:
key: value (string)
key: 123 (int)
key: -42 (signed int)
key: 2026-05-19 (ISO date, kept as string)
key: true (bool, kept as string "1" / "0")
key: "quoted value" (strips outer quotes)
key: 'quoted' (same, single)
key: [a, b, c] (flow list of strings)
# comment lines (ignored)
<blank line> (ignored)
Used by:
- nishi-pages site.yaml + per-doc frontmatter
- bench/ops scripts that read config
Per cardinal feedback-bits-up-exceed-never-match: substrate-owned;
no libyaml, no Python's yaml.safe_load, no PyYAML. Parser is
deterministic + bounded + auditable.
Per cardinal feedback-defensive-at-boundaries-trusting-internally:
input bytes are validated (key chars only [A-Za-z0-9_-]), value bytes
are stored verbatim (NUL-terminated) into a caller-owned arena.
dependencies 1 imports · 2 importers
imports: nx_syscalls_x86_64.nx
imported by: nx_build_doc.nxnx_build_site.nx
structs
| 54 | struct NxYamlEntry |
| 63 | struct NxYamlDoc |
consts
| 39 | const NX_YAML_OK: i64 = 0 |
| 40 | const NX_YAML_BAD_INPUT: i64 = 1 // src null or len <= 0 |
| 41 | const NX_YAML_BAD_LINE: i64 = 2 // no colon in non-empty/non-comment line |
| 42 | const NX_YAML_TOO_MANY_KEYS: i64 = 3 // exceeded max_entries |
| 43 | const NX_YAML_ARENA_FULL: i64 = 4 // value arena cap exhausted |
| 44 | const NX_YAML_KEY_TOO_LONG: i64 = 5 |
| 46 | const NX_YAML_MAX_KEY_LEN: i64 = 64 |
| 61 | const NX_YAML_ENTRY_BYTES: i64 = 32 |
| 75 | const NX_YAML_DOC_BYTES: i64 = 72 |
functions
| 79 | func nx_yaml_doc_init(d: *NxYamlDoc, |
| 97 | func _yml_is_ws(b: i64) -> i64 called by 1: _yml_ltrim |
| 103 | func _yml_is_key_char(b: i64) -> i64 called by 1: nx_yaml_parse |
| 113 | func _yml_eol(src: *u8, end: i64, off: i64) -> i64 called by 1: nx_yaml_parse |
| 123 | func _yml_ltrim(src: *u8, end: i64, off: i64) -> i64 |
| 133 | func _yml_rtrim(src: *u8, start: i64, line_end: i64) -> i64 called by 1: nx_yaml_parse |
| 149 | func _yml_strip_quotes(src: *u8, off_io: *i64, len_io: *i64) -> i64 called by 1: nx_yaml_parse |
| 174 | func _yml_append(dst: *u8, used_io: *i64, cap: i64, called by 1: nx_yaml_parse |
| 189 | func nx_yaml_parse(d: *NxYamlDoc, src: *u8, src_n: i64) -> i64 |
| 280 | func nx_yaml_lookup(d: *NxYamlDoc, called by 1: nx_bs_append_post_summary |
| 306 | func nx_yaml_count(d: *NxYamlDoc) -> i64 |
| 313 | func nx_yaml_key_at(d: *NxYamlDoc, i: i64, called by 1: nx_build_vars_add_yaml |
| 323 | func nx_yaml_value_at(d: *NxYamlDoc, i: i64, called by 1: nx_build_vars_add_yaml |