Bloccs.Parser (bloccs v0.1.1)

Copy Markdown View Source

Parses .bloccs TOML manifests into typed structs.

Two entry points: parse_node/1 and parse_network/1. Each returns either {:ok, struct} or {:error, [%Bloccs.Parser.Error{}]}. Errors are accumulated, not short-circuited, so one bad manifest surfaces all of its problems in a single pass.

Summary

Functions

Parse a network manifest from a file path.

Parse a node manifest from a file path.

Parse a node manifest from a binary string (no file association).

Functions

parse_network(path)

@spec parse_network(Path.t()) ::
  {:ok, Bloccs.Manifest.Network.t()} | {:error, [Bloccs.Parser.Error.t()]}

Parse a network manifest from a file path.

Recursively loads every node referenced by [nodes].X.use = "...". Node paths are resolved relative to the network file's directory.

parse_node(path)

@spec parse_node(Path.t()) ::
  {:ok, Bloccs.Manifest.Node.t()} | {:error, [Bloccs.Parser.Error.t()]}

Parse a node manifest from a file path.

parse_node_string(text, path \\ nil)

@spec parse_node_string(String.t(), Path.t() | nil) ::
  {:ok, Bloccs.Manifest.Node.t()} | {:error, [Bloccs.Parser.Error.t()]}

Parse a node manifest from a binary string (no file association).