fix small nitpicka and add example

This commit is contained in:
Alain Zscheile 2023-01-08 04:04:26 +01:00
parent 66d54b0f2a
commit 74ce57c0ed

View file

@ -23,21 +23,29 @@ header := magic[4b] generator[4b] type[4b] version[4b] tstr_loc[4b] reserve
```
The file magic at offset 0 is "YgLn" = 0x5967'4c63. The header itself forms a section, and contains the types of the top-level sections. After the first 32 bytes follows the primary linear table.
The top level linear table has `entsize = 2`.
The top level linear table has `entsize = 1`.
## Types
## File (sub)types
```
0x00000000 T_PLAIN_TEXT (UTF-8)
0x00000001 T_NESTED_TEXT
0x00000010 T_LINEAR_PLAIN_TAB
0x00000020 T_HASH_PLAIN_TAB
0x00000021 T_HASH_LINK_TAB
0x00000030 T_2DHC_PLAIN_TAB
0x00000031 T_2DHC_LINK_TAB
0x00000000 FT_NONE
0x00000001 FT_TEXT
```
## External link table (0x21, T_HASH_LINK_TAB; 0x31, T_2DHC_LINK_TAB)
## Types (in tables)
```
0x00000000 TT_PLAIN_TEXT (UTF-8)
0x00000001 TT_NESTED_TEXT
0x00000010 TT_STRING_TAB
0x00000020 TT_LINEAR_PLAIN_TAB
0x00000030 TT_HASH_PLAIN_TAB
0x00000031 TT_HASH_LINK_TAB
0x00000040 TT_2DHC_PLAIN_TAB
0x00000041 TT_2DHC_LINK_TAB
```
## External link table (0x21, TT_HASH_LINK_TAB; 0x31, TT_2DHC_LINK_TAB)
A hash table or "hilbert curve" table (see corresponding sections). Used to reference external content and facilitate its lookup.
@ -84,4 +92,39 @@ nt nesting := typ[1b]!=0 subtype[2b] length[4b] elems[1b * length]
0x010000 NTT_DIV
0x010001 NTT_GROUP
0x010002 NTT_HEADER
0x010003 NTT_QUOTE
0x010004 NTT_CODE
```
# Examples
## 01
```
@ 0000
5967 4c63 0000 0000 0000 0001 0000 0000
magic generator type version
@ 0001
0000 0005 0000 0000 0000 0000 0000 0000
tstr_loc reserved
@ 0002 linear table:
name type location esiz ecnt
0000 0001 0000 0010 0000 0005 0001 0001
.strtab strtab
0000 0009 0000 0001 0000 ???? 0001 0001
.text nt text
0000 0000 0000 0000 0000 0000 0000 0000
end-of-table marker
@ 0005 string table:
002e 7374 7274 6162 002e 7465 7874 0000
.strtab .text
@ 0006 text:
0000 0d48 656c 6c6f 2057 6f72 6c64 210a
t len Hello World!
```