add morphisms to Msb-ContinuationBit Sequences
This commit is contained in:
parent
b88251b9c4
commit
4a5977ec8e
2 changed files with 44 additions and 8 deletions
|
@ -3,22 +3,57 @@ morph_array_as_valterm_to_lenpfx (Terminator:x86.UInt8)
|
||||||
--> <Seq~<LengthPrefix x86.UInt64> x86.UInt8>
|
--> <Seq~<LengthPrefix x86.UInt64> x86.UInt8>
|
||||||
```
|
```
|
||||||
length_prefix_uint8_array_clear(dst);
|
length_prefix_uint8_array_clear(dst);
|
||||||
while( *src != Terminator ) {
|
while( *src != Terminator )
|
||||||
length_prefix_uint8_array_push(dst, *src);
|
length_prefix_uint8_array_push(dst, *src++);
|
||||||
src++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
morph_array_as_lenpfx_to_valterm (Terminator:x86.UInt8)
|
morph_array_as_lenpfx_to_valterm (Terminator:x86.UInt8)
|
||||||
<Seq~<LengthPrefix x86.UInt64> x86.UInt8>
|
<Seq~<LengthPrefix x86.UInt64> x86.UInt8>
|
||||||
--> <Seq~<ValueTerminated Terminator> x86.UInt8>
|
--> <Seq~<ValueTerminated Terminator> x86.UInt8>
|
||||||
```
|
```
|
||||||
for( uint64_t i = 0; i < src->len; ++i ) {
|
for( uint64_t i = 0; i < src->len; ++i )
|
||||||
*dst ++ = src->items[i];
|
*dst++ = src->items[i];
|
||||||
}
|
|
||||||
*dst = Terminator;
|
*dst = Terminator;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
morph_array_as_lenpfx_to_continuation_bit_8 ()
|
||||||
|
<Seq~<LengthPrefix x86.UInt64> x86.UInt8>
|
||||||
|
--> <Seq~MsbCont x86.UInt8>
|
||||||
|
```
|
||||||
|
for( uint64_t i = 0; i < src->len; ++i ) {
|
||||||
|
if( src->items[i] & (1<<7) ) {
|
||||||
|
fprintf(stderr, "error: value to high for MsbContinuation\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst[i] = src->items[i];
|
||||||
|
if( i+1 < src->len )
|
||||||
|
dst[i] |= (1<<7);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
```
|
||||||
|
|
||||||
|
morph_array_as_lenpfx_to_continuation_bit_16 ()
|
||||||
|
<Seq~<LengthPrefix x86.UInt64> x86.UInt16>
|
||||||
|
--> <Seq~MsbCont x86.UInt16>
|
||||||
|
```
|
||||||
|
for( uint64_t i = 0; i < src->len; ++i ) {
|
||||||
|
if( src->items[i] & (1<<15) ) {
|
||||||
|
fprintf(stderr, "error: value to high for MsbContinuation\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dst[i] = src->items[i];
|
||||||
|
if( i+1 < src->len )
|
||||||
|
dst[i] |= (1<<15);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
```
|
||||||
|
|
|
@ -358,7 +358,8 @@ fn parser(
|
||||||
fn main() {
|
fn main() {
|
||||||
let mut type_dict = Arc::new(RwLock::new(BimapTypeDict::new()));
|
let mut type_dict = Arc::new(RwLock::new(BimapTypeDict::new()));
|
||||||
let mut morphism_base = laddertypes::MorphismBase::<LdmcMorphism>::new(vec![
|
let mut morphism_base = laddertypes::MorphismBase::<LdmcMorphism>::new(vec![
|
||||||
type_dict.parse("Seq~<ValueTerminated '\\0'>").expect(""),
|
//type_dict.parse("Seq~MsbCont").expect(""),
|
||||||
|
//type_dict.parse("Seq~<ValueTerminated '\\0'>").expect(""),
|
||||||
type_dict.parse("Seq~<LengthPrefix x86.UInt64>").expect("")
|
type_dict.parse("Seq~<LengthPrefix x86.UInt64>").expect("")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue