func parseBinaryList(ann []Symbol, high byte, lengthByte byte, r io.Reader) (Value, error) {
	if lengthByte == 0 && high == binaryTypeList {
		return List{annotations: ann, values: []Value{}}, nil
	}
	if lengthByte == 0 && high == binaryTypeSExp {
		return SExp{annotations: ann, values: []Value{}}, nil
	}

	numBytes, errLength := determineLength32(lengthByte, r)
	if errLength != nil {
		return nil, errors.WithMessage(errLength, "unable to parse length of list")
	}

	data := make([]byte, numBytes)
	if n, err := r.Read(data); err != nil || n != int(numBytes) {
		return nil, errors.Errorf("unable to read list - read %d bytes of %d with err: %v", n, numBytes, err)
	}

	var values []Value
	dataReader := bytes.NewReader(data)
	for dataReader.Len() > 0 {
		value, err := parseNextBinaryValue(nil, dataReader)
		if err != nil {
			return nil, errors.WithMessage(err, "unable to parse list")
		}
		values = append(values, value)
	}

	if high == binaryTypeList {
		return List{annotations: ann, values: values}, nil
	}
	return SExp{annotations: ann, values: values}, nil
}
// parseBinaryList attempts to read and parse the entirety of the list whether
// it be a List (high == binaryTypeList) or SExp (high == binaryTypeSExp).
parseBinaryList attempts to read and parse the entirety of the list whether
it be a List (high == binaryTypeList) or SExp (high == binaryTypeSExp).
// parseBinaryList attempts to read and parse the entirety of the list whether // it be a List ( high == binaryTypeList ) or SExp ( high == binaryTypeSExp ) .
func parseBinaryList(ann []Symbol, high byte, lengthByte byte, r io.Reader) (Value, error) {
	if lengthByte == 0 && high == binaryTypeList {
		return List{annotations: ann, values: []Value{}}, nil
	}
	if lengthByte == 0 && high == binaryTypeSExp {
		return SExp{annotations: ann, values: []Value{}}, nil
	}
	numBytes, errLength := determineLength32(lengthByte, r)
	if errLength != nil {
		return nil, errors.WithMessage(errLength, "unable to parse length of list")
	}
	data := make([]byte, numBytes)
	if n, err := r.Read(data); err != nil || n != int(numBytes) {
		return nil, errors.Errorf("unable to read list - read %d bytes of %d with err: %v", n, numBytes, err)
	}
	var values []Value
	dataReader := bytes.NewReader(data)
	for dataReader.Len() > 0 {
		value, err := parseNextBinaryValue(nil, dataReader)
		if err != nil {
			return nil, errors.WithMessage(err, "unable to parse list")
		}
		values = append(values, value)
	}
	if high == binaryTypeList {
		return List{annotations: ann, values: values}, nil
	}
	return SExp{annotations: ann, values: values}, nil
}
func parseBinaryList ( ann [ ] Symbol , high byte , lengthByte byte , r io . Reader ) ( Value , error ) { if lengthByte == 0 && high == binaryTypeList { return List { annotations : ann , values : [ ] Value { } } , nil } if lengthByte == 0 && high == binaryTypeSExp { return SExp { annotations : ann , values : [ ] Value { } } , nil } numBytes , errLength := determineLength32 ( lengthByte , r ) if errLength != nil { return nil , errors . WithMessage ( errLength , " " ) } data := make ( [ ] byte , numBytes ) if n , err := r . Read ( data ) ; err != nil || n != int ( numBytes ) { return nil , errors . Errorf ( " " , n , numBytes , err ) } var values [ ] Value dataReader := bytes . NewReader ( data ) for dataReader . Len ( ) > 0 { value , err := parseNextBinaryValue ( nil , dataReader ) if err != nil { return nil , errors . WithMessage ( err , " " ) } values = append ( values , value ) } if high == binaryTypeList { return List { annotations : ann , values : values } , nil } return SExp { annotations : ann , values : values } , nil }
parseBinaryList attempts to read and parse the entirety of the list whether
it be a List (high == binaryTypeList) or SExp (high == binaryTypeSExp).
parseBinaryList attempts to read and parse the entirety of the list whether it be a List ( high == binaryTypeList ) or SExp ( high == binaryTypeSExp ) .