Elamur GroupantsโŒ•
โ˜ฐ

math-calc-parser

The groupant beside math/src/calc.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

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

componentlabelwhere
approximantpartialapproximant
astpartial../syntax.json
compositionpartialmodel.md
costpartialCost
descriptantpresentdescriptant
invariantpartialinvariant
testsexecuted bounded checkstests

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.

idtypelabelwhere
behavior_complementbehavior_complementpartial source derived modelbehavior_complement
reverse_reconstructionreverse_reconstructionpartial source derived modelreverse_reconstruction
binding_precedencebinding_precedencepartial source derived modelbinding_precedence
comparison_expansioncomparison_expansionpartial source derived modelcomparison_expansion
equation_projectionequation_projectionpartial source derived modelequation_projection
lexical_failurelexical_failurepartial source derived modellexical_failure

Parts

Model text

descriptant

math-calc-parser

lex/P normalize aliases, implicit multiplication and precedence; power associates right. Comparison chains expand at most two comparisons. parse_equation extracts top equality or appends0. Preimages include whitespace/aliases, no raw-byte inversion. O(B) token storage, uncapped nesting.

Epoch 2026-10-31: complete source read, parent AST reused; partial finite evidence only.

approximant

Scoped forward and cost

lex/P normalize aliases, implicit multiplication and precedence; power associates right. Comparison chains expand at most two comparisons. parse_equation extracts top equality or appends0. Preimages include whitespace/aliases, no raw-byte inversion. O(B) token storage, uncapped nesting.

No executable percent surrogate claimed.

invariant

Scoped invariant

lex/P normalize aliases, implicit multiplication and precedence; power associates right. Comparison chains expand at most two comparisons. parse_equation extracts top equality or appends0. Preimages include whitespace/aliases, no raw-byte inversion. O(B) token storage, uncapped nesting.

Source range[6098,17753) bound by manifest digest. Parent domain applies, not arbitrary public states.

models

Source-scoped typed relations

behavior_complement

parse('2^3^2') excludes left-associated (2^3)^2; successful parse excludes unconsumed tokens. Unknown identifiers followed by parentheses exclude Call unless name is recognized.

reverse_reconstruction

A canonical Call('binom',...) admits C/choose/nCr/binomial/binom spellings; equivalent whitespace and normalized multiplication symbols are lost. Output E does not recover original bytes.

binding_precedence

pow consumes unary exponent recursively: 2^-1 works and -2^2 becomes Neg(Pow(2,2)). Postfix factorial/index binds before power.

comparison_expansion

a<b<c becomes And(Lt(a,b.clone),Lt(b,c)); parser supports at most this second comparison, so a fourth comparison leaves tokens and errors.

equation_projection

parse_equation unwraps only root Eq; every other accepted E maps to(E,0). An And chain involving equality remains an expression against zero.

lexical_failure

Character scan recognizes exponent digits only when e/E is followed by valid signed/unsigned digits. Unknown symbol errors before parsing; malformed number text fails parse_q during primary.

tests

Evidence

See ../tests.md for actual checks and source mutant; this fragment adds no runtime test.

lex/P normalize aliases, implicit multiplication and precedence; power associates right. Comparison chains expand at most two comparisons. parse_equation extracts top equality or appends0. Preimages include whitespace/aliases, no raw-byte inversion. O(B) token storage, uncapped nesting.

wave34-composition

Parser descendant composition

The lex-normalization child runs before P exists: lexical Err prevents all parsing. Its canonical token stream feeds or/and/not/comparison/add/mul/unary and the power-association child. Power receives a cursor into that stream, consumes postfix and recursively unary exponents, then returns to the surrounding precedence layer. parse finally rejects unconsumed tokens. The two child ranges overlap the enclosing parser relation but do not exhaust it: function recognition, list parsing, comparison expansion and parse_equation remain modeled by the historical parent.

A compatible parser antecedent must satisfy both lexical spelling equivalence and the cursor/precedence relation; arbitrary lexer and power preimages cannot be paired without the same token stream. Exclusion at the parent includes failure ordering: lexical failure precedes numeric primary validation, which precedes trailing-token rejection when reached.

Cost

Lexing O(C) plus parser work over tokens; power's recursive depth is part of parser stack use. Do not sum overlapping parent and child token traversal estimates. No nesting or allocation bound is proved.

This page in Markdown โ†’ https://md.groupants.elamur.ai/free/en/mova/math/src/calc.rs.groupant/parser.groupant/