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, counts toward the byte limit.
Model.parse is the caller-facing entrypoint. Resource limits are opt-in with
limits := some { maxBytes := 100, maxExponent := 1000 }, where an omitted field keeps its default,
and 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 magnitude zero.
Instances For
Scan with the same ASCII trimming and syntax errors as TextParser.run, without rounding.
Instances For
TextParser.run is this scan followed by its 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 resource limits, keeping the complete IEEE status and the ternary value.
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, ternary value, 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 the unlimited parser's outcome, including all exception flags and the ternary value.
Parse text with an optional rounding direction mode, resource limits, and IEEE exception
status.
By default, conversion uses nearest-even rounding without resource limits and returns the value.
With limits := some bounds, bounds.maxBytes bounds the original UTF-8 input before scanning and
bounds.maxExponent bounds the adjusted decimal or binary exponent before numerical conversion,
and some {} selects the default bounds. With status := true, the result also carries all five
IEEE exception flags and the ternary value. Without it, the scanned text goes through
Internal.Value.convertText, so finite numeric input runs no rounding classifier.
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 the value of unlimited parsing.
A bounded parse with status preserves the unlimited parser's value, every exception flag, and the ternary value.