Text
Table of Contents
Classes
- Escapes
- Shared escape decoding/encoding for DXN's `string`/`char`/quoted
-`keyword` bodies (`dxn/DXN.md` §1.1's `escape` production) -- one
implementation so no caller duplicates it.
- Formatter
- Multi-line, indented `.dxn` rendering -- the `pretty: true` option
on `Dextrin::encode()`, built on top of {@see Printer}. Every
non-empty collection gets one entry per line, indented one level
deeper than its container; every empty collection and every scalar
falls through to the single-line printer unchanged (there's nothing
multi-line about `[]` or `42`).
- Lexer
- Hand-written `.dxn` tokenizer, directly off `dxn/DXN.md` §1.1's
lexical grammar. No parser-generator dependency -- the grammar is
small and fully normative.
- LexError
- ParseError
- Parser
- Hand-written recursive-descent `.dxn` parser -- the reverse of
{@see Printer}, built directly on {@see Lexer}'s token stream.
- Printer
- `.dxn` printer -- the reverse of {@see Parser}. Single-line,
minimal-whitespace output: a printer, not a formatter (no
line-wrapping/indentation policy is specified anywhere in
`dxn/DXN.md`) -- {@see Formatter} owns multi-line, human-readable
rendering, built on top of this class.
- Temporal
- ISO 8601 parsing/formatting shared by the `.dxn` text parser and
printer for `date`/`time`/`timestamp`/`datetime`/`duration` -- one
implementation so encode/decode never drift apart. Builds instants
via `DateTimeImmutable` (constructing the wall-clock value directly
in the relevant `DateTimeZone`, then reading back the UTC epoch)
rather than hand-rolling epoch arithmetic -- PHP's own offset
handling is already correct, unlike JS, which needed a hand-written
floor-division helper to get pre-epoch instants right.
- Token
- One lexed token. `start`/`end` are **codepoint indices**, not byte
offsets -- {@see Lexer} operates on the source split into an array
of single-codepoint strings (`preg_split('//u', ...)`) rather than
raw byte-indexed PHP strings, which sidesteps multi-byte UTF-8
sequences entirely (a JS port indexes UTF-16 code units natively;
PHP strings are raw bytes, so this port picks codepoints as its own
natural, consistently-defined unit instead).