CdmDocument containing the parsed structure.parseSdlCdm
Parse SDL text into a CDM document.
Produces a CdmDocument preserving comments, source locations, and formatting metadata for roundtrip fidelity.
Parameters
input | SDL text to parse. |
source | Optional source identifier (file path, URI). |
Returns
A
Throws
Exception on parse error.Examples
auto doc = parseSdlCdm(`server host="localhost" port=8080`);
assert(doc.root.nodeName == "server");
assert(doc.root.getAttribute("host").as!string == "localhost");Parse SDL from an open file handle.
Reads from the handle's current position (works for pipes, stdin, and files whose path is no longer resolvable); the source name is taken from the handle.
Parameters
file | File handle to read SDL content from. |
Returns
Builder.Result — CdmDocument for CdmBuilder, var for VarBuilder.Throws
Exception on I/O or parse error.fn
bool parseSdlCdm(out CdmDocument doc, const(char)[] input, out SdlError err,
string source = "", SdlPolicy policy = SdlPolicy.init) @trustedNon-throwing parse variant.
Parameters
doc | Output document; valid only on success. |
input | SDL source text. |
err | Populated with line/column diagnostics on failure. |
source | Source name for diagnostics. |
policy | Parsing policy. |
Returns
true on success, false with
err populated on failure.