@@ -9,8 +9,8 @@ duplicating them. These references are referred to as "back references".
9
9
The original serialization format had 3 tokens.
10
10
11
11
- ` 0xff ` - a pair, followed by the left and right sub-trees.
12
- - ` 0x80 ` - NIL, an empty atom
13
- - Atom - serialized with a UTF-8 like encoding. (see [ CLVM serialization] ( https://chialisp.com/clvm/#serialization ) )
12
+ - Atom - values, in the form of an array of bytes. For more details, see [ CLVM
13
+ serialization] ( https://chialisp.com/clvm/#serialization ) .
14
14
15
15
A back reference is introduced by ` 0xfe ` followed by an atom. The atom refers
16
16
back to an already decoded sub tree. The bits are interpreted just like an
@@ -29,9 +29,9 @@ byte index: | byte 0 | byte 1 | byte 2 | byte 3 |
29
29
bit traversal direction: <- x
30
30
```
31
31
32
- A 0 bit means follow the left sub-tree, a 1- bit means follow the right sub-tree.
33
- The last 1-bit is the terminator, and means we should pick the node at the
34
- current location in the tree.
32
+ A ` 0 ` bit means follow the left sub-tree while a ` 1 ` bit means follow the right
33
+ sub-tree. The last 1-bit is the terminator, and means we should pick the node at
34
+ the current location in the tree.
35
35
36
36
e.g. The reference ` 0b1011 ` means:
37
37
@@ -68,7 +68,7 @@ as we parse, so what a back reference refers to changes as we parse the
68
68
serialized CLVM tree. To understand what the parse stack is, we first need to
69
69
look at how CLVM is parsed.
70
70
71
- The parser has a stack of _ operations_ and a stack of the parsed result (the
71
+ The parser has a stack of _ operations_ and a stack of the parsed results (the
72
72
parse stack).
73
73
74
74
There are 2 operations that can be pushed onto the operations stack:
@@ -81,7 +81,7 @@ encounter when parsing; an atom or a pair (followed by the left- and right
81
81
sub-trees).
82
82
83
83
We keep popping operations off of the op-stack until it's empty. We take the
84
- following actions dependin on the operation:
84
+ following actions depending on the operation:
85
85
86
86
- ` Traverse ` , inspect the next byte of the input stream. If it's a pair (` 0xff ` )
87
87
we push ` Cons ` , ` Traverse ` , ` Traverse ` onto the operations stack. If it's an
@@ -128,7 +128,7 @@ A back reference to `3` would be: `0b1100` (right, left).
128
128
### Example back-reference
129
129
130
130
Consider the following LISP structure: ((` 1 ` . ` 2 ` ) . (` 1 ` . ` 2 ` ))
131
- It Can be serialized as ` 0xff ` ` 0xff ` ` 1 ` ` 2 ` ` 0xfe ` ` 0b10 `
131
+ It can be serialized as ` 0xff ` ` 0xff ` ` 1 ` ` 2 ` ` 0xfe ` ` 0b10 `
132
132
133
133
The parsing steps would be as follows:
134
134
@@ -181,8 +181,7 @@ When serializing with compression, we need to assign a tree-hash and an
181
181
the sub-tree itself or a back-reference, we need to know whether we have already
182
182
serialized an identical sub tree. If we have, we then have to perform a search
183
183
from that node up all of its parents until we reach the top of the parse stack.
184
- This, additionally, requires a data structure that knows about the parents of
185
- all nodes.
184
+ This requires a data structure that knows about the parents of all nodes.
186
185
187
186
This search is performed in ` find_path() ` . There may be multiple paths leading
188
187
to the stack (if the same structure is repeated in multiple places). We pick the
0 commit comments