Guide · Tokens and numbers

Retain only the token you need.

The parser streams fragments. The bounded collector copies selected octets and publishes a length only after completion.

Bind caller storage

Tokens.Collector binds a caller-owned Stream_Element_Array. The array can have arbitrary bounds and must outlive the collector.

The collector retains no fragment input and performs no allocation. Its capacity is exactly the bound array length.

Collect one selected token

Begin_Token chooses a decoded name, decoded string, or exact number. Before calling Append, ensure that the fragment input does not overlap collector storage. Then append each selected parser fragment.

Complete_Token publishes the staged prefix length atomically. Until then, the caller must not inspect or mutate the storage.

1. BeginSelect the token kind.
2. AppendCopy each complete fragment.
3. CompletePublish the exact prefix length.
4. ConsumeUse the prefix or convert it.

Keep capacity failure unpublished

Append copies all fragment octets or none. If the fragment does not fit, the collector enters Failed and publishes no completed length. Failed storage remains unpublished and must not be read or modified until abort or reset.

Abort_Token and Reset are idempotent. Each returns the collector to Empty. Retained storage octets then become unspecified.

Convert only a complete integer lexeme

Instantiate Numbers.Signed_Integers with a signed integer type, or instantiate Numbers.Unsigned_Integers with a modular type.

The signed Parse and unsigned Parse operations accept one complete strict JSON integer spelling. A fraction or exponent is invalid syntax. Range checks occur before arithmetic overflow or modular wrap.

ConversionSpecial result
Signed-0 converts to zero.
UnsignedEvery negative spelling, including -0, returns Negative_Value.

The result value is eligible only when the status is Converted. No failure publishes a numeric value.

Render deterministic integer text

The signed Render and unsigned Render operations emit exact base ten without a plus sign, leading zero, fraction, or exponent. They accept an arbitrary-bound output array.

If the array is too small, the operation reports zero produced octets and leaves the complete output unchanged.

Keep future conversions separate

The current public implementation provides checked signed and unsigned integer conversion and rendering. Binary64, decimal, and application-specific conversions are future work.

The parser always preserves number lexeme octets exactly. Conversion is a separate application decision and never changes the parser event stream.