Tighten
This commit is contained in:
parent
f84f495c93
commit
80fb72f782
65
preserve.md
65
preserve.md
|
@ -320,31 +320,26 @@ Each `Repr` takes one of three possible forms:
|
|||
Applications may choose between formats B and C depending on their
|
||||
needs at serialization time.
|
||||
|
||||
Every `Repr` starts with a *lead byte* describing the remainder of the
|
||||
representation.
|
||||
|
||||
#### The lead byte
|
||||
|
||||
The lead byte is constructed by a function `leadbyte`:
|
||||
Every `Repr` starts with a *lead byte*, constructed by
|
||||
`leadbyte(t,n,m)`, where `t`,`n`∈{0,1,2,3} and 0≤`m`<16:
|
||||
|
||||
leadbyte(t,n,m) = [t*64 + n*16 + m]
|
||||
|
||||
Both `t` and `n` are two-bit unsigned numbers; `m` is a four-bit
|
||||
unsigned number.
|
||||
|
||||
The lead byte describes the rest of the representation as
|
||||
follows:[^some-encodings-unused]
|
||||
The arguments `t` and `n` describe the rest of the
|
||||
representation:[^some-encodings-unused]
|
||||
|
||||
[^some-encodings-unused]: Some encodings are unused. All such
|
||||
encodings are reserved for future versions of this specification.
|
||||
|
||||
- `leadbyte(0,0,-)` (format A) represents an Atom with fixed-length binary representation.
|
||||
- `leadbyte(0,1,-)` (format A) is reserved.
|
||||
- `leadbyte(0,2,-)` (format C) is a Stream Start byte.
|
||||
- `leadbyte(0,3,-)` (format C) is a Stream End byte.
|
||||
- `leadbyte(1,-,-)` (format B) represents an Atom with variable-length binary representation.
|
||||
- `leadbyte(2,-,-)` (format B) represents a Record.
|
||||
- `leadbyte(3,-,-)` (format B) represents a Sequence, Set or Dictionary.
|
||||
- `t`=0, `n`=0 (format A) represents an `Atom` with fixed-length binary representation.
|
||||
- `t`=0, `n`=1 (format A) represents certain small `SignedInteger`s.
|
||||
- `t`=0, `n`=2 (format C) is a Stream Start byte.
|
||||
- `t`=0, `n`=3 (format C) is a Stream End byte.
|
||||
- `t`=1 (format B) represents an `Atom` with variable-length binary representation.
|
||||
- `t`=2 (format B) represents a `Record`.
|
||||
- `t`=3 (format B) represents a `Sequence`, `Set` or `Dictionary`.
|
||||
|
||||
#### Encoding data of fixed length (format A)
|
||||
|
||||
|
@ -494,9 +489,7 @@ order.
|
|||
|
||||
Note that `header(3,3,m)` and `open(3,3)`/`close(3,3)` is unused and reserved.
|
||||
|
||||
### Variable-length Atoms
|
||||
|
||||
#### SignedInteger
|
||||
### SignedIntegers
|
||||
|
||||
Format B/A (known length/fixed-size):
|
||||
|
||||
|
@ -522,32 +515,16 @@ needed to unambiguously identify the value and its sign, and `m =
|
|||
|
||||
For example,
|
||||
|
||||
[[ -257 ]] = [0x42, 0xFE, 0xFF]
|
||||
[[ -256 ]] = [0x42, 0xFF, 0x00]
|
||||
[[ -255 ]] = [0x42, 0xFF, 0x01]
|
||||
[[ -254 ]] = [0x42, 0xFF, 0x02]
|
||||
[[ -129 ]] = [0x42, 0xFF, 0x7F]
|
||||
[[ -128 ]] = [0x41, 0x80]
|
||||
[[ -127 ]] = [0x41, 0x81]
|
||||
[[ -4 ]] = [0x41, 0xFC]
|
||||
[[ -3 ]] = [0x1D]
|
||||
[[ -2 ]] = [0x1E]
|
||||
[[ -1 ]] = [0x1F]
|
||||
[[ 0 ]] = [0x10]
|
||||
[[ 1 ]] = [0x11]
|
||||
[[ 12 ]] = [0x1C]
|
||||
[[ 13 ]] = [0x41, 0x0D]
|
||||
[[ 127 ]] = [0x41, 0x7F]
|
||||
[[ 128 ]] = [0x42, 0x00, 0x80]
|
||||
[[ 255 ]] = [0x42, 0x00, 0xFF]
|
||||
[[ 256 ]] = [0x42, 0x01, 0x00]
|
||||
[[ 32767 ]] = [0x42, 0x7F, 0xFF]
|
||||
[[ 32768 ]] = [0x43, 0x00, 0x80, 0x00]
|
||||
[[ 65535 ]] = [0x43, 0x00, 0xFF, 0xFF]
|
||||
[[ 65536 ]] = [0x43, 0x01, 0x00, 0x00]
|
||||
[[ 131072 ]] = [0x43, 0x02, 0x00, 0x00]
|
||||
[[ -257 ]] = 42 FE FF [[ -3 ]] = 1D [[ 128 ]] = 42 00 80
|
||||
[[ -256 ]] = 42 FF 00 [[ -2 ]] = 1E [[ 255 ]] = 42 00 FF
|
||||
[[ -255 ]] = 42 FF 01 [[ -1 ]] = 1F [[ 256 ]] = 42 01 00
|
||||
[[ -254 ]] = 42 FF 02 [[ 0 ]] = 10 [[ 32767 ]] = 42 7F FF
|
||||
[[ -129 ]] = 42 FF 7F [[ 1 ]] = 11 [[ 32768 ]] = 43 00 80 00
|
||||
[[ -128 ]] = 41 80 [[ 12 ]] = 1C [[ 65535 ]] = 43 00 FF FF
|
||||
[[ -127 ]] = 41 81 [[ 13 ]] = 41 0D [[ 65536 ]] = 43 01 00 00
|
||||
[[ -4 ]] = 41 FC [[ 127 ]] = 41 7F [[ 131072 ]] = 43 02 00 00
|
||||
|
||||
#### String, ByteString and Symbol
|
||||
### Strings, ByteStrings and Symbols
|
||||
|
||||
Syntax for these three types varies only in the value of `n` supplied
|
||||
to `header`, `open`, and `close`. In each case, the payload following
|
||||
|
|
Loading…
Reference in New Issue