Binary character input with explicit resource limits #
The byte limit is checked before scanning, including before trimming ASCII whitespace.
The exponent limit applies to the parsed exponent after fractional digits adjust its scale.
Both checks precede exact numerical conversion. Accepted values are never clamped or approximated
to satisfy a limit: their value and exception status agree with TextParser.run.
Infinity and NaN spellings have exponent magnitude zero. Their text, including every NaN payload digit, remains subject to the byte limit.
Model.parse is the caller-facing entrypoint. Resource limits are opt-in with limits := true;
status := true includes all IEEE exception flags. The TextParser namespace contains
implementation helpers used by this entrypoint and its correctness proofs.
Instances For
Instances For
Magnitude of the adjusted decimal or binary exponent; special values have no exponent.
Instances For
Scan with the same ASCII trimming and syntax errors as TextParser.run, without rounding.
Instances For
The existing parser is exactly this scan followed by its original numerical conversion.
Check the original byte length before scanning, then check the adjusted exponent before conversion. The successful result is the scanned value itself, so conversion does not scan the input again.
Instances For
Implementation core with explicit resource limits, retaining the complete IEEE status.
Instances For
A successful bounded scan is exactly an original scan satisfying both resource limits.
The byte bound holds for the original input, before any edge whitespace is removed.
Every successful scan respects the bound on its actual adjusted exponent.
When the original input meets the limits, bounded scanning preserves syntax errors as well.
Within the declared limits, bounded and original parsing agree on every value, flag, and error.
Successful bounded conversion comes from an original scanned value within the exponent limit. The original input satisfies the byte bound, and conversion preserves the full outcome.
A bounded success is exactly the original parser's outcome, including all exception flags.
Parse text with optional rounding, resource limits, and IEEE exception status.
By default, conversion uses nearest-even rounding without resource limits and returns the value.
With limits := true, maxBytes bounds the original UTF-8 input before scanning and
maxExponent bounds the adjusted decimal or binary exponent before numerical conversion.
With status := true, the result also carries all five IEEE exception flags.
Instances For
With limits and status disabled, parsing returns the exact core's value.
Status-enabled parsing without limits returns the complete exact core outcome.
With limits enabled and status disabled, parsing returns the bounded core's value.
With limits and status enabled, parsing returns the complete bounded core outcome.
A successful bounded parse returns exactly the value produced by unlimited parsing.
A bounded parse with status preserves the unlimited parser's value and every exception flag.