Texcraft code by TeX section

This index maps the sections/chapters in Knuth's original TeX to the corresponding Texcraft code. This is not meant to be exhaustive in either direction, but rather a general guide.

Empty cells generally indicate that work on that section hasn't started.

Texcraft code is frequently annotated with the analogous TeX section (e.g. TeX.2021.855) and git grep can be used to find these annotations.

#NameTexcraft code
1IntroductionN/A. This section defines global variables specific to the TeX Pascal code.
2The character setN/A. Texcraft uses Rust's Unicode character facilities.
3Input and outputN/A. Texcraft uses Rust's stdlib for reading and writing files.
4String handlingLargely N/A because Texcraft uses Rust's standard string facilities but some of this code is related to the string interner, which in Texcraft is in collections/interner.rs in texcraft-stdext.
5On-line and off-line printingN/A. Texcraft uses Rust's string formatting and printing facilities.
6Reporting errorsThe error module in texlang and errormode.rs in texlang-stdlib. See also the dedicated documentation on Texlang's error system.
7Arithmetic with scaled dimensionscommon
8Packed dataN/A. Texcraft doesn't have any memory usage optimizations of this type.
9Dynamic memory allocationN/A. Memory allocation is done via Rust stdlib.
10Data structures for boxes and their friendsds.rs in boxworks
11Memory layoutN/A. Memory allocation is done via Rust stdlib.
12Displaying boxesThe boxworks-lang crate contains a DSL for box data structures. The format is different than in TeX. TeX's format can be parsed using code in tex.rs in boxworks.
13Destroying boxesN/A. Memory including boxes is managed by Rust.
14Copying boxesN/A. Copying is done via implementations of Rust's Clone trait.
15The command codesN/A. Texlang doesn't have global command codes. Texlang's command tags feature is used for cases when the command needs to be identified.
16The semantic nest
17The table of equivalentsN/A. Texlang's doesn't have a global table of state. Instead, the component pattern is used for per-command state.
18The hash tableMostly N/A because Texcraft uses Rust's stdlib data structures. But command/map.rs in texlang is the equivalent thing. The hash table is related to string interning, which in Texcraft is in collections/interner.rs in texcraft-stdext.
19Saving and restoring equivalentsImplemented via collections/groupingmap.rs in texcraft-stdext.
20Token listsGenerally N/A because Texcraft just uses Rust's vector type. But texmacro.rs in texlang is related.
21Introduction to the syntactic routinesN/A. This section is essentially just documentation.
22Input stacks and statesThe stacks are in Internal in vm/mod.rs in texlang. Error context is provided using Texlang's token tracing system, token/trace.rs in texlang.
23Maintaining the input stacksThe stacks are modified throughout the vm module in texlang.
24Getting the next tokentoken/lexer.rs and vm/streams.rs (especially the function next_unexpanded) in texlang.
25Expanding the next tokenvm/streams.rs in texlang, especially the next_expanded function.
26Basic scanning subroutinesThe parse module in texlang. In particular the Parsable trait determines what can be "scanned" and implementations of this trait generally map to subroutines in this section.
27Building token listsparse.mod.rs in texlang and def.rs in texlang-stdlib.
28Conditional processingconditional.rs in texlang-stdlib.
29File namesPartly parse/filelocation.rs in texlang, but in general this section hasn't been figured out.
30Font metric datatfm.
31Device-independent file formatdvi.
32Shipping pages outboxworks-dvi (planned).
33Packaging
34Data structures for math mode
35Subroutines for math mode
36Typesetting math formulas
37Alignment
38Breaking paragraphs into linesboxworks-knuthplass.
39Breaking paragraphs into lines, continuedboxworks-knuthplass.
40Pre-hyphenationboxworks-hyphenate (planned).
41Post-hyphenationboxworks-hyphenate (planned).
42Hyphenationhyphenate and texlang-hyphenate (implementation of \hyphenation).
43Initializing the hyphenation tableshyphenate and texlang-hyphenate (implementation of \patterns).
44Breaking vertical lists into pages
45The page builder
46The chief executiveThe main switch is implemented in vm/mod.rs in texlang. But most of this section is text preprocessing which is done in the boxworks-text crate, and relies heavily on lig/kern code in the tfm crate.
47Building boxes and lists
48Building math lists
49Mode-independent processingVarious modules in texlang-stdlib. E.g. \advance is implemented in math.rs; \def in def.rs; etc.
50Dumping and undumping the tablesImplemented by Texlang's serializable VMs feature which has dedicated documentation. The Texlang framework code for serding is in vm/serde.rs in texlang, but serialization code is spread throughout the project (e.g. #[derive(Serialize)] on any component type).
51The main programThis section does a simple few things. Basic program initialization/setup is implemented in Texcraft's binary crates. Errors on the input ending prematurely are implemented throughout Texlang - e.g. the error of a conditional ending prematurely is implemented in conditional.rs in texlang-stdlib.
52DebuggingN/A. This section is about connecting TeX with a Pascal debugger.
53Extensions