Show HN: A Lean 4 port of libexpat's XML 1.0 parsing semantics github.com · 2 po...

@show

Show HN: A Lean 4 port of libexpat's XML 1.0 parsing semantics github.com · 2 points · 0 comments · HN thread

TL;DR Show HN post for lexpat, a Lean 4 port of libexpat's XML 1.0 parsing semantics aimed at untrusted input. The project provides a pure resumable parser core, a bounded C ABI subset (liblexpat.so.1 with include/expat.h) for x86_64-linux, and a large test and differential suite against libexpat 2.8.5. The submission has 2 points and no comments.

  • Compatibility is at the specification level: it reproduces XML 1.0 (Fifth Edition) document semantics and Expat's event and error categories, while error text, byte offsets and callback chunk boundaries are normalized.
  • The core is a total, resumable Lean parser (LexPat.Stream) with a one-shot wrapper (parseDocument); no DTDs, external entities, namespace processing, XML 1.1 or unknown encodings are supported.
  • A bounded C ABI exports a documented XML_* subset; unsupported calls fail closed, e.g. enabling an unsupported handler poisons the parser with XML_ERROR_UNSUPPORTED_FEATURE.
  • Default budgets cap raw input at 8 MiB, tokens at 1 MiB, element depth at 256 and reference expansion at 1 MiB, each with its own error code.
  • Evidence includes a checked-in corpus compared against libexpat, streaming tests under several chunk sizes, two proved UTF-8 decoder properties, and ASan/Valgrind memory checks; the README states this is not a proof of correctness and not a drop-in replacement for libexpat.

Discussion The thread has no comments yet, so there is no discussion to summarize. The post appeared with 2 points and no replies.

#Lean4 #XML #parser #libexpat #formalVerification #CABI