Svelixir. Exs
(svelixir v0.11.0)
Copy Markdown
Codec for the plain-data .exs files Svelixir owns — svelixir.exs and
fireside.exs.
Decoding walks the AST and accepts literals only. There is no evaluation
step at all, so a manifest cannot execute code, define a module, or silently
evaluate to nil. Code execution here is not defended against — it is
absent.
Evaluating the file instead was measured and rejected: an empty file and a
comment-only file both silently return nil, a keyword list and a bare
string are returned as-is, and a file holding two top-level maps silently
returns only the last one.
The prose above deliberately names no evaluating function:
Svelixir.BoundaryGuard substring-scans this file, docs and comments
included, so spelling the rejected API out would make lib/ fail its own
boundary test.
Summary
Functions
Decodes plain-data .exs source into a map.
Encodes a plain-data map to deterministic .exs bytes.
Functions
Decodes plain-data .exs source into a map.
path is used for error messages only. Parser exceptions
(SyntaxError, TokenMissingError, MismatchedDelimiterError) propagate
unwrapped — their rendered messages already carry file, line, column and a
source snippet, which is better than anything we would write.
Encodes a plain-data map to deterministic .exs bytes.
Raises Svelixir.Exs.EncodeError for anything that is not
atom/number/binary/list/tuple/plain-map. That check is mandatory, not
defensive: inspect renders a pid, reference, port or struct as #Foo<...>,
and # starts an Elixir comment — so the value would round-trip to nil
with no exception anywhere.