toon_codec/decode/parser

Parsing functions for TOON format elements.

This module provides functions to parse array headers, keys, values, and delimited data from TOON format strings. Parse a primitive token (string, number, boolean, or null).

Quoted strings remain strings even if they look like numbers. Parse a quoted string token. Parse an unquoted value (number or string). Parse a numeric token. Check if a string has a forbidden leading zero. Parse delimited values from a string.

Splits on the delimiter while respecting quoted sections. Split a string on delimiter, respecting quotes. Parse a key from the beginning of a line.

Returns the key and the position after the colon. Parse a quoted key. Parse an unquoted key. Parse an array header line.

Returns the header info and any inline values after the colon. Parse the bracket segment [#?N delim?] Parse length and delimiter from bracket content. Parse fields segment {field1,field2,…} Unescape field names (handle quoted field names). Extract inline values after the colon. Check if a line looks like an array header. Check if content is a key-value line (has unquoted colon).

Values

pub fn is_array_header(content: String) -> Bool
pub fn is_key_value_line(content: String) -> Bool
pub fn parse_array_header(
  line: String,
) -> Result(
  #(types.ArrayHeader, option.Option(String)),
  error.ToonError,
)
pub fn parse_delimited_values(
  text: String,
  delimiter: types.Delimiter,
) -> List(String)
pub fn parse_key(
  content: String,
) -> Result(#(String, Int), error.ToonError)
pub fn parse_primitive(
  token: String,
) -> Result(types.JsonValue, error.ToonError)

Unquoted tokens are interpreted based on their content.

Search Document