Eyeon.Decoder (eyeon v0.3.2)

Copy Markdown View Source

Decodes Ion parser AST nodes to Elixir values.

This module is codec-agnostic: both Eyeon.TextDecoder (text path) and Eyeon.BinaryDecoder.V11 (binary path) produce AST nodes that flow through decode_values/4 or decode_value/4 to produce final Elixir values.

Summary

Functions

Decode a single AST node to an Elixir value.

Decode a list of AST nodes, returning a list of Elixir values or {:error, reason}.

Flatten compound AST nodes produced by parser shift/reduce conflicts.

Functions

decode_value(strings, symtab, catalog, opts)

@spec decode_value(term(), term(), Eyeon.Catalog.t(), map()) :: any()

Decode a single AST node to an Elixir value.

decode_values(values, symtab, catalog, opts)

@spec decode_values(list(), term(), Eyeon.Catalog.t(), map()) ::
  [any()] | {:error, any()}

Decode a list of AST nodes, returning a list of Elixir values or {:error, reason}.

flatten_ast_node(node)

@spec flatten_ast_node(term()) :: [term(), ...]

Flatten compound AST nodes produced by parser shift/reduce conflicts.

These are 2-tuples where the first element is a 3-element token tuple {atom, line, chars}. e.g. {{:id_symbol, 5, ~c"a"}, {:sexp, [...]}} should become two separate nodes. We only flatten 3-element first tuples to avoid breaking typed nulls {{:null, line}, {:type, ...}} and other legitimate 2-tuple AST nodes like {:struct, fields}, {:list, values}, etc.