slovo/.llm/BETA_17_JSON_PRIMITIVE_SCALAR_PARSING_FOUNDATION.md

1.7 KiB

1.0.0-beta.17 JSON Primitive Scalar Parsing Foundation

Scope

Slovo-facing 1.0.0-beta.17 adds narrow std.json facade names for primitive scalar token parsing:

  • parse_bool_value_result ((token string)) -> (result bool i32)
  • parse_i32_value_result ((token string)) -> (result i32 i32)
  • parse_u32_value_result ((token string)) -> (result u32 i32)
  • parse_i64_value_result ((token string)) -> (result i64 i32)
  • parse_u64_value_result ((token string)) -> (result u64 i32)
  • parse_f64_value_result ((token string)) -> (result f64 i32)
  • parse_null_value_result ((token string)) -> (result bool i32)

The construction surface from 1.0.0-beta.7 remains intact: the existing 24 JSON construction exports are still present.

Contract

These helpers parse one already-isolated primitive scalar token. Success returns ok payload; ordinary parse failure returns err 1. parse_null_value_result returns ok true only for exact null and err 1 otherwise.

Numeric and boolean conversion is intentionally concrete and result-returning. The promoted numeric and boolean helpers consume a whole JSON primitive token: no leading/trailing whitespace, no leading +, no leading-zero integer form except 0, and no non-finite f64 values. parse_f64_value_result accepts the current JSON-number grammar subset implemented by the runtime, including exponent notation. This slice does not freeze a stable API or ABI.

Non-Scope

This is not full JSON parsing. It does not add parse_string, parse_object, parse_array, parse_value, tokenizers, recursive JsonValue, maps/sets, generic parse APIs, whitespace-tolerant document parsing, schema validation, streaming, Unicode escape handling, stable API freeze, stable ABI/layout, or performance claims.