Formats

Every format dmog reads and writes, with the shapes, the parts and the losses of each.

The formats dmog translate reads and writes, as dmog formats prints them. Each format's identifier is what --from and --to take.

Format Reads as Writes from Root Schema Streams
abnf tree tree object grammar-rules yes
c tree tree object c yes
css tree tree object css-ast yes
csv tree records array none yes
ebnf tree tree object grammar-rules yes
expr tree tree any expr no
feed tree tree object feed yes
gbnf tree tree object grammar-rules yes
ini tree tree object none yes
json tree tree any none yes
json5 tree tree any none yes
jsonc tree tree any none yes
jsonic tree tree any none yes
jsonl tree tree array none yes
markdown records, tree records array markdown-ast yes
pgn tree tree array pgn-database yes
proto tree tree object proto-ast yes
semver tree tree object semver no
toml tree tree object none yes
xml tree tree any xml-element yes
yaml tree tree any none yes
zon tree tree any none yes

The columns, and each format's section, give the fields of dmog formats:

  • Reads as (reads) is the shapes the format's documents are read in: tree, records, or both, in order of preference.
  • Writes from (writes) is the shape its render writes from.
  • Root (root) is the value its render needs at the root of a tree: object, array or any. A document whose root is another value is wrapped under --key.
  • Schema (schema) names the tree a format writes when it writes only its own documents' tree, and the tree its documents read as.
  • Streams is no where whole gives the reason the format's documents are read whole.

abnf #

Field Value
Reads as tree
Writes from tree
Root object
Schema grammar-rules
Transducer part abnf-transduce
Lift none
Embedding none
Render abnf-render

What a document written as this format does not keep:

  • Comments, blank lines and layout are not kept, and neither is a value annotation, which a comment carries: each rule is written on one line, its alternatives between slashes and its elements between spaces.
  • ABNF starts from its first rule, so a grammar whose start is another (GBNF's, which starts from root) is written with its start rule first: the text of the rules before it is held until that rule arrives and written after it, and nothing is held where the start rule comes first or the grammar names no start. A start naming a rule the grammar does not define, in a grammar that has rules, is refused at its end with TARGET_VALUE_UNREPRESENTABLE, naming the rule.
  • A numeric value is written in hexadecimal, whatever base the text gave it (%d65 is written %x41), a concatenation of numeric values a quoted string can hold as the case-sensitive string %s"...", and %i"..." as the quoted string it means: each reads back as the same element.
  • The repetition from 0 to 1 is written [ ... ] over a group and *1 before anything else, and a repetition of an element a prefix already repeats, which another notation can write and RFC 5234 cannot, in a group of its own, an option [ ... ] where it is from 0 to 1, which reads back with one more group.
  • A grammar of another notation is written as ABNF spells it: a literal, which matches exactly, as %s"..." or, where no quoted string holds it, as the numeric value of its code points; a character or a range as a numeric value; a class as the alternation of its members, each a character or a range, in a group where it has more than one; and GBNF's . as %x00-10FFFF.
  • A grammar the render cannot write as ABNF is refused with TARGET_VALUE_UNREPRESENTABLE, naming the rule and what it met: a token terminal, a negated class, an empty class, a name ABNF cannot spell (the empty name among them, and a reference's name in angle brackets, which ABNF reads as prose), prose holding > or a character past ASCII, a case-insensitive literal that no quoted string holds and that holds a letter of ASCII or a character past ASCII that may have cases (one of the Basic Multilingual Plane, or of a script past it that has them), and a literal holding a lone surrogate. A tree that is not the schema's is refused the same way, naming what was met.

c #

Field Value
Reads as tree
Writes from tree
Root object
Schema c
Transducer part c-transduce
Lift none
Embedding none
Render c-render

What a document written as this format does not keep:

  • White space is written as spaces and line feeds, each token where its span puts it, so comments and layout come back with every token's line, column and offset: a tab, a form feed, a vertical tab and a carriage return are each written as a space, which the reader counts as one column and one offset as it counts them, and white space after the last token is not written.
  • A comment after the last token is not in the tree, which keeps a comment only as a token before another, so it is not written.
  • An operator, which the tree keeps as a node's op and not as a token, and the punctuation the reader's expression nodes leave out (an expression's parentheses, a call's parentheses and the commas between its arguments, a subscript's brackets, a conditional's ? and :, a comma expression's commas, and the * of a pointer inside parentheses, kept as an empty token) have no place in the tree: each is written right after the text before it, with a space only where two pieces would read as one token, or, where the next token begins a later line and the line before has no room for it, just before that token.
  • The parameter list after a parenthesised declarator in a parameter's declaration (the (int, char) of void g(int (*cb)(int, char))) is not in the tree, so it is not written, and the parameter reads back as the same tree, a pointer rather than a pointer to a function.

css #

Field Value
Reads as tree
Writes from tree
Root object
Schema css-ast
Transducer part css-transduce
Lift none
Embedding none
Render css-render

What a document written as this format does not keep:

  • Layout is not kept: the stylesheet is written with a blank line between its top-level nodes, each node of a block on a line of its own two spaces deeper than the line that opens the block, and a rule's selectors one per line.
  • Every declaration is written as its property, a colon, a space and its value, and every declaration and every statement at-rule ends with a semicolon, one the document ended with a closing brace or with its end included.
  • A comment is kept only where the reader keeps one, as a node of a list of rules, declarations or keyframes: a comment inside a selector, a property name or a declaration's value, or between the parts of a rule or a declaration, is not written, while one inside an at-rule's prelude is kept as part of it.
  • An at-rule whose node keeps no prelude is written without one: @host, and @font-face and the other at-rules whose block holds declarations, @page apart, whose selectors are kept.
  • Source positions are not written, since a reader derives them from the written text.
  • A statement that ends a document with params ending in a lone backslash, an escape the document ended before it finished, is written with its semicolon, which that backslash then escapes.

csv #

Field Value
Reads as tree
Writes from records
Root array
Schema none
Transducer part csv-transduce
Lift none
Embedding none
Render csv

What a document written as this format does not keep:

  • The rows are the elements of the root array, and a root of another kind is written as one row.
  • The columns are the first row's, an object's keys or an array's positions labelled 0, 1 and so on, so a member or position of a later row that the first row lacks is not written, and one the first row has and a later row lacks is an empty field.
  • When the first row is a scalar there is one column, named value, and every row is written whole in it, an array or an object as its compact JSON text.
  • A null and a missing cell are both written as the empty field, so the two cannot be told apart, or from an empty string, when read back.
  • A nested array or object in a cell is written as its compact JSON text.
  • A number that is not finite is written as Infinity, -Infinity or NaN, and as null inside a nested array or object, since JSON has no spelling for one.
  • Every field is written quoted.
  • Records end in CRLF.
  • Every value is written as text, so a number or a boolean reads back as a string.

ebnf #

Field Value
Reads as tree
Writes from tree
Root object
Schema grammar-rules
Transducer part ebnf-transduce
Lift none
Embedding none
Render ebnf-render

What a document written as this format does not keep:

  • Comments, blank lines and layout are not kept, and neither are the ISO 14977 spellings this package reads (=, a comma between items, a closing semicolon), which come back as W3C's: each rule is written on one line, name ::= ..., its alternatives between bars and its elements between spaces.
  • EBNF starts from its first rule, so a grammar whose start is another (GBNF's, which starts from root) is written with its start rule first: the text of the rules before it is held until that rule arrives and written after it, and nothing is held where the start rule comes first or the grammar names no start. A start naming a rule the grammar does not define, in a grammar that has rules, is refused at its end with TARGET_VALUE_UNREPRESENTABLE, naming the rule.
  • A literal is written in double quotes, or in single quotes where it holds a double quote, and a class's member as itself where it is printable ASCII and not one of the class's own marks (#, -, ], ^), and as a code point (#x2D) otherwise, a member that would begin with a hexadecimal digit in a class that writes any code point written as a code point too, since W3C EBNF reads a code point's digits for as long as they go (#x5Cb is U+5CB): each reads back as the same element.
  • Repetitions are written in W3C EBNF's postfix forms, A?, A* and A+, after the element, the innermost first, so a repetition of a repetition is a postfix on a postfix (A*?).
  • A grammar of another notation is written as EBNF spells it: a lone control character as its code point; a case-insensitive literal (ABNF's quoted string) of one letter as the class of its two cases, and one holding no letter as a string; a range as a class of one range, and GBNF's . as the class of every code point; a counted repetition as its copies, the least of them, and then, to its most, nested options (A A ( A A? )? for two to four), or the last copy repeated (A A+ for two or more); an empty alternative, which W3C EBNF has no form for, by making the other alternatives an option (( A | B )?); and an RFC 5234 core rule the grammar references and does not define (ALPHA, DIGIT and the rest) as a rule of its own after the others, as ABNF's compiler adds it. Each reads back as what EBNF wrote, which the render writes again as the same text.
  • A grammar the render cannot write as EBNF is refused with TARGET_VALUE_UNREPRESENTABLE, naming the rule and what it met: prose, a token terminal, an incremental rule (=/), a name EBNF cannot spell (the empty name among them), an empty class, the empty literal, a literal no one EBNF terminal spells, since this front end reads whitespace between terminals and the run that would spell it would match the literal with whitespace inside (one holding both quotes, or a control character beside other characters, and a case-insensitive one holding a letter beside another character, or a character past ASCII that may have cases: one of the Basic Multilingual Plane, or of a script past it that has them), a repetition of no copies, one of more than 64 copies past its least or of more than 8,192 copies in all, and a rule whose alternatives are all empty. A tree that is not the schema's is refused the same way, naming what was met.

expr #

Field Value
Reads as tree
Writes from tree
Root any
Schema expr
Transducer part none
Lift none
Embedding expr-embed
Render expr-render

Read whole: A binary operator follows its left term, and a later operator can take a finished operation as its own term, as the - in 12-3 takes 12, so an expression's tree is complete only at its end: a document is read whole before anything is written.

What a document written as this format does not keep:

  • Comments, spacing, implicit lists and maps, and the document's own spelling of strings and numbers are not kept: every list is written in brackets, every object in braces with its keys quoted, every string double-quoted and every number as JSON writes it.
  • An operation of the default operators is written in infix, and a term that would need parentheses, which read back as a group, is written as a list instead, which reads back as the same tree.
  • A list whose first element is an object whose src member is a default operator's source text, as the reader's own value describes an operator, is written with that text in the object's place, as an operation where its count makes one: only the src member is read, and the object's other members, the token the operator was read from among them, are not kept. A list whose first element is an object with any other src that is not empty, zero, false or null, as a C syntax tree's token has, is refused with TARGET_VALUE_UNREPRESENTABLE, since the reader would read that src alone as the list's operator.
  • A negative number is written with its sign, which reads back as the operator - applied to the number's magnitude.
  • A number that is not finite is written as the string Infinity, -Infinity or NaN.

feed #

Field Value
Reads as tree
Writes from tree
Root object
Schema feed
Transducer part feed-transduce
Lift none
Embedding feed-embed
Render feed-render

What a document written as this format does not keep:

  • A feed is written as Atom 1.0, so one read from Atom 0.3 reads back as version 1.0.
  • An RSS feed is written as the Atom feed the reader makes of it, so what that mapping leaves out is not written: a channel's language, docs, cloud, ttl, textInput, skipHours and skipDays, its image but for its URL, which is the logo, its webMaster beside a managingEditor, and its pubDate beside a lastBuildDate.
  • An RSS item's guid is written as its entry's id without its isPermaLink flag, and its source as Atom's source element, which the reader does not read back.
  • A text construct or a content of type xhtml is written as type html, its markup as escaped text, and reads back as html with its value trimmed.
  • A feed's own elements are written in the order of the tree's members, and each entry after them as it comes, as Atom requires and as every reader and the embedding build a feed, its entries last; a tree with a member of the feed after its entries, which no reader builds, is refused part way with TARGET_VALUE_UNREPRESENTABLE.
  • A feed with no id, or a null one, is written with the id tag:tabnas.dev,2026:feed-render, which Atom requires, and an entry with none with that id, a slash and its position among the feed's entries from 0, so that no two such entries share one; each reads back as that id.
  • A feed or an entry with no title, or a null one, is written with an empty title of type text, which Atom requires, and reads back with that title.
  • A feed or an entry with no updated, or a null one, is written with the updated 1970-01-01T00:00:00Z, which Atom requires and which is the date the embedding gives a plain tree, and reads back with that date.
  • A date, a feed's or a source's updated or an entry's updated or published, is written in RFC 3339's form, which Atom requires: one in that form as it is, a t or a z in it in upper case, and one in RFC 822's form, as RSS writes dates, as the same instant, its zone as Z or as the offset it names (EST as -05:00, +0100 as +01:00), a two-digit year read as RFC 2822 reads one and seconds as 00 where it has none, so its day of the week and the spelling of its zone, its year and its names do not read back.
  • A date in neither form, among them one with a comment or with a military zone but Z, is written as 1970-01-01T00:00:00Z followed by a category whose scheme is tag:tabnas.dev,2026:feed-render/date, whose term names the member (updated or published) and whose label is the date's text, and it reads back as that category; a date with no text is written as a missing one is.
  • A feed without an author, which Atom requires of a feed unless every entry has one, is written with one named by the feed's title where that is text and not empty, and unknown otherwise, with the uri tag:tabnas.dev,2026:feed-render, which reads back as that author, though every entry may have one, since the feed's elements are written before its entries are seen.
  • A member whose value is null is not written.
  • A character XML 1.0 cannot carry, which the reader builds only from a character reference no well-formed document holds, is written as U+FFFD, the replacement character.
  • A plain tree, from another format or a program, is written through the embedding: an object's members, an array's elements or a scalar root as the entries, each titled by its value's own title where that is a string and otherwise by its key or its position, its content the value's compact JSON text, and its categories of the scheme tag:tabnas.dev,2026:feed-embed the value itself, from which the reverse reads it back exactly.
  • In the embedding the feed's id is tag:tabnas.dev,2026:feed-embed, an entry's is that, a slash and the entry's position, and every updated is 1970-01-01T00:00:00Z, since a plain tree has neither an identity nor a time.

gbnf #

Field Value
Reads as tree
Writes from tree
Root object
Schema grammar-rules
Transducer part gbnf-transduce
Lift none
Embedding none
Render gbnf-render

What a document written as this format does not keep:

  • Comments, blank lines and layout are not kept: each rule is written on one line, its alternatives between bars and its elements between spaces.
  • A string is written with the escapes GBNF and JSON share, \x08 and \x0C for the two GBNF does not have, and any other character as itself; a class's member is written as itself where it is printable ASCII and not one of the class's own marks, and as an escape otherwise: each reads back as the same element.
  • Repetitions are written in GBNF's forms, x*, x+, x?, x{m}, x{m,} and x{m,n}, after the element, the innermost first, so a repetition of a repetition is a postfix on a postfix (x*?).
  • GBNF starts from the rule named root, which its own tree names as its start: a grammar with no start, as one of ABNF or EBNF, starts from its first rule, and is written with root ::= and that rule's name after the others where it has no rule named root, which reads back with that rule added; one whose rule named root is not its first is refused with TARGET_VALUE_UNREPRESENTABLE, naming its first rule, since GBNF would start from root instead; and a start naming a rule the grammar does not define, as a GBNF document of rules none of which is root, is refused at its end, naming the rule; a grammar of no rules is written as no text.
  • A grammar of another notation is written as GBNF spells it: a case-insensitive literal (ABNF's quoted string) as its characters, each letter the class of its two cases and each other character a string of one, in a group where it has more than one, which matches what it matches; a character as a string of one, or, a surrogate, which no string holds, as a class of one; a range as a class of one range; and an RFC 5234 core rule the grammar references and does not define (ALPHA, DIGIT and the rest) as a rule of its own after the others, as ABNF's compiler adds it. Each reads back as what GBNF wrote, which the render writes again as the same text.
  • A grammar the render cannot write as GBNF is refused with TARGET_VALUE_UNREPRESENTABLE, naming the rule and what it met: prose, an incremental rule (=/), a name GBNF cannot spell (the empty name among them), an empty class, a case-insensitive literal holding a character past ASCII beside a letter of ASCII, or one that may have cases (one of the Basic Multilingual Plane, or of a script past it that has them), and a reference to the engine's own NR, ST, TX or VL token that the grammar does not define, which ABNF's and EBNF's compilers read as that token and GBNF has no form for, refused at the grammar's end, naming the rule that holds it. A tree that is not the schema's is refused the same way, naming what was met.

ini #

Field Value
Reads as tree
Writes from tree
Root object
Schema none
Transducer part ini-transduce
Lift none
Embedding none
Render ini-render

What a document written as this format does not keep:

  • Comments are not kept.
  • Every key and every string value is written double-quoted; a section name, a boolean and null are written as they are.
  • A number is written by its lexeme, or as Infinity, -Infinity or NaN, in a JSON text too, and reads back as a string, since the reader builds every unquoted value but true, false and null as a string.
  • A key that ends in a pair of square brackets reads back as an array under the name before them, since that is the reader's array mark inside quotes too.
  • A section name is written with its dots, closing brackets and backslashes escaped, and one padded with blanks reads back without them.
  • A member that follows a section inside a section is written after that section's header again, which reads back as written only while section.duplicate is merge, the default.
  • A root member that follows a section is written after the root header [], and reads back as written.
  • An array or an object INI has no place for is written as its compact JSON text, double-quoted, as the value of its key or of its array's item, and reads back as that text, a string: an array or an object inside an array, an empty array, an array under the empty key, an object nested more than 127 sections deep, and an object under a key the render writes no header for.
  • The render writes no header for a key that is blank, holds a control character or any of " ' # ; , = [, or is true, false or null or spelt with blanks and only their letters.

json #

Field Value
Reads as tree
Writes from tree
Root any
Schema none
Transducer part json-transduce
Lift none
Embedding none
Render json

What a document written as this format does not keep:

  • JSON has no spelling for Infinity or NaN, so a number that is not finite is written as null.

json5 #

Field Value
Reads as tree
Writes from tree
Root any
Schema none
Transducer part json5-transduce
Lift none
Embedding none
Render json5-render

What a document written as this format does not keep:

  • Comments are not kept.
  • Trailing commas are not kept.
  • Unquoted keys, single-quoted strings, hexadecimal numbers, leading and trailing decimal points, plus signs and line continuations are written in JSON's forms.
  • A number that is not finite is written Infinity, -Infinity or NaN, as JSON5 spells it.

jsonc #

Field Value
Reads as tree
Writes from tree
Root any
Schema none
Transducer part jsonc-transduce
Lift none
Embedding none
Render json

What a document written as this format does not keep:

  • Comments are not kept.
  • Trailing commas are not kept.
  • JSON has no spelling for Infinity or NaN, so a number that is not finite is written as null.

jsonic #

Field Value
Reads as tree
Writes from tree
Root any
Schema none
Transducer part jsonic-transduce
Lift none
Embedding none
Render json

What a document written as this format does not keep:

  • Comments are not kept.
  • Trailing commas are not kept.
  • Implicit objects and lists, unquoted keys and strings, single-quoted, backtick and multiline strings, and path-dive keys are written in JSON's forms.
  • Numbers spelled in hexadecimal, octal or binary, with digit separators, with a leading plus sign or a leading zero, or with a leading or trailing decimal point are written as plain decimal numbers.
  • JSON has no spelling for Infinity or NaN, so a number that is not finite is written as null.

jsonl #

Field Value
Reads as tree
Writes from tree
Root array
Schema none
Transducer part jsonl-transduce
Lift none
Embedding none
Render jsonl-render

What a document written as this format does not keep:

  • An element that is itself an array or object is written as compact JSON on its line.
  • Number spellings the document did not provide are written as JSON writes them.
  • JSON has no spelling for Infinity or NaN, so a number that is not finite is written as null.

markdown #

Field Value
Reads as records, tree
Writes from records
Root array
Schema markdown-ast
Transducer part markdown-transduce
Lift markdown-lift
Embedding none
Render markdown-render

What a document written as this format does not keep:

  • The rows are the elements of the root array, and a root of another kind is written as one row.
  • The columns are the first row's, an object's keys or an array's positions labelled 0, 1 and so on, so a member or position of a later row that the first row lacks is not written, and one the first row has and a later row lacks is an empty cell.
  • When the first row is a scalar there is one column, named value, and every row is written whole in it, an array or an object as its compact JSON text.
  • A table of no columns, such as the one an empty array or object makes, is written as the empty document, which reads back as the empty table.
  • Read as records, a document with no table is the empty table, of no columns and no rows.
  • Read as records, a document with several tables is its first table, and the tables after it are not read.
  • Inline markup in a cell is flattened to its text when it is read, an image to its alt text; a written cell escapes every character that can begin inline markup, so it reads back as the text it was.
  • A null and a missing cell are both written as an empty cell, so the two cannot be told apart, or from an empty string, when read back.
  • A nested array or object in a cell is written as its compact JSON text.
  • A number that is not finite is written as Infinity, -Infinity or NaN, and as null inside a nested array or object, since JSON has no spelling for one.
  • Every value is written as text, so a number or a boolean reads back as a string.
  • Column alignment is not kept.
  • A line break in a cell is written as a space.
  • Whitespace at either end of a cell is not kept, as the reader trims it: the space, the tab, U+00A0, U+FEFF, U+2028, U+2029 and the other Unicode space separators, though not U+0085.
  • A U+0000 in a cell is written as U+FFFD, the character a Markdown reader puts in its place, so it reads back as U+FFFD.
  • Read as a tree, a bracketed label is a linkReference or an imageReference whether or not the document defines it, as mdast keeps references unresolved, so one with no definition, which CommonMark reads as literal text, is a reference, and emphasis or a link around it nests as it would around a reference.
  • Read as records, a cell's reference is its text, without the brackets.

pgn #

Field Value
Reads as tree
Writes from tree
Root array
Schema pgn-database
Transducer part pgn-transduce
Lift none
Embedding none
Render pgn-render

What a document written as this format does not keep:

  • Layout is not kept: each tag pair is written on a line of its own, a blank line comes before a game's movetext and between two games, and the movetext is broken into lines of at most 79 characters where its tokens allow.
  • Move numbers are written as PGN's export format writes them, before each white move and before each black move but one that follows the white move of its number with no comment or variation between, so the document's own move numbers are not kept; a move number of more than nine digits, which the reader counts from a FEN tag, is not written, and the count gives it again.
  • A move's glyphs, comments and variations are written after it grouped by kind, in the order of the tree's members, and so are a line's own before its first move, so the order in which the document interleaved different kinds is not kept.
  • A tag pair whose name a game repeats is written once, with the value the reader keeps, the first.
  • A line escaped with a percent sign is not written, since the reader discards it.
  • A game with no tag, no movetext and no result, which the reader builds from a lone move number, is written as the move number 1.
  • A game with no result that the reader would read the next game into, one with no move or one that a game with no tag follows, is written with the termination marker *, which the reader reads as its result.

proto #

Field Value
Reads as tree
Writes from tree
Root object
Schema proto-ast
Transducer part proto-transduce
Lift none
Embedding none
Render proto-render

What a document written as this format does not keep:

  • The file is written anew from its tree: comments, blank lines and white space are not kept, and each declaration is written on a line of its own, a block's declarations indented two spaces deeper than the line that opens it.
  • An empty statement, a semicolon on its own, declares nothing and is not kept.
  • A scalar is kept as the text its tokens spell, run together, so white space between the tokens of one is not: a sign is written against its number, a qualified name with no space around its dots, and adjacent string literals with nothing between them.
  • An option's aggregate value in braces is kept as its fields, so its layout, its comments and the separators and colons between its fields are not: it is written on one line, a field holding an aggregate as name { ... } and any other as name: value.

semver #

Field Value
Reads as tree
Writes from tree
Root object
Schema semver
Transducer part none
Lift none
Embedding semver-embed
Render semver-render

Read whole: A version is made from its text only once the whole text has been accepted, since a character after it can make it no version at all, so a document's tree is complete only at its end: it is read whole before anything is written.

What a document written as this format does not keep:

  • Members other than major, minor, patch, prerelease and build are not written.
  • A prerelease or build that is absent, null, empty or an empty list is not written, and reads back as an empty list.
  • A prerelease or build given as one string is written as it is, after its hyphen or plus sign, and reads back as the list of its dot-separated identifiers.
  • A major, minor, patch or prerelease identifier given as a string of digits reads back as a number, as the reader builds one, and a build identifier given as a number reads back as a string of its digits.

toml #

Field Value
Reads as tree
Writes from tree
Root object
Schema none
Transducer part toml-transduce
Lift none
Embedding none
Render toml-render

What a document written as this format does not keep:

  • Comments are not kept.
  • Every key is written as a quoted key, and every table under a key as an inline table on that key's line.
  • Every string is written as a basic string on one line, its line breaks escaped; a literal or multi-line string is not kept as one.
  • A date or time is written as a string, since the reader builds one as text.
  • A number is written as JSON writes its value, not as the document spelled it: a hexadecimal, octal or binary integer, an underscore and an exponent are not kept, and a whole float such as 1.0 is written as an integer.
  • A null is not written: a member whose value is null is omitted, and a null element of an array is skipped.
  • An integer TOML's 64-bit integers cannot hold, below -9223372036854775808 or above 9223372036854775807, is written as a float, its digits followed by .0, and reads back as the nearest double; a number that is not finite is written inf, -inf or nan, whatever its lexeme.

xml #

Field Value
Reads as tree
Writes from tree
Root any
Schema xml-element
Transducer part xml-transduce
Lift none
Embedding xml-embed
Render xml-render

What a document written as this format does not keep:

  • An element tree, the one the reader builds, is written as it is: an object whose members are name, localName, attributes and children, with text and elements as children; one whose text or attribute value holds a character XML cannot carry, or whose element or attribute name is not an XML name, is refused, since no XML document holds it.
  • A plain tree, from another format or a program, is written through the embedding and read back by the same convention: the root value as the element document, an object as an element of type="object" whose members are member elements, each with a name attribute holding its key, and an array as an element of type="array" whose elements are item elements.
  • In the embedding a string is its element's text and an empty string an element of type="string" with no text; a number is its text in an element of type="number", INF, -INF or NaN where it is not finite, and reads back as the number, its lexeme kept; a boolean is true or false in an element of type="boolean"; and null is an element of type="null" with no text.
  • A string or a key holding a character XML cannot carry (U+0000 to U+0008, U+000B, U+000C, U+000E to U+001F, U+FFFE or U+FFFF) is written as its double-quoted JSON form, a string as the text of an element of type="string" with encoding="json" and a key in the name attribute with name-encoding="json", and reads back as the string it was.
  • The XML declaration, the DOCTYPE, comments and processing instructions are not kept: an entity the DOCTYPE declared is written as its replacement text, and an attribute it defaulted is written on the element.
  • CDATA sections are not kept: their text is written as escaped character data, and two texts the reader read either side of a CDATA section, a comment or a processing instruction read back as one; an empty text child is written as an empty CDATA section, the one spelling that reads back as one.
  • Namespace prefixes are written as part of the name; localName, prefix, namespace, space and lang are not written, since a reader derives them again from the name and from the xmlns, xml:space and xml:lang attributes, which are kept.
  • Entity and character references are written as their characters, escaped where XML requires; a carriage return, and a tab or a line feed in an attribute's value, are written as character references, since a bare one is normalised away when read.
  • Attribute values are written double-quoted, and the quoting, the white space inside a tag and a byte order mark are not kept.

yaml #

Field Value
Reads as tree
Writes from tree
Root any
Schema none
Transducer part yaml-transduce
Lift none
Embedding none
Render yaml-render

What a document written as this format does not keep:

  • Comments are not kept.
  • Anchors and aliases are not kept: an alias is written as a copy of the value it names.
  • Tags are not kept.
  • Styles are not kept: every string and key is written double-quoted, and every collection in block style.
  • A stream of several documents is written as one document, a sequence of them.

zon #

Field Value
Reads as tree
Writes from tree
Root any
Schema none
Transducer part zon-transduce
Lift none
Embedding none
Render zon-render

What a document written as this format does not keep:

  • Comments are not kept.
  • Every field name is written in the quoted identifier form, .@"name", whether or not it is a bare identifier.
  • Strings are written double-quoted with Zig's escapes, never as multiline string literals.
  • A character literal and an enum literal are written as the value the reader resolved them to, so neither reads back as a literal.
  • An empty struct is written .{}, which ZON reads as an empty tuple, so an empty object reads back as an empty array.
  • A field name is written by a convention that keeps every name apart: the empty name, which ZON has no field name for, as $empty; a name holding U+0000, which no ZON field name holds, as $json: followed by the name's double-quoted JSON form, as alchemy's quoted writes it; a name that begins with $ with one more $ in front, so $empty, $big and $json:x are written $$empty, $$big and $$json:x; and any other name as it is.
  • Each field name reads back by the reverse of that convention: $empty is the empty name; $json: followed by a text is the string the text spells as a double-quoted JSON string, as alchemy's unquoted reads it; $$ followed by a rest is $ followed by the rest; and any other name is as it is.
  • An object whose only member is $big and holds an integer's digits as the reader writes them (a string of the characters 0 to 9 and - that alchemy's number reads, other than -0), the reader's form of an integer no double holds exactly, is written as that integer, so it reads back as a number when a double holds the integer; any other object with a $big member is written as a struct, whose $big field the convention for names writes as $$big, so one whose $big holds 1-2, 01, -0 or - reads back as the object it was.

This page describes dmog 0.4.0. Written from dmog formats, in rs/src/translate.rs · This page as Markdown