080-u8-literal.scm (1047B)
1 ; #u8(...) — bytevector literal. Each element is a fixnum byte (0..255); 2 ; result is a HDR.BV with those exact bytes. 3 4 ; Empty literal. 5 (define e #u8()) 6 (if (bytevector=? e (make-bytevector 0 0)) 0 (sys-exit 1)) 7 8 ; Length and per-byte access. 9 (define a #u8(1 2 3)) 10 (if (= (bytevector-length a) 3) 0 (sys-exit 2)) 11 (if (= (bytevector-u8-ref a 0) 1) 0 (sys-exit 3)) 12 (if (= (bytevector-u8-ref a 1) 2) 0 (sys-exit 4)) 13 (if (= (bytevector-u8-ref a 2) 3) 0 (sys-exit 5)) 14 15 ; Equality with a same-bytes string literal (both HDR.BV). 16 (if (bytevector=? #u8(65 66 67) "ABC") 0 (sys-exit 6)) 17 18 ; Hex element values are accepted (parser shares atom dispatch). 19 (define b #u8(#x00 #xff)) 20 (if (= (bytevector-length b) 2) 0 (sys-exit 7)) 21 (if (= (bytevector-u8-ref b 0) 0) 0 (sys-exit 8)) 22 (if (= (bytevector-u8-ref b 1) 255) 0 (sys-exit 8)) 23 24 ; Whitespace and comments inside the literal. 25 (define c #u8( 10 20 ; trailing comment 26 30 )) 27 (if (= (bytevector-length c) 3) 0 (sys-exit 9)) 28 (if (= (bytevector-u8-ref c 2) 30) 0 (sys-exit 10)) 29 30 (sys-exit 0)