Skip to content

tex-expansion: TeX/e-TeX/LaTeX macro expansion engine (KC-101) - #88

Merged
jay3332 merged 2 commits into
mainfrom
agent/kabir-claude/tex-expansion
Sep 13, 2026
Merged

jay3332 merged 2 commits into
mainfrom
agent/kabir-claude/tex-expansion

Conversation

@GoKubar

@GoKubar GoKubar commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • New standalone crate crates/tex-expansion (not yet wired into crates/compiler — see CONTRACT.md for the proposed adoption diff and ownership boundaries).
  • Implements TeX's expansion processor: catcodes/tokenizer, \def/\edef/\gdef/\xdef with delimited/#{/undelimited params, \let/\futurelet, \expandafter/\noexpand/\csname, all TeX+e-TeX conditionals (\if*, \ifcase, \newif, \unless), \count/\dimen/\skip/\toks registers + arithmetic + \numexpr/\dimexpr, and a LaTeX layer (\newcommand/\newenvironment/counters/\@ifnextchar/\@ifstar/\@namedef/\@nameuse).
  • Oracle-validated: tests/oracle/gen/cases.py drives real tex/etex/pdflatex (MacTeX) to capture ground truth for 108 cases, committed as tests/oracle/manifest.json; cargo test never invokes TeX itself.
  • 47 Rust unit tests + 108/108 oracle cases green.

Test plan

  • cargo test (47 unit + 2 oracle-suite tests covering 108 cases) green
  • Adoption into crates/compiler per CONTRACT.md (owned by another agent/PR)

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xd5Hmwh5GHNTiAmHUJ1MZu

GoKubar and others added 2 commits September 13, 2026 01:43
New crate crates/tex-expansion implementing catcodes+tokenizer,
def/edef/gdef/xdef/let/futurelet, expandafter/noexpand/csname, TeX and
e-TeX conditionals (if/ifx/ifnum/ifdim/ifodd/ifcase/newif/unless), grouping
with global/aftergroup, count/dimen/skip/toks registers with countdef family
and numexpr/dimexpr, and a LaTeX layer (newcommand/renewcommand/provide,
newenvironment, counters, @ifnextchar/@ifstar/@namedef/@nameuse). 45 unit
tests passing.

Implementation-Agent: Claude Fable 5.1 (subagent kabir-claude KC-101, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Fable 5.1 <[email protected]>
…orpus

Fixes found via a 108-case oracle corpus run against real tex/etex/pdflatex:
bare grouping braces must not appear in the content-token stream (matches
real main-control semantics, not \write's scan_toks semantics); \the\dimen
must render via TeX's print_scaled algorithm, not raw sp; \numexpr division
rounds to nearest (ties away from zero); \ifcase must keep skipping on a
negative selector; \setcounter/\addtocounter values may contain expandable
constructs like \value{...}; \count's "..." hex parsing.

Adds tests/oracle/ (generator script + committed manifest.json + expected
fixtures, gitignored tmp/) and CONTRACT.md proposing the crates/compiler
adoption path, known deviations from real TeX, and what's done vs not.

47 unit tests + 108/108 oracle cases green.

Implementation-Agent: Claude Fable 5.1 (subagent kabir-claude KC-101, mac-m5pro-kabir)
Commit-Executor: Claude Code direct Git
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@jay3332
jay3332 merged commit cf4efec into main Sep 13, 2026
13 of 18 checks passed
@GoKubar
GoKubar deleted the agent/kabir-claude/tex-expansion branch September 13, 2026 18:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants