Skip to content

SDL API reference ​

Everything below is exported by sparkles.wired.sdl. Each group links to the SDL specification section that defines it. Every function returns SdlExpected!T (Expected!(T, SdlError)) instead of throwing.

Typed values ​

FunctionDoes
fromSDL!(T, config = sdlFull)(text, sourceName = null)Parses under config, then decodes a T.
fromSDL!(T, Sink, config = sdlFull)(text, sink, sourceName)The same, putting every independent failure into sink.
fromSDL!T(node), fromSDL!(T, Sink)(node, sink)Decodes a T from a node of a document you keep alive.
toSDL(value)Canonical text of value, as an SdlString.
writeSDL(value, writer)The same text into any character output range.
readSDLFile!T(path), writeSDLFile(value, path)File versions; writes are atomic (temporary file, then rename).

T may be Decoded!U, which also records which fields the input supplied. isWireRoundTrippable!(Sdl, T) is true when fromSDL!T(toSDL(v)) == v holds for every value. See SPEC §6 and §11.

Field roles ​

UDAField reads
@SdlTagValue(n)positional value n (an array: from n on)
@SdlAttribute()the attribute of the field's name
@SdlChild() (the default)the child tag of the field's name
@SdlTagName(), @SdlTagNamespace()the containing tag's own name or namespace
@SdlExtra() on SdlExtras/OwnedSdlExtrasevery occurrence no other field claimed

Names come from @WireName!Sdl (a : sets the namespace) or the case policy. The shared policies (@WireOptional, @WireDefault, @WireAlias, @WireCheck, @WireAs, @WireConvert, @WireStrict) apply as for JSON. See SPEC §5 and §8.

Documents ​

NameIs
parseSdlDocument!config(text, sourceName)An owning SdlDocument in source order.
validateSDL!config(text, sourceName)Whether text parses, without keeping a document.
writeSdlDocument(document, writer, options)The document's canonical text.
SdlNodeA tag: qualifiedName, byValue, byAttribute, byChild, span.
SdlDocumentroot, its owned source, position(offset), and comments.
SdlNode.extentThe bytes the node owns: whole lines, or its inline range.
SdlComment, SdlCommentKindA comment's span and whether it is a line or a block comment.
SdlCommentRangecomments: a random-access range of SdlComment in source order.
SdlScalarOne value: kind, then the payload accessor for that kind.
SdlNameQueryA name to filter byChild/byAttribute, optionally any namespace.
SdlSpan, SdlPositionA source byte range; the line and column of an offset.

See SPEC §4.

Selection ​

In the sparkles:wired-sdl-select sub-package, module sparkles.wired.sdl.select.

NameIs
SdlPath.parse(path)A borrowed, validated path (.. first: any depth); nodes, attributes.
SdlSelector.parse(path, filter)A path plus a DQL filter over each selected node; copies share it.
SdlNodeSelection, SdlSelectedNodesThe node ranges, in document order: unfiltered and filtered.
SdlAttributeSelection!NodesThe attributes the last segment names, of the nodes Nodes yields.
SdlNodeResolverThe DQL host resolver over one node: values[i], attributes[i], attributes, children.
SdlSelectorError, SdlSelectorPartA fault's input (path or filter) and DQL's error at an offset in it.

The editor's remove, removeAttribute, replaceAttribute and setAttribute accept a selection. See Select SDL nodes with a path and editing §3.2.

Profiles ​

sdlFull, sdlDubCompat, and sdlDubRecipe are the predefined SdlParserConfig values; a custom one enables scalar families (SdlScalarFeatures) and syntax (SdlSyntaxFeatures) one by one. See SPEC §3.1.

Errors ​

SdlError carries a stage, a stable code, the source name and span, rolePath (the place in the SDL text) and valuePath (the place in the D value), and a reason; toString renders all of it. A failed union decode lists each variant's error in variants. See SPEC §7.

Lower levels ​

lexSDL!config(text) yields SdlTokens; decodeSdlScalar decodes a scalar token; writeSdlScalar writes one scalar canonically. See SPEC §11.