@@ -27,8 +27,8 @@ elaboration, and core language is forthcoming.
2727 - [ Conditional formats] ( #conditional-formats )
2828 - [ Overlap formats] ( #overlap-formats )
2929 - [ Number formats] ( #number-formats )
30- - [ Array formats] ( #array -formats )
31- - [ Repeat formats] ( #repeat-formats )
30+ - [ Exact-length repetition formats] ( #exact-length-repetition -formats )
31+ - [ Repeat until end formats] ( #repeat-until-end -formats )
3232 - [ Limit formats] ( #limit-formats )
3333 - [ Stream position formats] ( #stream-position-formats )
3434 - [ Link formats] ( #link-formats )
@@ -140,7 +140,7 @@ If no binding is found, names can refer to one of the built-in primitives:
140140- ` u8 ` , ` u16be ` , ` u16le ` , ` u32be ` , ` u32le ` , ` u64be ` , ` u64le `
141141- ` s8 ` , ` s16be ` , ` s16le ` , ` s32be ` , ` s32le ` , ` s64be ` , ` s64le `
142142- ` f32be ` , ` f32le ` , ` f64be ` , ` f64le `
143- - ` array8 ` , ` array16 ` , ` array32 ` , ` array64 `
143+ - ` repeat_len8 ` , ` repeat_len16 ` , ` repeat_len32 ` , ` repeat_len64 `
144144- ` link8 ` , ` link16 ` , ` link32 ` , ` link64 `
145145- ` stream_pos `
146146- ` succeed ` , ` fail `
@@ -297,9 +297,9 @@ data-dependent formats. For example:
297297``` fathom
298298{
299299 len <- u32be,
300- data <- array32 len { x <- u32be, y <- u32be },
301- // ▲
302- // └─── type of `len` is `Repr u32be`
300+ data <- repeat_len32 len { x <- u32be, y <- u32be },
301+ // ▲
302+ // └─── type of `len` is `Repr u32be`
303303}
304304```
305305
@@ -319,10 +319,10 @@ let unit : Format =
319319```
320320
321321No annotations needed in the following example, as the type can be inferred from
322- the type of ` array8 ` :
322+ the type of ` repeat_len8 ` :
323323
324324``` fathom
325- array8 3 {}
325+ repeat_len8 3 {}
326326```
327327
328328#### Tuple syntax for record formats
@@ -386,10 +386,10 @@ more convenient:
386386
387387 ⋮
388388
389- start_code <- array16 seg_count u16be,
390- id_delta <- array16 seg_count s16be,
391- // ▲
392- // └──── `seg_count` is used here
389+ start_code <- repeat_len16 seg_count u16be,
390+ id_delta <- repeat_len16 seg_count s16be,
391+ // ▲
392+ // └──── `seg_count` is used here
393393}
394394```
395395
@@ -431,12 +431,12 @@ because they might appear in the representation types of subsequent fields.
431431
432432Some some examples of record formats and their representations are:
433433
434- | format | ` Repr ` format |
435- | ------------------------------------------------- | -------------------------------------- |
436- | ` { x <- f32le, y <- f32le } ` | ` { x : F32, y : F32 } ` |
437- | ` { len <- u16be, data <- array16 len s8 } ` | ` { len : U16, data : Array16 len S8 } ` |
438- | ` { magic <- u32be where u32_eq magic "icns" } ` | ` { magic : U32 } ` |
439- | ` { let len = 4 : U32, data <- array32 len s8 } ` | ` { len : U32, data : Array32 len S8 } ` |
434+ | format | ` Repr ` format |
435+ | ----------------------------------------------------- | -------------------------------------- |
436+ | ` { x <- f32le, y <- f32le } ` | ` { x : F32, y : F32 } ` |
437+ | ` { len <- u16be, data <- repeat_len16 len s8 } ` | ` { len : U16, data : Array16 len S8 } ` |
438+ | ` { magic <- u32be where u32_eq magic "icns" } ` | ` { magic : U32 } ` |
439+ | ` { let len = 4 : U32, data <- repeat_len32 len s8 } ` | ` { len : U32, data : Array32 len S8 } ` |
440440
441441### Conditional formats
442442
@@ -479,8 +479,8 @@ enriched with information that occurs later on in the stream:
479479
480480``` fathom
481481overlap {
482- records0 : array16 len array_record0,
483- records1 : array16 len (array_record0 records0),
482+ records0 : repeat_len16 len array_record0,
483+ records1 : repeat_len16 len (array_record0 records0),
484484}
485485```
486486
@@ -535,36 +535,40 @@ corresponding host representation:
535535| ` f32be ` , ` f32le ` | ` F32 ` |
536536| ` f64be ` , ` f64le ` | ` F64 ` |
537537
538- ### Array formats
538+ ### Exact-length repetition formats
539539
540- There are four array formats, corresponding to the four [ array types] ( #arrays ) :
540+ There are four length constrained repetition formats, corresponding to the four
541+ [ array types] ( #arrays ) :
541542
542- - ` array8 : U8 -> Format -> Format`
543- - ` array16 : U16 -> Format -> Format`
544- - ` array32 : U32 -> Format -> Format`
545- - ` array64 : U64 -> Format -> Format`
543+ - ` repeat_len8 : U8 -> Format -> Format`
544+ - ` repeat_len16 : U16 -> Format -> Format`
545+ - ` repeat_len32 : U32 -> Format -> Format`
546+ - ` repeat_len64 : U64 -> Format -> Format`
546547
547- #### Representation of array formats
548+ These formats will parse the specified number of elements, failing if one of
549+ those elements failed to parse, or if the end of the current binary stream was
550+ reached.
548551
549- The [ representation] ( #format-representations ) of the array formats preserve the
550- lengths, and use the representation of the element formats as the element types
551- of the host [ array types] ( #array-types ) .
552+ #### Representation of exact-length repetition formats
552553
553- | format | ` Repr ` format |
554- | ---------------------- | ----------------------------------- |
555- | ` array8 len format ` | ` Array8 len (Repr format) ` |
556- | ` array16 len format ` | ` Array16 len (Repr format) ` |
557- | ` array32 len format ` | ` Array32 len (Repr format) ` |
558- | ` array64 len format ` | ` Array64 len (Repr format) ` |
554+ The [ representation] ( #format-representations ) of the repetition formats preserve
555+ the lengths in a corresponding [ array type] ( #array-types ) :
559556
560- ### Repeat formats
557+ | format | ` Repr ` format |
558+ | --------------------------- | ----------------------------------- |
559+ | ` repeat_len8 len format ` | ` Array8 len (Repr format) ` |
560+ | ` repeat_len16 len format ` | ` Array16 len (Repr format) ` |
561+ | ` repeat_len32 len format ` | ` Array32 len (Repr format) ` |
562+ | ` repeat_len64 len format ` | ` Array64 len (Repr format) ` |
563+
564+ ### Repeat until end formats
561565
562566The ` repeat_until_end ` format repeats parsing the given format until the end of
563567the current binary stream is reached:
564568
565569- ` repeat_until_end : Format -> Format `
566570
567- #### Representation of repeat formats
571+ #### Representation of repeat until end formats
568572
569573Because the repeat format does not have a predefined length, it is
570574[ represented] ( #format-representations ) as a dynamically sized
0 commit comments