diff options
| author | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-28 23:17:02 +0200 |
|---|---|---|
| committer | Taylan Kammer <taylan.kammer@gmail.com> | 2026-06-28 23:17:02 +0200 |
| commit | 594e34e1145e0b23a685e1685a181751dd5d0044 (patch) | |
| tree | daaa8f459e0e9434a22698433066cb5abf43ad11 /doc/0/1-parse.md | |
| parent | d129b1fe89866d540e4a6faeee7433b6ad51be4a (diff) | |
Yet another NaN-packing design change.
Diffstat (limited to 'doc/0/1-parse.md')
| -rw-r--r-- | doc/0/1-parse.md | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/doc/0/1-parse.md b/doc/0/1-parse.md index 54b1dd4..91407da 100644 --- a/doc/0/1-parse.md +++ b/doc/0/1-parse.md @@ -6,9 +6,9 @@ Zisp s-expressions represent an extremely minimal set of data types; only that which is necessary to strategically construct more complex values: +---------+--------+--------+ - | String | Rune | List | + | String | List | Rune | +---------+--------+--------+ - | foobar | #name | (...) | + | foobar | (...) | #name | +---------+--------+--------+ The parser recognizes various *syntax sugar* which abbreviates verbose syntax, @@ -199,6 +199,26 @@ contain NUL bytes, in which case this optimization isn't used.) Longer strings may be *interned* which is a feature explained further below. Otherwise, each string is allocated separately, and represented by its unique memory address. +### List + +A list is a sequence of values with a fixed length. + +A unique, contiguous array of values is allocated in program memory for each +list of non-zero length, and the list as a value is then represented by the +memory address of the array. The empty list is represented by a distinct +canonical bit pattern. + +Lists are valid as a datum if one of the following holds true: + +* The list encodes a quoted string, datum label, or shebang line. + +* All values in the list are a valid datum, or it is empty. + +Further, a structure of nested list values may not contain cyclic references +back up in the structure (which would make the above definition diverge into +infinity). Such cycles must be broken up with datum labels, or else the list +cannot be considered a datum, since it cannot be printed or parsed. + ### Rune A rune is represented by an ASCII character sequence of 1 to 6 bytes, that must @@ -219,26 +239,6 @@ default decoder settings and documented explicitly as such. Runes are always stored directly in a CPU word; never by memory address. -### List - -A list is a sequence of values with a fixed length. - -A unique, contiguous array of values is allocated in program memory for each -list of non-zero length, and the list as a value is then represented by the -memory address of the array. The empty list is represented by a specific -canonical bit pattern. - -Lists are valid as a datum if one of the following holds true: - -* The list encodes a quoted string, datum label, or shebang line. - -* All values in the list are a valid datum, or it is empty. - -Further, a structure of nested list values may not contain cyclic references -back up in the structure (which would make the above definition diverge into -infinity). Such cycles must be broken up with datum labels, or else the list -cannot be considered a datum, since it cannot be printed or parsed. - ## String interning |
