---
title: "latex-parse — Mova code model"
description: "Mova code model of latex/src/parse.rs: components with their labels, obernants and the model text."
url: "https://groupants.elamur.ai/free/en/mova/latex/src/parse.rs.groupant/"
---
Elamur: [Mova](https://md.mova.elamur.ai/free/en/) · [Dictionary](https://md.dictionary.elamur.ai/free/en/) · [Research](https://md.research.elamur.ai/free/en/) · **Groupants**

This page as HTML: <https://groupants.elamur.ai/free/en/mova/latex/src/parse.rs.groupant/>

# latex-parse

The groupant beside latex/src/parse.rs in the Mova repository: what the code computes, what it never does, how to go back from its outputs, its invariants, cost and checks.

## Facts

- **kind:** groupant
- **status:** partial source bound model
- **source:** [`latex/src/parse.rs`](https://github.com/ElamurAI/mova-free/blob/main/latex/src/parse.rs)
- **source SHA-256:** `f463a4a8e13c7702…`
- **repository folder:** [`latex/src/parse.rs.groupant`](https://github.com/ElamurAI/mova-free/tree/main/latex/src/parse.rs.groupant)
- **repository commit:** `855da7bd4a7b`

> **Implementation material.** A Mova code model describes this code at one source revision: partial models, finite checks and their stated scope. It is not a reviewed general exposition, and its labels are shown as written, never raised.

## Components

| component | label | where |
|---|---|---|
| **approximant** | partial | [approximant](#approximant) |
| **ast** | partial | `syntax.json` |
| **composition** | partial | [composition](#composition) |
| **descriptant** | present | [descriptant](#descriptant) |
| **invariant** | partial | [invariant](#invariant) |
| **tests** | executed bounded checks | [tests](#tests) |

## Obernants

The typed relations around the forward model: the behaviour complement (what the code never does), the reverse reconstruction (every input compatible with an output) and specialised views.

| id | type | label | where |
|---|---|---|---|
| `behavior_complement` | behavior_complement | partial source derived model | [behavior_complement](#behavior-complement) |
| `reverse_reconstruction` | reverse_reconstruction | partial source derived model | [reverse_reconstruction](#reverse-reconstruction) |
| `failure_precedence` | failure_precedence | partial source derived model | [failure_precedence](#failure-precedence) |
| `macro_resources` | macro_resources | partial source derived model | [macro_resources](#macro-resources) |
| `row_normalization` | row_normalization | partial source derived model | [row_normalization](#row-normalization) |
| `unknown_fallback` | unknown_fallback | partial source derived model | [unknown_fallback](#unknown-fallback) |

## Parts

- [latex-parse-stage0](https://md.groupants.elamur.ai/free/en/mova/latex/src/parse.rs.groupant/stage0.groupant/)
- [latex-parse-stage1](https://md.groupants.elamur.ai/free/en/mova/latex/src/parse.rs.groupant/stage1.groupant/)
- [latex-parse-stage2](https://md.groupants.elamur.ai/free/en/mova/latex/src/parse.rs.groupant/stage2.groupant/)

## Model text


### descriptant

#### latex-parse

parse_with initializes local macro state and token stack. list consumes until stop kind, normalizes rows; top tables choose Aligned if any row has multiple cells else Gathered. Local macros shadow external before built-in dispatch, CmdRaw bypasses expansion. Unknown grouped arguments parse or become canonical Text on recoverable failure.

Epoch2026-10-31: full source reviewed before edits; prospective models retained externally. No optimization.

### approximant

#### Forward relation

parse_with initializes local macro state and token stack. list consumes until stop kind, normalizes rows; top tables choose Aligned if any row has multiple cells else Gathered. Local macros shadow external before built-in dispatch, CmdRaw bypasses expansion. Unknown grouped arguments parse or become canonical Text on recoverable failure.

No useful approximate executable metric for exact categorical syntax; future caps1/2/5/10% only.

### invariant

#### Domain, invariant and cost

parse_with initializes local macro state and token stack. list consumes until stop kind, normalizes rows; top tables choose Aligned if any row has multiple cells else Gathered. Local macros shadow external before built-in dispatch, CmdRaw bypasses expansion. Unknown grouped arguments parse or become canonical Text on recoverable failure.

Depth threshold400; expansions10000; token threshold1000000 checked pre-expansion. primes saturate255; offsets u32 require representable lengths. Argument errors occur before duplicate sup/sub check.

Cost in source bytes B, expanded tokens T, body/argument copies C and tree N: O(B+T+C) plus delimiter matching and repeated nested operations; storage includes tokens, macro clones and tree; recursion bounded only along list depth.

### composition

#### Composition

parse_with initializes local macro state and token stack. list consumes until stop kind, normalizes rows; top tables choose Aligned if any row has multiple cells else Gathered. Local macros shadow external before built-in dispatch, CmdRaw bypasses expansion. Unknown grouped arguments parse or become canonical Text on recoverable failure.

Build generates table enums consumed by parser dispatch and printers. Lexer tokens feed macros and parser; parser returns AST whose equality ignores spans. Printers and gate compare that quotient, not original bytes. Shared parent syntax backs scoped stages; stages are byte-bound projections, not independent Rust modules.

### models

### behavior_complement

Accepted unmatched closers and duplicate scripts are excluded, but arbitrary TeX semantic validity is not established. MAX_TOKENS is a check before substitution, not a global peak allocation ceiling.

### reverse_reconstruction

parse preimage includes comments, spacing, aliases, dropped presentation commands and macro programs with the same expanded normalized structure. Error preimage includes sources sharing first reached failure and byte offset; no unique original recoverability.

### failure_precedence

script obtains argument before checking occupied slot; genfrac parses six args before delimiter validation.

### macro_resources

Local definitions persist for formula; expansion increments before threshold check and substitution may exceed token threshold.

### row_normalization

Only one trailing empty row removed; single top cell unwrapped; other tables explicit Env.

### unknown_fallback

Failed unknown argument can become Text after stack truncation; local macro changes are not rolled back.

### tests

#### Evidence — 2026-10-31

parse::tests (7 named tests); integration unbalanced_is_an_error_with_position and macros_newcommand_def_let_declareop

Selected library filters ast:: lex:: macros:: parse:: print:: table:: and integration gate excluding document_extraction_with_preamble_macros and random_token_soup_never_panics_and_roundtrips. Direct rustc --test latex/build.rs exercises private helpers. All selected tests twice debug/release with identical sorted names. Four compiled mutants at build/AST/parser/printer boundaries fail assertions then exact restoration passes. These do not individually cover every source. Build-main failure effects, allocation failures and universal roundtrip are unproved. Strict Clippy reports existing lints. No corpus/live VMM/API/GPU/full-school/held-out tests.
