feat(stdlib): Tiled P0 — XML reader + base64 decode + gzip framing (#67)
All checks were successful
bootstrap / cfree-fixpoint (push) Successful in 20s
ci / build-and-test (push) Successful in 1m43s
commit-lint / conventional-commits (push) Successful in 2s
docs / build-and-deploy (push) Successful in 27s

The three parsing primitives the TMX path needs that were not already in
the tree (zlib inflate + the JSON reader already shipped):

- Xml.* — a minimal, deterministic pure-Ludic XML reader for the
  element/attribute/CDATA subset TMX/TSX/TX use, spliced on demand. Handles
  nested elements, single/double-quoted attributes, text + <![CDATA[…]]>,
  comments, the <?xml?> prolog and <!DOCTYPE>, the five predefined entities
  and numeric character references.
- Base64.* — standard base64 (RFC 4648) decode + a matching pure-Ludic
  encoder; the decoder ignores the whitespace Tiled wraps into <data>.
  Splicing Base64.* also pulls in inflate.ludic so a plain tool can run the
  full base64 -> zlib/gzip decode chain.
- z_gunzip — gzip framing (RFC 1952) over the existing DEFLATE inflater:
  skip the 10-byte header + optional fields, inflate the body, ignore the
  CRC32/ISIZE trailer.

Golden corpus vendored under assets/tiled-fixtures/ (mapeditor/tiled
examples, attributed, + hand-authored multi-encoding fixtures). New
example library/tiled_p0.ludic proves all three (21 assertions); docs
pages + inventory added so check-impl stays green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Orkun ÇAKILKAYA 2026-09-01 14:04:49 +03:00
parent 0b149a6876
commit 79776d1f6a
35 changed files with 20549 additions and 18415 deletions

View file

@ -586,6 +586,27 @@ function emit_ns_call(ns: pointer, meth: pointer, e: Node) -> Val {
if (meth == "encode") { bare = "json_encode"; push(labels, "value") }
if (meth == "parse") { bare = "json_parse"; push(labels, "text") }
}
# Xml.* — the minimal XML reader (runtime/native/xml.ludic, spliced on demand).
# parse returns an Xml node; the accessors read tag/text/attributes/children.
if (ns == "Xml") {
if (meth == "parse") { bare = "xml_parse"; push(labels, "text") }
if (meth == "tag") { bare = "xml_tag"; push(labels, "node") }
if (meth == "text") { bare = "xml_text"; push(labels, "node") }
if (meth == "attr") { bare = "xml_attr"; push(labels, "node"); push(labels, "key") }
if (meth == "attr_int") { bare = "xml_attr_int"; push(labels, "node"); push(labels, "key"); push(labels, "dflt") }
if (meth == "has") { bare = "xml_has"; push(labels, "node"); push(labels, "key") }
if (meth == "attr_count") { bare = "xml_attr_count"; push(labels, "node") }
if (meth == "child_count") { bare = "xml_child_count"; push(labels, "node") }
if (meth == "child") { bare = "xml_child"; push(labels, "node"); push(labels, "index") }
if (meth == "find") { bare = "xml_find"; push(labels, "node"); push(labels, "tag") }
if (meth == "count") { bare = "xml_count"; push(labels, "node"); push(labels, "tag") }
}
# Base64.* — standard base64 codec (runtime/native/base64.ludic, spliced on
# demand). decode/encode round-trip through NUL-terminated strings.
if (ns == "Base64") {
if (meth == "decode") { bare = "base64_decode"; push(labels, "src") }
if (meth == "encode") { bare = "base64_encode"; push(labels, "src") }
}
# #62: a package-provided namespace (declared with @Namespace(Foo)) that none
# of the hardcoded core blocks matched — alias Foo.method to the bare function
# foo_method (positional args), the same generic path the core aliases use.