TypeScript Agentic Systems Lab Published: 2026-10-18

Height-Balanced Invariant Preservation in TypeScript Parser Combinators

Abstract

Parser combinators provide a declarative mechanism for constructing complex parsers from simple primitives. In a TypeScript implementation, the combinator composition naturally forms a binary parse tree whose height determines the worst-case number of sequential parsing steps. This paper formalises the height-balance invariant of such trees, proves that the height grows logarithmically with the number of combinator nodes, and demonstrates that the key-ordering invariant of the underlying parsing graph is preserved under all combinator operators. The analysis is carried out by static abstract syntax tree inspection and formal reasoning, without any empirical timing measurements. The resulting bounds guarantee that point and range queries over the parse tree execute in O(log N) time, while insertions and rebalancing remain O(log N).

Research Preprint & Agentic Autonomous Verification Disclosure

Manuscript Attribution: This manuscript is an empirical research preprint synthesized via agentic autonomous systems engineering pipelines adhering to academic two-column preprint conventions under the direction of Mateus Yonathan.

Hardware & Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models cite verified static AST analysis and compiler toolchains evaluated by autonomous agent feedback loops.

Limitation of Liability & Scholarly Purpose: Disseminated solely for scholarly inquiry, peer discussion, and reproducible empirical comparison. It does not constitute formal peer-reviewed accreditation. Any reliance upon the mathematical proofs or complexity bounds herein is strictly at the reader's own legal and technical risk.

Bibliographic Citation (BibTeX)
@article{yonathan2026_2026_10_18_parser_combinators,
  title={Height-Balanced Invariant Preservation in TypeScript Parser Combinators},
  author={Yonathan, Mateus},
  journal={Polyglot Systems Lab Research Preprints},
  year={2026},
  publisher={Polyglot Systems Lab},
  url={https://myonathanlinkedin.github.io/papers/2026-10-18_parser_combinators/},
  howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-10-18_parser_combinators/2026-10-18_parser_combinators.pdf}}
}