module TOML::ValueDecoder

Overview

Decoders that turn raw atom/string text into typed Values.

Kept in a dedicated module so the parser stays focused on structural concerns. All decoders raise TOML::ParseError (with 1-based line/column) on invalid input.

Extended Modules

Defined in:

toml/value_decoder.cr

Instance Method Summary

Instance Method Detail

def decode_basic_string(raw : String, line : Int32, column : Int32) : StringValue #

Decodes a BasicString token (raw still includes the surrounding " quotes) into a StringValue.


[View source]
def decode_float(raw : String) : FloatValue | Nil #

Build a FloatValue from the textual form int_part . frac_part or with an exponent. Used by the parser when it has reassembled the parts that the lexer emitted as Atom Dot Atom.


[View source]
def decode_literal_string(raw : String, _line : Int32, _column : Int32) : StringValue #

[View source]
def decode_multiline_basic_string(raw : String, line : Int32, column : Int32) : StringValue #

[View source]
def decode_multiline_literal_string(raw : String, _line : Int32, _column : Int32) : StringValue #

[View source]
def try_decode_atom(raw : String) : Value | Nil #

Try to decode an atom as an integer, float, boolean, or special float (inf, nan, +inf, -inf, +nan, -nan). Returns nil if raw is none of these so the caller can try other interpretations (datetime, dotted-key segment, …).


[View source]
def try_decode_datetime(raw : String) : Value | Nil #

Try to decode raw as one of the four TOML date/time variants: OffsetDateTime, LocalDateTime, LocalDate, LocalTime. Returns nil if raw does not match any of these shapes so the caller can keep trying integer/float interpretations.

Accepts both T/t and a literal space as the date/time delimiter (per TOML 1.0). The lexer emits a space-separated form as separate tokens, so this method only sees T/t forms and the space variant must be reassembled by the parser.


[View source]