std::parse

std/src/parse.mo

Text -> numbers, in pure Monad: strict, whole-string, no trimming.

Option, not Result, because these classify a TOKEN rather than parse a document -- a YAML plain scalar that is not a number stays a string, which is exactly the none branch.

PORTABLE BY CONSTRUCTION: no native is used, and in particular this does NOT call F64.bits_of_string (its f64_of_string native is web-gated, lang/src/codegen/natives.mo's web_only_natives), so it works on every target including wasm. The value is built from F64 literals, a digit table and repeated multiplication/division.

WHY THE ODD SPELLING OF ADDITION: written when infix (+) still resolved to I64.add (init/src/lib.mo's since-removed override) and a + b on two F64 values did not check. + resolves now (through [Add A] HAdd A A A and Add F64), but the spelling is kept: the subtraction form is what the digit-table verification ran against. *, - and / dispatch the same way, through the HMul/HSub/HDiv bridges and the Mul/Sub/Div instances.

PRECISION: correctly rounded while the mantissa has at most 19 significant digits and the decimal exponent is within +/-22 (each power of ten is then exact and the single final scale is one IEEE operation). Beyond that the result carries a bounded relative error (~1e-15), which is what config data needs. Exact strtod parity is deliberately not claimed.

defParse.i64#
pub def Parse.i64 (s : String) : Option I64

Parse a strict decimal integer: optional +/-, one or more digits, nothing else. Overflow is none. 0x/0o/0b are not accepted (they are not in the YAML 1.2 core schema, and a caller that wants them can add a case).

instance_#
pub instance Copy Parse.Decimal {
    def copy (d : Parse.Decimal) : Pair Parse.Decimal Parse.Decimal :=
        Pair.pair d d
}

The parser state is a pure record of Copy scalars, so sharing a snapshot across a branch is a bit-copy, not an ownership move.

defParse.f64#
pub def Parse.f64 (s : String) : Option F64

Parse a strict decimal float: optional sign, an integer part, an optional . + fraction (either part may be empty, but not both), and an optional [eE] + optional sign + digits. The whole string must be consumed. Non-finite spellings (.inf, .nan) are NOT accepted here; they are a YAML scalar-resolution concern, not a number grammar one.