Remove single-precision floats from the implementations

This commit is contained in:
Tony Garnock-Jones 2024-01-27 14:40:37 +01:00
parent dc1b0ac54d
commit be32f9b7c8
89 changed files with 464 additions and 1305 deletions

View File

@ -13,5 +13,5 @@ defaults:
layout: page
title: "Preserves"
version_date: "October 2023"
version: "0.992.0"
version_date: "January 2024"
version: "0.993.0"

View File

@ -261,7 +261,6 @@ PRESERVES_OUTOFLINE
typedef enum preserves_type_tag {
PRESERVES_BOOLEAN = 0,
PRESERVES_FLOAT,
PRESERVES_DOUBLE,
PRESERVES_SIGNED_INTEGER,
@ -283,7 +282,6 @@ typedef enum preserves_type_tag {
PRESERVES_OUTOFLINE(char const *preserves_type_tag_name(preserves_type_tag_t type), {
switch (type) {
case PRESERVES_BOOLEAN: return "BOOLEAN";
case PRESERVES_FLOAT: return "FLOAT";
case PRESERVES_DOUBLE: return "DOUBLE";
case PRESERVES_SIGNED_INTEGER: return "SIGNED_INTEGER";
case PRESERVES_STRING: return "STRING";
@ -366,7 +364,6 @@ PRESERVES_OUTOFLINE
/*
PRESERVES_BOOLEAN: repr==PRESERVES_REPR_NONE, len=0, data._boolean
PRESERVES_FLOAT: repr=PRESERVES_REPR_NONE, len=0, data._float
PRESERVES_DOUBLE: repr=PRESERVES_REPR_NONE, len=0, data._double
PRESERVES_SIGNED_INTEGER:
@ -418,7 +415,6 @@ typedef struct preserves_index_entry {
union {
bool _boolean;
float _float;
double _double;
int64_t _signed;
uint64_t _unsigned;
@ -818,18 +814,6 @@ PRESERVES_OUTOFLINE
uint8_t *bs = _preserves_reader_next_bytes(r, len);
if (bs == NULL) return _preserves_reader_finish(r, PRESERVES_END_INCOMPLETE_INPUT);
switch (len) {
case 4: {
uint32_t i;
memcpy(&i, bs, 4);
i = ntohl(i);
float f;
memcpy(&f, &i, 4);
RETURN_ON_FAIL(_preserves_reader_emit_entry(r, &count, (preserves_index_entry_t) {
.type = PRESERVES_FLOAT, .repr = PRESERVES_REPR_NONE, .len = 0, .data = {
._float = f
}}));
break;
}
case 8: {
uint32_t lo, hi;
memcpy(&hi, bs, 4);
@ -995,10 +979,6 @@ PRESERVES_IMPLEMENTATION_CHUNK
fprintf(f, i->data._boolean ? " #t" : " #f");
break;
case PRESERVES_FLOAT:
fprintf(f, " %f", i->data._float);
break;
case PRESERVES_DOUBLE:
fprintf(f, " %f", i->data._double);
break;

View File

@ -41,15 +41,6 @@ namespace Preserves {
decodeEmbedded(decodeEmbedded)
{}
boost::optional<float> next_float() {
uint8_t buf[4];
if (!next_chunk(buf, sizeof(buf))) return boost::none;
uint32_t n = buf[0] << 24 | buf[1] << 16 | buf[2] << 8 | buf[3];
float f;
memcpy(&f, &n, sizeof(f));
return f;
}
boost::optional<double> next_double() {
uint8_t buf[8];
if (!next_chunk(buf, sizeof(buf))) return boost::none;
@ -113,7 +104,6 @@ namespace Preserves {
return BinaryReader<>(i).next().map(decodeEmbedded).map(Value<T>::from_embedded);
case BinaryTag::Ieee754: return varint(i).flat_map([&](size_t len)-> boost::optional<Value<T>> {
switch (len) {
case 4: return next_float().map(Value<T>::from_float);
case 8: return next_double().map(Value<T>::from_double);
default: return boost::none;
}

View File

@ -151,19 +151,6 @@ namespace Preserves {
return (*this) << (b ? BinaryTag::True : BinaryTag::False);
}
BinaryWriter& operator<<(float f) {
uint32_t n;
memcpy(&n, &f, sizeof(f));
uint8_t buf[4];
buf[0] = (n >> 24) & 0xff;
buf[1] = (n >> 16) & 0xff;
buf[2] = (n >> 8) & 0xff;
buf[3] = (n) & 0xff;
(*this) << BinaryTag::Ieee754;
put(uint8_t(sizeof(buf)));
return write(buf, sizeof(buf));
}
BinaryWriter& operator<<(double d) {
uint64_t n;
memcpy(&n, &d, sizeof(d));

View File

@ -35,13 +35,6 @@ namespace Preserves {
BinaryWriter& write(BinaryWriter& w) const override {
return w << this->_value();
});
PRESERVES_ATOMIC_VALUE_CLASS(Float, float, float, ValueKind::Float, as_float,
BinaryWriter& write(BinaryWriter& w) const override {
return w << this->_value();
}
boost::optional<double> as_double() const override {
return this->value;
});
PRESERVES_ATOMIC_VALUE_CLASS(Double, double, double, ValueKind::Double, as_double,
BinaryWriter& write(BinaryWriter& w) const override {
return w << this->_value();
@ -57,13 +50,6 @@ namespace Preserves {
return boost::none;
}
}
boost::optional<float> as_float() const override {
if (uint64_t(float(this->value)) == this->value) {
return float(this->value);
} else {
return boost::none;
}
}
boost::optional<double> as_double() const override {
if (uint64_t(double(this->value)) == this->value) {
return double(this->value);
@ -82,13 +68,6 @@ namespace Preserves {
return boost::none;
}
}
boost::optional<float> as_float() const override {
if (int64_t(float(this->value)) == this->value) {
return float(this->value);
} else {
return boost::none;
}
}
boost::optional<double> as_double() const override {
if (int64_t(double(this->value)) == this->value) {
return double(this->value);
@ -295,7 +274,6 @@ namespace Preserves {
bool is_mutable() const override { return underlying.is_mutable(); }
boost::optional<bool> as_bool() const override { return underlying.as_bool(); }
boost::optional<float> as_float() const override { return underlying.as_float(); }
boost::optional<double> as_double() const override { return underlying.as_double(); }
boost::optional<uint64_t> as_unsigned() const override { return underlying.as_unsigned(); }
boost::optional<int64_t> as_signed() const override { return underlying.as_signed(); }
@ -355,12 +333,6 @@ namespace Preserves {
return Value<T>(new Boolean<T>(b));
}
template <typename T>
Value<T> Value<T>::from_float(float f)
{
return Value<T>(new Float<T>(f));
}
template <typename T>
Value<T> Value<T>::from_double(double d)
{

View File

@ -14,7 +14,6 @@ namespace Preserves {
enum class ValueKind {
Boolean,
Float,
Double,
SignedInteger,
String,
@ -43,7 +42,6 @@ namespace Preserves {
std::shared_ptr<ValueImpl<T>> _impl() const { return p; }
static Value from_bool(bool b);
static Value from_float(float f);
static Value from_double(double d);
static Value from_int(uint64_t i);
static Value from_int(int64_t i);
@ -67,11 +65,9 @@ namespace Preserves {
static Value from_number(uint64_t i) { return from_int(i); }
static Value from_number(int64_t i) { return from_int(i); }
static Value from_number(float f) { return from_float(f); }
static Value from_number(double d) { return from_double(d); }
static Value from(bool b) { return from_bool(b); }
static Value from(float f) { return from_float(f); }
static Value from(double d) { return from_double(d); }
static Value from(uint64_t i) { return from_int(i); }
static Value from(unsigned i) { return from_int(uint64_t(i)); }
@ -95,7 +91,6 @@ namespace Preserves {
bool is_mutable() const;
bool is_bool() const { return value_kind() == ValueKind::Boolean; }
bool is_float() const { return value_kind() == ValueKind::Float; }
bool is_double() const { return value_kind() == ValueKind::Double; }
bool is_int() const { return value_kind() == ValueKind::SignedInteger; }
bool is_string() const { return value_kind() == ValueKind::String; }
@ -109,9 +104,6 @@ namespace Preserves {
boost::optional<bool> as_bool() const;
bool to_bool() const { return as_bool().value(); }
boost::optional<float> as_float() const;
float to_float() const { return as_float().value(); }
boost::optional<double> as_double() const;
double to_double() const { return as_double().value(); }
@ -175,7 +167,6 @@ namespace Preserves {
virtual bool is_mutable() const { return false; }
virtual boost::optional<bool> as_bool() const { return boost::none; }
virtual boost::optional<float> as_float() const { return boost::none; }
virtual boost::optional<double> as_double() const { return boost::none; }
virtual boost::optional<uint64_t> as_unsigned() const { return boost::none; }
virtual boost::optional<int64_t> as_signed() const { return boost::none; }
@ -219,7 +210,6 @@ namespace Preserves {
#define PRESERVES_DELEGATE_CAST(t, name) \
template <typename T> boost::optional<t> Value<T>::name() const { return p->name(); }
PRESERVES_DELEGATE_CAST(bool, as_bool);
PRESERVES_DELEGATE_CAST(float, as_float);
PRESERVES_DELEGATE_CAST(double, as_double);
PRESERVES_DELEGATE_CAST(uint64_t, as_unsigned);
PRESERVES_DELEGATE_CAST(int64_t, as_signed);
@ -265,7 +255,6 @@ namespace Preserves {
if (bKind < aKind) return false;
switch (aKind) {
case ValueKind::Boolean: return a.to_bool() < b.to_bool();
case ValueKind::Float: return a.to_float() < b.to_float();
case ValueKind::Double: return a.to_double() < b.to_double();
case ValueKind::SignedInteger: {
if (auto av = a.as_signed()) {

View File

@ -1,6 +1,6 @@
{
"name": "@preserves/core",
"version": "0.992.4",
"version": "0.993.0",
"description": "Preserves data serialization format",
"homepage": "https://gitlab.com/preserves/preserves",
"license": "Apache-2.0",

View File

@ -2,7 +2,7 @@ import { Annotated } from "./annotated";
import { DecodeError, ShortPacket } from "./codec";
import { Tag } from "./constants";
import { Set, Dictionary } from "./dictionary";
import { DoubleFloat, SingleFloat } from "./float";
import { DoubleFloat } from "./float";
import { Record } from "./record";
import { Bytes, BytesLike, underlying, hexDigit } from "./bytes";
import { Value } from "./values";
@ -31,7 +31,6 @@ export interface TypedDecoder<T> {
body: (d: TypedDecoder<S>) => R): R;
nextBoolean(): boolean | undefined;
nextFloat(): SingleFloat | undefined;
nextDouble(): DoubleFloat | undefined;
nextEmbedded(): Embedded<T> | undefined;
nextSignedInteger(): number | bigint | undefined;
@ -241,7 +240,6 @@ export class Decoder<T = never> implements TypedDecoder<T> {
case Tag.Embedded: return this.state.wrap<T>(embed(this.embeddedDecode.decode(this.state)));
case Tag.Ieee754:
switch (this.state.varint()) {
case 4: return this.state.wrap<T>(SingleFloat.fromBytes(this.state.nextbytes(4)));
case 8: return this.state.wrap<T>(DoubleFloat.fromBytes(this.state.nextbytes(8)));
default: throw new DecodeError("Invalid IEEE754 size");
}
@ -308,14 +306,6 @@ export class Decoder<T = never> implements TypedDecoder<T> {
});
}
nextFloat(): SingleFloat | undefined {
return this.skipAnnotations((reset) => {
if (this.state.nextbyte() !== Tag.Ieee754) return reset();
if (this.state.nextbyte() !== 4) return reset();
return SingleFloat.fromBytes(this.state.nextbytes(4));
});
}
nextDouble(): DoubleFloat | undefined {
return this.skipAnnotations((reset) => {
if (this.state.nextbyte() !== Tag.Ieee754) return reset();

View File

@ -5,7 +5,8 @@ import type { Encoder, Preservable } from "./encoder";
import type { Writer, PreserveWritable } from "./writer";
import { Bytes, dataview } from "./bytes";
export type FloatType = 'Single' | 'Double';
// v Previously included 'Single'; may again in future. Also, 'Half', 'Quad'?
export type FloatType = 'Double';
export const FloatType = Symbol.for('FloatType');
export abstract class Float {
@ -37,7 +38,6 @@ export abstract class Float {
abstract get [FloatType](): FloatType;
static isFloat = (x: any): x is Float => x?.[FloatType] !== void 0;
static isSingle = (x: any): x is SingleFloat => x?.[FloatType] === 'Single';
static isDouble = (x: any): x is DoubleFloat => x?.[FloatType] === 'Double';
}
@ -58,76 +58,39 @@ export function floatlikeString(f: number): string {
return s + '.0';
}
export class SingleFloat extends Float implements Preservable<any>, PreserveWritable<any> {
__as_preserve__<T = GenericEmbedded>(): Value<T> {
return this;
}
static fromBytes(bs: Bytes | DataView): SingleFloat {
const view = dataview(bs);
const vf = view.getInt32(0, false);
if ((vf & 0x7f800000) === 0x7f800000) {
// NaN or inf. Preserve quiet/signalling bit by manually expanding to double-precision.
const sign = vf >> 31;
const payload = vf & 0x007fffff;
const dbs = new Bytes(8);
const dview = dataview(dbs);
dview.setInt16(0, (sign << 15) | 0x7ff0 | (payload >> 19), false);
dview.setInt32(2, (payload & 0x7ffff) << 13, false);
return new SingleFloat(dview.getFloat64(0, false));
} else {
return new SingleFloat(dataview(bs).getFloat32(0, false));
}
}
static __from_preserve__<T>(v: Value<T>): undefined | SingleFloat {
return Float.isSingle(v) ? v : void 0;
}
__w(v: DataView, offset: number) {
if (Number.isNaN(this.value)) {
const dbs = new Bytes(8);
const dview = dataview(dbs);
dview.setFloat64(0, this.value, false);
const sign = dview.getInt8(0) >> 7;
const payload = (dview.getInt32(1, false) >> 5) & 0x007fffff;
const vf = (sign << 31) | 0x7f800000 | payload;
v.setInt32(offset, vf, false);
} else {
v.setFloat32(offset, this.value, false);
}
}
__preserve_on__(encoder: Encoder<any>) {
encoder.state.emitbyte(Tag.Ieee754);
encoder.state.emitbyte(4);
encoder.state.makeroom(4);
this.__w(encoder.state.view, encoder.state.index);
encoder.state.index += 4;
}
toBytes(): Bytes {
const bs = new Bytes(4);
this.__w(bs.dataview(), 0);
return bs;
}
toString(): string {
if (Number.isFinite(this.value)) {
return floatlikeString(this.value) + 'f';
} else {
return '#xf"' + this.toBytes().toHex() + '"';
}
}
get [FloatType](): 'Single' {
return 'Single';
}
}
export function Single(value: number | Float): SingleFloat {
return new SingleFloat(value);
}
// -- These snippets are useful to keep in mind for promoting 4-byte, single-precision floats
// -- to 8-byte, double-precision floats *while preserving NaN bit-patterns*:
//
// static fromBytes(bs: Bytes | DataView): SingleFloat {
// const view = dataview(bs);
// const vf = view.getInt32(0, false);
// if ((vf & 0x7f800000) === 0x7f800000) {
// // NaN or inf. Preserve quiet/signalling bit by manually expanding to double-precision.
// const sign = vf >> 31;
// const payload = vf & 0x007fffff;
// const dbs = new Bytes(8);
// const dview = dataview(dbs);
// dview.setInt16(0, (sign << 15) | 0x7ff0 | (payload >> 19), false);
// dview.setInt32(2, (payload & 0x7ffff) << 13, false);
// return new SingleFloat(dview.getFloat64(0, false));
// } else {
// return new SingleFloat(dataview(bs).getFloat32(0, false));
// }
// }
//
// __w(v: DataView, offset: number) {
// if (Number.isNaN(this.value)) {
// const dbs = new Bytes(8);
// const dview = dataview(dbs);
// dview.setFloat64(0, this.value, false);
// const sign = dview.getInt8(0) >> 7;
// const payload = (dview.getInt32(1, false) >> 5) & 0x007fffff;
// const vf = (sign << 31) | 0x7f800000 | payload;
// v.setInt32(offset, vf, false);
// } else {
// v.setFloat32(offset, this.value, false);
// }
// }
export class DoubleFloat extends Float implements Preservable<any>, PreserveWritable<any> {
__as_preserve__<T = GenericEmbedded>(): Value<T> {

View File

@ -3,12 +3,11 @@ import { Bytes } from "./bytes";
import { Value } from "./values";
import { Set, Dictionary } from "./dictionary";
import { annotate, Annotated } from "./annotated";
import { Double, Float, Single } from "./float";
import { Double, Float } from "./float";
import { Embedded } from "./embedded";
export enum ValueClass {
Boolean,
Float,
Double,
SignedInteger,
String,
@ -26,7 +25,6 @@ export type Fold<T, R = Value<T>> = (v: Value<T>) => R;
export interface FoldMethods<T, R> {
boolean(b: boolean): R;
single(f: number): R;
double(f: number): R;
integer(i: number | bigint): R;
string(s: string): R;
@ -45,7 +43,6 @@ export interface FoldMethods<T, R> {
export class VoidFold<T> implements FoldMethods<T, void> {
boolean(b: boolean): void {}
single(f: number): void {}
double(f: number): void {}
integer(i: number | bigint): void {}
string(s: string): void {}
@ -73,9 +70,6 @@ export abstract class ValueFold<T, R = T> implements FoldMethods<T, Value<R>> {
boolean(b: boolean): Value<R> {
return b;
}
single(f: number): Value<R> {
return Single(f);
}
double(f: number): Value<R> {
return Double(f);
}
@ -134,7 +128,7 @@ export function valueClass<T>(v: Value<T>): ValueClass {
return ValueClass.Boolean;
case 'number':
if (!Number.isInteger(v)) {
throw new Error("Non-integer number in Preserves valueClass; missing SingleFloat/DoubleFloat wrapper?");
throw new Error("Non-integer number in Preserves valueClass; missing Float wrapper?");
} else {
return ValueClass.SignedInteger;
}
@ -157,8 +151,6 @@ export function valueClass<T>(v: Value<T>): ValueClass {
return ValueClass.Annotated;
} else if (Bytes.isBytes(v)) {
return ValueClass.ByteString;
} else if (Float.isSingle(v)) {
return ValueClass.Float;
} else if (Float.isDouble(v)) {
return ValueClass.Double;
} else {
@ -202,8 +194,6 @@ export function fold<T, R>(v: Value<T>, o: FoldMethods<T, R>): R {
return o.annotated(v, walk);
} else if (Bytes.isBytes(v)) {
return o.bytes(v);
} else if (Float.isSingle(v)) {
return o.single(v.value);
} else if (Float.isDouble(v)) {
return o.double(v.value);
} else {

View File

@ -9,7 +9,7 @@ export function fromJS<T = GenericEmbedded>(x: any): Value<T> {
case 'number':
if (!Number.isInteger(x)) {
// We require that clients be explicit about integer vs. non-integer types.
throw new TypeError("Refusing to autoconvert non-integer number to Single or Double");
throw new TypeError("Refusing to autoconvert non-integer number to Double");
}
// FALL THROUGH
case 'bigint':

View File

@ -32,7 +32,6 @@ export function merge<T>(
}
return fold<T, Value<T>>(a, {
boolean: die,
single(_f: number) { return is(a, b) ? a : die(); },
double(_f: number) { return is(a, b) ? a : die(); },
integer: die,
string: die,

View File

@ -19,9 +19,7 @@ export function typeCode<V>(v: Value<V>): number {
case 'symbol':
return 6;
case 'object':
if (Float.isFloat(v)) {
return Float.isSingle(v) ? 1 : 2;
}
if (Float.isFloat(v)) return 2; // 1 was for single-precision floats
if (Bytes.isBytes(v)) return 5;
if (Array.isArray(v)) {
return ('label' in v) ? 7 : 8;
@ -55,7 +53,7 @@ export function compare<V>(
const vb = b as any;
return va < vb ? -1 : va > vb ? 1 : 0;
}
case 1:
// case 1: // was single-precision
case 2: {
const va = (a as Float).value;
const vb = (b as Float).value;

View File

@ -8,7 +8,7 @@ import { Bytes, unhexDigit } from './bytes';
import { Decoder, DecoderState, neverEmbeddedTypeDecode } from './decoder';
import { Record } from './record';
import { Annotated, newPosition, Position, updatePosition } from './annotated';
import { Double, DoubleFloat, FloatType, Single, SingleFloat } from './float';
import { Double, DoubleFloat, FloatType } from './float';
import { stringify } from './text';
import { embed, GenericEmbedded, EmbeddedTypeDecode } from './embedded';
@ -24,12 +24,10 @@ export interface ReaderOptions<T> extends ReaderStateOptions {
const MAX_SAFE_INTEGERn = BigInt(Number.MAX_SAFE_INTEGER);
const MIN_SAFE_INTEGERn = BigInt(Number.MIN_SAFE_INTEGER);
export const NUMBER_RE: RegExp = /^([-+]?\d+)(((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+))([fF]?))?$/;
export const NUMBER_RE: RegExp = /^([-+]?\d+)((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+))?$/;
// Groups:
// 1 - integer part and sign
// 2 - decimal part, exponent and Float marker
// 3 - decimal part and exponent
// 7 - Float marker
// 2 - decimal part and exponent
export class ReaderState {
buffer: string;
@ -131,20 +129,14 @@ export class ReaderState {
}
}
readHexFloat(precision: FloatType): SingleFloat | DoubleFloat {
readHexFloat(): DoubleFloat {
const pos = this.copyPos();
if (this.nextchar() !== '"') {
this.error("Missing open-double-quote in hex-encoded floating-point number", pos);
}
const bs = this.readHexBinary();
switch (precision) {
case 'Single':
if (bs.length !== 4) this.error("Incorrect number of bytes in hex-encoded Float", pos);
return SingleFloat.fromBytes(bs);
case 'Double':
if (bs.length !== 8) this.error("Incorrect number of bytes in hex-encoded Double", pos);
return DoubleFloat.fromBytes(bs);
}
if (bs.length !== 8) this.error("Incorrect number of bytes in hex-encoded Double", pos);
return DoubleFloat.fromBytes(bs);
}
readBase64Binary(): Bytes {
@ -180,10 +172,8 @@ export class ReaderState {
} else {
return Number(v);
}
} else if (m[7] === '') {
return Double(parseFloat(m[1] + m[3]));
} else {
return Single(parseFloat(m[1] + m[3]));
return Double(parseFloat(acc));
}
} else {
return Symbol.for(acc);
@ -360,8 +350,7 @@ export class Reader<T> {
case '"': return this.state.readLiteralBinary();
case 'x': switch (this.state.nextchar()) {
case '"': return this.state.readHexBinary();
case 'f': return this.state.readHexFloat('Single');
case 'd': return this.state.readHexFloat('Double');
case 'd': return this.state.readHexFloat();
default: this.state.error('Invalid #x syntax', startPos);
}
case '[': return this.state.readBase64Binary();

View File

@ -1,7 +1,7 @@
// Preserves Values.
import type { Bytes } from './bytes';
import type { DoubleFloat, SingleFloat } from './float';
import type { DoubleFloat } from './float';
import type { Annotated } from './annotated';
import type { Set, Dictionary } from './dictionary';
import type { Embedded, GenericEmbedded } from './embedded';
@ -13,7 +13,6 @@ export type Value<T = GenericEmbedded> =
| Annotated<T>;
export type Atom =
| boolean
| SingleFloat
| DoubleFloat
| number | bigint
| string

View File

@ -1,12 +1,6 @@
import { Single, Double, fromJS, Dictionary, IDENTITY_FOLD, fold, mapEmbeddeds, Value, embed, preserves } from '../src/index';
import { Double, fromJS, Dictionary, IDENTITY_FOLD, fold, mapEmbeddeds, Value, embed, preserves } from '../src/index';
import './test-utils';
describe('Single', () => {
it('should print reasonably', () => {
expect(Single(123.45).toString()).toEqual("123.45f");
});
});
describe('Double', () => {
it('should print reasonably', () => {
expect(Double(123.45).toString()).toEqual("123.45");
@ -21,7 +15,7 @@ describe('fold', () => {
new Dictionary([[[3, 4], fromJS([5, 6])],
['a', 1],
['b', true]]),
Single(3.4),
Double(3.4),
t,
]);
}

View File

@ -1,6 +1,6 @@
{
"name": "@preserves/schema-cli",
"version": "0.992.5",
"version": "0.993.0",
"description": "Command-line tools for Preserves Schema",
"homepage": "https://gitlab.com/preserves/preserves",
"license": "Apache-2.0",
@ -26,8 +26,8 @@
"@types/minimatch": "^3.0"
},
"dependencies": {
"@preserves/core": "^0.992.4",
"@preserves/schema": "^0.992.5",
"@preserves/core": "^0.993.0",
"@preserves/schema": "^0.993.0",
"chalk": "^4.1",
"chokidar": "^3.5",
"commander": "^7.2",

View File

@ -1,6 +1,6 @@
{
"name": "@preserves/schema",
"version": "0.992.5",
"version": "0.993.0",
"description": "Schema support for Preserves data serialization format",
"homepage": "https://gitlab.com/preserves/preserves",
"license": "Apache-2.0",
@ -20,12 +20,12 @@
"compile:watch": "yarn compile -w",
"rollup": "rollup -c",
"rollup:watch": "yarn rollup -w",
"copy-schema": "mkdir -p ./dist && cp -a ../../../../schema/*.prs ./dist",
"copy-schema": "mkdir -p ./dist && cp -a ../../../../schema/schema.prs ../../../../schema/host.prs ./dist",
"test": "jest",
"test:watch": "jest --watch",
"veryclean": "yarn run clean && rm -rf node_modules"
},
"dependencies": {
"@preserves/core": "^0.992.4"
"@preserves/core": "^0.993.0"
}
}

View File

@ -154,7 +154,6 @@ export function converterForSimple(
let valexp: Item = `${src}`;
switch (p.atomKind._variant) {
case 'Boolean': test = `typeof ${src} === 'boolean'`; break;
case 'Float': test = `_.Float.isSingle(${src})`; valexp = `${src}.value`; break;
case 'Double': test =`_.Float.isDouble(${src})`; valexp = `${src}.value`; break;
case 'SignedInteger': test = `typeof ${src} === 'number'`; break;
case 'String': test = `typeof ${src} === 'string'`; break;

View File

@ -37,7 +37,6 @@ export function simpleType(resolver: RefResolver, p: M.SimplePattern): FieldType
case 'atom':
switch (p.atomKind._variant) {
case 'Boolean': return Type.ref(`boolean`, null);
case 'Float': return Type.ref(`number`, null);
case 'Double': return Type.ref(`number`, null);
case 'SignedInteger': return Type.ref(`number`, null);
case 'String': return Type.ref(`string`, null);

View File

@ -40,7 +40,6 @@ function unconverterFor(ctx: FunctionContext, p: M.Pattern, src: string): Item {
return `${src}`;
case 'atom':
switch (p.atomKind._variant) {
case 'Float': return `_.Single(${src})`;
case 'Double': return `_.Double(${src})`;
default: return `${src}`;
}

View File

@ -5,7 +5,6 @@ import * as M from '../meta';
export function sourceCodeFor(v: Value<M.InputEmbedded>): Item {
return fold(v, {
boolean(b: boolean): Item { return b.toString(); },
single(f: number): Item { return f.toString(); },
double(f: number): Item { return f.toString(); },
integer(i: number): Item { return i.toString(); },
string(s: string): Item { return JSON.stringify(s); },

File diff suppressed because one or more lines are too long

View File

@ -285,7 +285,6 @@ export class SchemaInterpreter<V> {
case 'any': return input;
case 'atom': switch (p.atomKind._variant) {
case 'Boolean': return inputIf(typeof input === 'boolean');
case 'Float': return inputIf(Float.isFloat(input));
case 'Double': return inputIf(Float.isDouble(input));
case 'SignedInteger': return inputIf(typeof input === 'number' || typeof input === 'bigint');
case 'String': return inputIf(typeof input === 'string');

View File

@ -225,7 +225,6 @@ function parsePattern(name: symbol, body0: Array<Input>): Pattern {
switch (str) {
case 'any': return ks(M.SimplePattern.any());
case 'bool': return ks(M.SimplePattern.atom(M.AtomKind.Boolean()));
case 'float': return ks(M.SimplePattern.atom(M.AtomKind.Float()));
case 'double': return ks(M.SimplePattern.atom(M.AtomKind.Double()));
case 'int': return ks(M.SimplePattern.atom(M.AtomKind.SignedInteger()));
case 'string': return ks(M.SimplePattern.atom(M.AtomKind.String()));

View File

@ -7,7 +7,6 @@ The main package re-exports a subset of the exports of its constituent modules:
- From [preserves.values][]:
- [Annotated][preserves.values.Annotated]
- [Embedded][preserves.values.Embedded]
- [Float][preserves.values.Float]
- [ImmutableDict][preserves.values.ImmutableDict]
- [Record][preserves.values.Record]
- [Symbol][preserves.values.Symbol]
@ -56,7 +55,7 @@ Finally, it provides a few utility aliases for common tasks:
'''
from .values import Float, Symbol, Record, ImmutableDict, Embedded, preserve
from .values import Symbol, Record, ImmutableDict, Embedded, preserve
from .values import Annotated, is_annotated, strip_annotations, annotate

View File

@ -206,7 +206,6 @@ class Decoder(BinaryCodec):
return self.wrap(Embedded(self.decode_embedded(self.next())))
if tag == 0x87:
count = self.nextbyte()
if count == 4: return self.wrap(Float.from_bytes(self.nextbytes(4)))
if count == 8: return self.wrap(struct.unpack('>d', self.nextbytes(8))[0])
raise DecodeError('Invalid IEEE754 size')
if tag == 0xb0: return self.wrap(self.nextint(self.varint()))

View File

@ -33,12 +33,12 @@ import numbers
from enum import Enum
from functools import cmp_to_key
from .values import preserve, Float, Embedded, Record, Symbol, cmp_floats, _unwrap
from .values import preserve, Embedded, Record, Symbol, cmp_floats, _unwrap
from .compat import basestring_
class TypeNumber(Enum):
BOOL = 0
FLOAT = 1
# FLOAT = 1 # single-precision
DOUBLE = 2
SIGNED_INTEGER = 3
STRING = 4
@ -57,7 +57,6 @@ def type_number(v):
raise ValueError('type_number expects Preserves value; use preserve()')
if isinstance(v, bool): return TypeNumber.BOOL
if isinstance(v, Float): return TypeNumber.FLOAT
if isinstance(v, float): return TypeNumber.DOUBLE
if isinstance(v, numbers.Number): return TypeNumber.SIGNED_INTEGER
if isinstance(v, basestring_): return TypeNumber.STRING

View File

@ -1,5 +1,5 @@
´³schema·³version°³ definitions·³Axis´³orµµ±values´³rec´³lit³values„´³tupleµ„„„„µ± descendants´³rec´³lit³ descendants„´³tupleµ„„„„µ±at´³rec´³lit³at„´³tupleµ´³named³key³any„„„„„µ±label´³rec´³lit³label„´³tupleµ„„„„µ±keys´³rec´³lit³keys„´³tupleµ„„„„µ±length´³rec´³lit³length„´³tupleµ„„„„µ± annotations´³rec´³lit³ annotations„´³tupleµ„„„„µ±embedded´³rec´³lit³embedded„´³tupleµ„„„„µ±parse´³rec´³lit³parse„´³tupleµ´³named³module´³seqof´³atom³Symbol„„„´³named³name´³atom³Symbol„„„„„„µ±unparse´³rec´³lit³unparse„´³tupleµ´³named³module´³seqof´³atom³Symbol„„„´³named³name´³atom³Symbol„„„„„„„„³Step´³orµµ±Axis´³refµ„³Axis„„µ±Filter´³refµ„³Filter„„µ±Function´³refµ„³Function„„„„³Filter´³orµµ±nop´³rec´³lit³nop„´³tupleµ„„„„µ±compare´³rec´³lit³compare„´³tupleµ´³named³op´³refµ„³
Comparison„„´³named³literal³any„„„„„µ±regex´³rec´³lit³regex„´³tupleµ´³named³regex´³atom³String„„„„„„µ±test´³rec´³lit³test„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±real´³rec´³lit³real„´³tupleµ„„„„µ±int´³rec´³lit³int„´³tupleµ„„„„µ±kind´³rec´³lit³kind„´³tupleµ´³named³kind´³refµ„³ ValueKind„„„„„„„„³Function´³rec´³lit³count„´³tupleµ´³named³selector´³refµ„³Selector„„„„„³Selector´³seqof´³refµ„³Step„„³ Predicate´³orµµ±Selector´³refµ„³Selector„„µ±not´³rec´³lit³not„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±or´³rec´³lit³or„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„µ±and´³rec´³lit³and„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„„„³ ValueKind´³orµµ±Boolean´³lit³Boolean„„µ±Float´³lit³Float„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
Comparison„„´³named³literal³any„„„„„µ±regex´³rec´³lit³regex„´³tupleµ´³named³regex´³atom³String„„„„„„µ±test´³rec´³lit³test„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±real´³rec´³lit³real„´³tupleµ„„„„µ±int´³rec´³lit³int„´³tupleµ„„„„µ±kind´³rec´³lit³kind„´³tupleµ´³named³kind´³refµ„³ ValueKind„„„„„„„„³Function´³rec´³lit³count„´³tupleµ´³named³selector´³refµ„³Selector„„„„„³Selector´³seqof´³refµ„³Step„„³ Predicate´³orµµ±Selector´³refµ„³Selector„„µ±not´³rec´³lit³not„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±or´³rec´³lit³or„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„µ±and´³rec´³lit³and„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„„„³ ValueKind´³orµµ±Boolean´³lit³Boolean„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
ByteString´³lit³
ByteString„„µ±Symbol´³lit³Symbol„„µ±Record´³lit³Record„„µ±Sequence´³lit³Sequence„„µ±Set´³lit³Set„„µ±
Dictionary´³lit³

View File

@ -170,7 +170,6 @@ FILTER_RE2 = Symbol('=r')
FILTER_LABEL = Symbol('^')
FILTER_BOOL = Symbol('bool')
FILTER_FLOAT = Symbol('float')
FILTER_DOUBLE = Symbol('double')
FILTER_INT = Symbol('int')
FILTER_STRING = Symbol('string')
@ -226,7 +225,6 @@ def parse_step(tokens):
if t == TRANSFORM_REAL: return syntax.Step.Filter(syntax.Filter.real)
if t == TRANSFORM_INT: return syntax.Step.Filter(syntax.Filter.int)
if t == FILTER_BOOL: return kind_filter(syntax.ValueKind.Boolean())
if t == FILTER_FLOAT: return kind_filter(syntax.ValueKind.Float())
if t == FILTER_DOUBLE: return kind_filter(syntax.ValueKind.Double())
if t == FILTER_INT: return kind_filter(syntax.ValueKind.SignedInteger())
if t == FILTER_STRING: return kind_filter(syntax.ValueKind.String())
@ -448,8 +446,6 @@ def exec(self, v):
@extend(syntax.Filter.real)
def exec(self, v):
v = preserve(_unwrap(v))
if isinstance(v, Float):
return (v.value,)
if type(v) == float:
return (v,)
if type(v) == int:
@ -459,8 +455,6 @@ def exec(self, v):
@extend(syntax.Filter.int)
def exec(self, v):
v = preserve(_unwrap(v))
if isinstance(v, Float):
return (int(v.value()),)
if type(v) == float:
return (int(v),)
if type(v) == int:
@ -476,10 +470,6 @@ def exec(self, v):
def exec(self, v):
return (v,) if type(v) == bool else ()
@extend(syntax.ValueKind.Float)
def exec(self, v):
return (v,) if isinstance(v, Float) else ()
@extend(syntax.ValueKind.Double)
def exec(self, v):
return (v,) if type(v) == float else ()

View File

@ -1,6 +1,6 @@
´³schema·³version°³ definitions·³Ref´³rec´³lit³ref„´³tupleµ´³named³module´³refµ„³
ModulePath„„´³named³name´³atom³Symbol„„„„„³Bundle´³rec´³lit³bundle„´³tupleµ´³named³modules´³refµ„³Modules„„„„„³Schema´³rec´³lit³schema„´³tupleµ´³dict·³version´³named³version´³refµ„³Version„„³ definitions´³named³ definitions´³refµ„³ Definitions„„³ embeddedType´³named³ embeddedType´³refµ„³EmbeddedTypeName„„„„„„„³Binding´³rec´³lit³named„´³tupleµ´³named³name´³atom³Symbol„„´³named³pattern´³refµ„³ SimplePattern„„„„„³Modules´³dictof´³refµ„³
ModulePath„´³refµ„³Schema„„³Pattern´³orµµ± SimplePattern´³refµ„³ SimplePattern„„µ±CompoundPattern´³refµ„³CompoundPattern„„„„³Version´³lit°„³AtomKind´³orµµ±Boolean´³lit³Boolean„„µ±Float´³lit³Float„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
ModulePath„´³refµ„³Schema„„³Pattern´³orµµ± SimplePattern´³refµ„³ SimplePattern„„µ±CompoundPattern´³refµ„³CompoundPattern„„„„³Version´³lit°„³AtomKind´³orµµ±Boolean´³lit³Boolean„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
ByteString´³lit³
ByteString„„µ±Symbol´³lit³Symbol„„„„³
Definition´³orµµ±or´³rec´³lit³or„´³tupleµ´³ tuplePrefixµ´³named³pattern0´³refµ„³NamedAlternative„„´³named³pattern1´³refµ„³NamedAlternative„„„´³named³patternN´³seqof´³refµ„³NamedAlternative„„„„„„„„µ±and´³rec´³lit³and„´³tupleµ´³ tuplePrefixµ´³named³pattern0´³refµ„³ NamedPattern„„´³named³pattern1´³refµ„³ NamedPattern„„„´³named³patternN´³seqof´³refµ„³ NamedPattern„„„„„„„„µ±Pattern´³refµ„³Pattern„„„„³

View File

@ -279,7 +279,6 @@ DICT = Symbol('dict')
DICTOF = Symbol('dictof')
DOUBLE = Symbol('Double')
EMBEDDED = Symbol('embedded')
FLOAT = Symbol('Float')
LIT = Symbol('lit')
NAMED = Symbol('named')
OR = Symbol('or')
@ -469,7 +468,6 @@ class SchemaObject:
if p.key == ATOM:
k = p[0]
if k == BOOLEAN and isinstance(v, bool): return v
if k == FLOAT and isinstance(v, Float): return v
if k == DOUBLE and isinstance(v, float): return v
if k == SIGNED_INTEGER and isinstance(v, int): return v
if k == STRING and isinstance(v, str): return v

View File

@ -28,7 +28,7 @@ from .binary import Decoder
class TextCodec(object):
pass
NUMBER_RE = re.compile(r'^([-+]?\d+)(((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+))([fF]?))?$')
NUMBER_RE = re.compile(r'^([-+]?\d+)((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+))?$')
class Parser(TextCodec):
"""Parser for the human-readable Preserves text syntax.
@ -251,15 +251,13 @@ class Parser(TextCodec):
if c == '=': continue
acc.append(c)
def read_hex_float(self, bytecount):
def read_hex_float(self):
if self.nextchar() != '"':
raise DecodeError('Missing open-double-quote in hex-encoded floating-point number')
bs = self.read_hex_binary()
if len(bs) != bytecount:
if len(bs) != 8:
raise DecodeError('Incorrect number of bytes in hex-encoded floating-point number')
if bytecount == 4: return Float.from_bytes(bs)
if bytecount == 8: return struct.unpack('>d', bs)[0]
raise DecodeError('Unsupported byte count in hex-encoded floating-point number')
return struct.unpack('>d', bs)[0]
def upto(self, delimiter, skip_commas):
vs = []
@ -308,10 +306,8 @@ class Parser(TextCodec):
if m:
if m[2] is None:
return int(m[1])
elif m[7] == '':
return float(m[1] + m[3])
else:
return Float(float(m[1] + m[3]))
return float(acc)
else:
return Symbol(acc)
@ -357,8 +353,7 @@ class Parser(TextCodec):
if c == 'x':
c = self.nextchar()
if c == '"': return self.wrap(self.read_hex_binary())
if c == 'f': return self.wrap(self.read_hex_float(4))
if c == 'd': return self.wrap(self.read_hex_float(8))
if c == 'd': return self.wrap(self.read_hex_float())
raise DecodeError('Invalid #x syntax')
if c == '[': return self.wrap(self.read_base64_binary())
if c == '!':

View File

@ -39,135 +39,6 @@ def cmp_floats(a, b):
if b & 0x8000000000000000: b = b ^ 0x7fffffffffffffff
return a - b
class Float(object):
"""Wrapper for treating a Python double-precision floating-point value as a
single-precision (32-bit) float, from Preserves' perspective. (Python lacks native
single-precision floating point support.)
```python
>>> Float(3.45)
Float(3.45)
>>> import preserves
>>> preserves.stringify(Float(3.45))
'3.45f'
>>> preserves.stringify(3.45)
'3.45'
>>> preserves.parse('3.45f')
Float(3.45)
>>> preserves.parse('3.45')
3.45
>>> preserves.encode(Float(3.45))
b'\\x87\\x04@\\\\\\xcc\\xcd'
>>> preserves.encode(3.45)
b'\\x87\\x08@\\x0b\\x99\\x99\\x99\\x99\\x99\\x9a'
```
Attributes:
value (float): the double-precision representation of intended single-precision value
"""
def __init__(self, value):
self.value = value
def __eq__(self, other):
other = _unwrap(other)
if other.__class__ is self.__class__:
return cmp_floats(self.value, other.value) == 0
def __lt__(self, other):
other = _unwrap(other)
if other.__class__ is self.__class__:
return cmp_floats(self.value, other.value) < 0
def __ne__(self, other):
return not self.__eq__(other)
def __hash__(self):
return hash(self.value)
def __repr__(self):
return 'Float(' + repr(self.value) + ')'
def to_bytes(self):
"""Converts this 32-bit single-precision floating point value to its binary32 format,
taking care to preserve the quiet/signalling bit-pattern of NaN values, unlike its
`struct.pack('>f', ...)` equivalent.
```python
>>> Float.from_bytes(b'\\x7f\\x80\\x00{')
Float(nan)
>>> Float.from_bytes(b'\\x7f\\x80\\x00{').to_bytes()
b'\\x7f\\x80\\x00{'
>>> struct.unpack('>f', b'\\x7f\\x80\\x00{')[0]
nan
>>> Float(struct.unpack('>f', b'\\x7f\\x80\\x00{')[0]).to_bytes()
b'\\x7f\\xc0\\x00{'
>>> struct.pack('>f', struct.unpack('>f', b'\\x7f\\x80\\x00{')[0])
b'\\x7f\\xc0\\x00{'
```
(Note well the difference between `7f80007b` and `7fc0007b`!)
"""
if math.isnan(self.value) or math.isinf(self.value):
dbs = struct.pack('>d', self.value)
vd = struct.unpack('>Q', dbs)[0]
sign = vd >> 63
payload = (vd >> 29) & 0x007fffff
vf = (sign << 31) | 0x7f800000 | payload
return struct.pack('>I', vf)
else:
return struct.pack('>f', self.value)
def __preserve_write_binary__(self, encoder):
encoder.buffer.append(0x87)
encoder.buffer.append(4)
encoder.buffer.extend(self.to_bytes())
def __preserve_write_text__(self, formatter):
if math.isnan(self.value) or math.isinf(self.value):
formatter.chunks.append('#xf"' + self.to_bytes().hex() + '"')
else:
formatter.chunks.append(repr(self.value) + 'f')
@staticmethod
def from_bytes(bs):
"""Converts a 4-byte-long byte string to a 32-bit single-precision floating point value
wrapped in a [Float][preserves.values.Float] instance. Takes care to preserve the
quiet/signalling bit-pattern of NaN values, unlike its `struct.unpack('>f', ...)`
equivalent.
```python
>>> Float.from_bytes(b'\\x7f\\x80\\x00{')
Float(nan)
>>> Float.from_bytes(b'\\x7f\\x80\\x00{').to_bytes()
b'\\x7f\\x80\\x00{'
>>> struct.unpack('>f', b'\\x7f\\x80\\x00{')[0]
nan
>>> Float(struct.unpack('>f', b'\\x7f\\x80\\x00{')[0]).to_bytes()
b'\\x7f\\xc0\\x00{'
>>> struct.pack('>f', struct.unpack('>f', b'\\x7f\\x80\\x00{')[0])
b'\\x7f\\xc0\\x00{'
```
(Note well the difference between `7f80007b` and `7fc0007b`!)
"""
vf = struct.unpack('>I', bs)[0]
if (vf & 0x7f800000) == 0x7f800000:
# NaN or inf. Preserve quiet/signalling bit by manually expanding to double-precision.
sign = vf >> 31
payload = vf & 0x007fffff
dbs = struct.pack('>Q', (sign << 63) | 0x7ff0000000000000 | (payload << 29))
return Float(struct.unpack('>d', dbs)[0])
else:
return Float(struct.unpack('>f', bs)[0])
# FIXME: This regular expression is conservatively correct, but Anglo-chauvinistic.
RAW_SYMBOL_RE = re.compile(r'^[-a-zA-Z0-9~!$%^&*?_=+/.]+$')

View File

@ -1,6 +1,6 @@
[project]
name = "preserves"
version = "0.992.2"
version = "0.993.0"
description = "Data serialization format"
readme = "README.md"
requires-python = ">=3.6, <4"

View File

@ -0,0 +1,73 @@
The code below deals with expansion of single-precision IEEE 754 floating point values to
double-precision (and vice-versa) without losing detail of NaN bit-patterns.
```python
def to_bytes(self):
"""Converts this 32-bit single-precision floating point value to its binary32 format,
taking care to preserve the quiet/signalling bit-pattern of NaN values, unlike its
`struct.pack('>f', ...)` equivalent.
```python
>>> Float.from_bytes(b'\\x7f\\x80\\x00{')
Float(nan)
>>> Float.from_bytes(b'\\x7f\\x80\\x00{').to_bytes()
b'\\x7f\\x80\\x00{'
>>> struct.unpack('>f', b'\\x7f\\x80\\x00{')[0]
nan
>>> Float(struct.unpack('>f', b'\\x7f\\x80\\x00{')[0]).to_bytes()
b'\\x7f\\xc0\\x00{'
>>> struct.pack('>f', struct.unpack('>f', b'\\x7f\\x80\\x00{')[0])
b'\\x7f\\xc0\\x00{'
```
(Note well the difference between `7f80007b` and `7fc0007b`!)
"""
if math.isnan(self.value) or math.isinf(self.value):
dbs = struct.pack('>d', self.value)
vd = struct.unpack('>Q', dbs)[0]
sign = vd >> 63
payload = (vd >> 29) & 0x007fffff
vf = (sign << 31) | 0x7f800000 | payload
return struct.pack('>I', vf)
else:
return struct.pack('>f', self.value)
@staticmethod
def from_bytes(bs):
"""Converts a 4-byte-long byte string to a 32-bit single-precision floating point value
wrapped in a [Float][preserves.values.Float] instance. Takes care to preserve the
quiet/signalling bit-pattern of NaN values, unlike its `struct.unpack('>f', ...)`
equivalent.
```python
>>> Float.from_bytes(b'\\x7f\\x80\\x00{')
Float(nan)
>>> Float.from_bytes(b'\\x7f\\x80\\x00{').to_bytes()
b'\\x7f\\x80\\x00{'
>>> struct.unpack('>f', b'\\x7f\\x80\\x00{')[0]
nan
>>> Float(struct.unpack('>f', b'\\x7f\\x80\\x00{')[0]).to_bytes()
b'\\x7f\\xc0\\x00{'
>>> struct.pack('>f', struct.unpack('>f', b'\\x7f\\x80\\x00{')[0])
b'\\x7f\\xc0\\x00{'
```
(Note well the difference between `7f80007b` and `7fc0007b`!)
"""
vf = struct.unpack('>I', bs)[0]
if (vf & 0x7f800000) == 0x7f800000:
# NaN or inf. Preserve quiet/signalling bit by manually expanding to double-precision.
sign = vf >> 31
payload = vf & 0x007fffff
dbs = struct.pack('>Q', (sign << 63) | 0x7ff0000000000000 | (payload << 29))
return Float(struct.unpack('>d', dbs)[0])
else:
return Float(struct.unpack('>f', bs)[0])
```

View File

@ -119,32 +119,6 @@
double15: @"-sNaN" <Test #x"8708fff8000000000111" #xd"fff8000000000111">
double16: @"+sNaN" <Test #x"87087ff8000000000001" #xd"7ff8000000000001">
double17: @"+sNaN" <Test #x"87087ff8000000000111" #xd"7ff8000000000111">
float0: <Test #x"870400000000" 0.0f>
float+0: <Test #x"870400000000" +0.0f>
float-0: <Test #x"870480000000" -0.0f>
float1: <Test #x"87043f800000" 1.0f>
float1u: <Test #x"87043f800000" 1.0F>
float1a: <Test #x"87043f800000" 1e0f>
float1b: <Test #x"87043f800000" 1.0e0f>
float1c: <Test #x"87043f800000" 1e-0f>
float1d: <Test #x"87043f800000" 1.0e-0f>
float1e: <Test #x"87043f800000" 1e+0f>
float1f: <Test #x"87043f800000" 1.0e+0f>
float2: <Test #x"870412345678" #xf"12 34 56 78">
float3: @"Fewer than 8 digits" <ParseError "#xf\"123456\"">
float4: @"More than 8 digits" <ParseError "#xf\"123456789a\"">
float5: @"Invalid chars" <ParseError "#xf\"12zz5678\"">
float6: @"Positive infinity" <Test #x"87047f800000" #xf"7f800000">
float7: @"Negative infinity" <Test #x"8704ff800000" #xf"ff800000">
float8: @"+sNaN" <Test #x"87047f800001" #xf"7f800001">
float9: @"+sNaN" <Test #x"87047f800111" #xf"7f800111">
float10: @"-sNaN" <Test #x"8704ff800001" #xf"ff800001">
float11: @"-sNaN" <Test #x"8704ff800111" #xf"ff800111">
float12: @"Bad spacing" <ParseError "#xf\"12345 678\"">
float13: @"+qNaN" <Test #x"87047fc00001" #xf"7fc00001">
float14: @"+qNaN" <Test #x"87047fc00111" #xf"7fc00111">
float15: @"-qNaN" <Test #x"8704ffc00001" #xf"ffc00001">
float16: @"-qNaN" <Test #x"8704ffc00111" #xf"ffc00111">
int-98765432109876543210987654321098765432109: <Test #x"b012feddc125aed4226c770369269596ce3f0ad3" -98765432109876543210987654321098765432109>
int-12345678123456781234567812345678: <Test #x"b00eff642cf6684f11d1dad08c4a10b2" -12345678123456781234567812345678>
int-1234567812345678123456781234567: <Test #x"b00df06ae570d4b4fb62ae746dce79" -1234567812345678123456781234567>

View File

@ -135,7 +135,6 @@ class BinaryCodecTests(PreservesTestCase):
self._roundtrip(131072, _buf(0xb0, 0x03, 0x02, 0x00, 0x00))
def test_floats(self):
self._roundtrip(Float(1.0), _buf(0x87, 0x04, 0x3f, 0x80, 0, 0))
self._roundtrip(1.0, _buf(0x87, 0x08, 0x3f, 0xf0, 0, 0, 0, 0, 0, 0))
self._roundtrip(-1.202e300, _buf(0x87, 0x08, 0xfe, 0x3c, 0xb7, 0xb7, 0x59, 0xbf, 0x04, 0x26))

View File

@ -14,7 +14,6 @@
(define :encode-embedded values)
(define (AtomKind? p)
(or (AtomKind-Boolean? p)
(AtomKind-Float? p)
(AtomKind-Double? p)
(AtomKind-SignedInteger? p)
(AtomKind-String? p)
@ -29,15 +28,6 @@
((define/generic *->preserve ->preserve)
(define (->preserve preservable)
(match preservable ((AtomKind-Boolean) 'Boolean)))))
(struct
AtomKind-Float
()
#:transparent
#:methods
gen:preservable
((define/generic *->preserve ->preserve)
(define (->preserve preservable)
(match preservable ((AtomKind-Float) 'Float)))))
(struct
AtomKind-Double
()
@ -87,7 +77,6 @@
(match
input
((and dest 'Boolean) (AtomKind-Boolean))
((and dest 'Float) (AtomKind-Float))
((and dest 'Double) (AtomKind-Double))
((and dest 'SignedInteger) (AtomKind-SignedInteger))
((and dest 'String) (AtomKind-String))

View File

@ -27,8 +27,7 @@
(define (->preserve preservable)
(for/hash [((k v) (in-hash preservable))]
(values (*->preserve k) (*->preserve v))))])
#:defaults ([float? (define (->preserve preservable) preservable)]
[embedded? (define (->preserve preservable) preservable)]
#:defaults ([embedded? (define (->preserve preservable) preservable)]
[record?
(define/generic *->preserve ->preserve)
(define (->preserve preservable)

View File

@ -26,7 +26,6 @@
(maybe-dest dest-pat-stx
`(? ,(match atom-kind
[(AtomKind-Boolean) 'boolean?]
[(AtomKind-Float) 'float?]
[(AtomKind-Double) 'flonum?]
[(AtomKind-SignedInteger) 'exact-integer?]
[(AtomKind-String) 'string?]

View File

@ -131,7 +131,6 @@
(match (peel-annotations item)
['any (ks (SimplePattern-any))]
['bool (ks (SimplePattern-atom (AtomKind-Boolean)))]
['float (ks (SimplePattern-atom (AtomKind-Float)))]
['double (ks (SimplePattern-atom (AtomKind-Double)))]
['int (ks (SimplePattern-atom (AtomKind-SignedInteger)))]
['string (ks (SimplePattern-atom (AtomKind-String)))]

View File

@ -38,7 +38,7 @@ SimplePattern =
# any
/ =any
# special builtins: bool, float, double, int, string, bytes, symbol
# special builtins: bool, double, int, string, bytes, symbol
/ <atom @atomKind AtomKind>
# matches an embedded value in the input: #!p
@ -79,7 +79,7 @@ CompoundPattern =
DictionaryEntries = { any: NamedSimplePattern ...:... }.
AtomKind = =Boolean / =Float / =Double / =SignedInteger / =String / =ByteString / =Symbol .
AtomKind = =Boolean / =Double / =SignedInteger / =String / =ByteString / =Symbol .
NamedAlternative = [@variantLabel string @pattern Pattern].

View File

@ -14,7 +14,6 @@
(match (unwrap pattern)
[(Binding n p) (pattern->unparser p (escape n))]
[(SimplePattern-any) `(*->preserve ,src-stx)]
[(SimplePattern-atom (AtomKind-Float)) `(->float (*->preserve ,src-stx))]
[(SimplePattern-atom (AtomKind-Double)) `(exact->inexact (*->preserve ,src-stx))]
[(SimplePattern-atom _) `(*->preserve ,src-stx)]
[(SimplePattern-embedded _interface) `(embedded ,src-stx)]

View File

@ -9,7 +9,6 @@
bytes->double
double->bytes)
(require "float.rkt")
(require (only-in racket/math nan? infinite?))
(module binary racket/base
@ -37,21 +36,20 @@
#x0070000000000000
(arithmetic-shift payload 29)))
(dbs (integer->integer-bytes vd 8 #f #t)))
(float (floating-point-bytes->real dbs #t 0 8)))
(float (floating-point-bytes->real bs #t 0 4))))
(floating-point-bytes->real dbs #t 0 8))
(floating-point-bytes->real bs #t 0 4)))
(define (float->bytes v)
(let ((v (float-value v)))
(if (or (nan? v) (infinite? v))
(let* ((dbs (real->floating-point-bytes v 8 #t))
(vd (integer-bytes->integer dbs #f #t))
(signexp (bitwise-bit-field vd 55 64))
(payload (bitwise-bit-field vd 29 52))
(vf (bitwise-ior (arithmetic-shift signexp 23)
payload))
(bs (integer->integer-bytes vf 4 #f #t)))
bs)
(real->floating-point-bytes v 4 #t))))
(if (or (nan? v) (infinite? v))
(let* ((dbs (real->floating-point-bytes v 8 #t))
(vd (integer-bytes->integer dbs #f #t))
(signexp (bitwise-bit-field vd 55 64))
(payload (bitwise-bit-field vd 29 52))
(vf (bitwise-ior (arithmetic-shift signexp 23)
payload))
(bs (integer->integer-bytes vf 4 #f #t)))
bs)
(real->floating-point-bytes v 4 #t)))
(define (bytes->double bs)
(floating-point-bytes->real bs #t 0 8))

View File

@ -1,14 +0,0 @@
#lang racket/base
;; Wrapper struct to mark a need for 32-bit IEEE floating-point
;; precision (de)serialization. In many circumstances, Racket lacks
;; 32-bit floating point support, and single-flonum? always yields #f.
(provide (struct-out float)
->float)
(struct float (value) #:transparent)
(define (->float v)
(if (float? v)
v
(float (exact->inexact v))))

View File

@ -8,7 +8,7 @@
;;---------------------------------------------------------------------------
;; Representing values
(require "float.rkt" "float-bytes.rkt")
(require "float-bytes.rkt")
(struct record (label fields) #:transparent)
(struct annotated (annotation item) #:transparent)
(struct embedded (value) #:transparent)
@ -26,9 +26,7 @@
[#x84 '#:end]
[#x85 (let ((a (next))) (annotated a (next)))]
[#x86 (embedded (next))]
[#x87 (match (next-byte)
[4 (bytes->float (next-bytes 4))]
[8 (bytes->double (next-bytes 8))])]
[#x87 (match (next-byte) [8 (bytes->double (next-bytes 8))])]
[#xB0 (next-integer (next-varint))]
[#xB1 (bytes->string/utf-8 (next-bytes (next-varint)))]
[#xB2 (next-bytes (next-varint))]
@ -74,7 +72,6 @@
(match v
[#f (write-byte #x80 out-port)]
[#t (write-byte #x81 out-port)]
[(float _) (write-byte #x87 out-port) (write-byte 4 out-port) (output-bytes (float->bytes v))]
[(? flonum?) (write-byte #x87 out-port) (write-byte 8 out-port) (output-bytes (double->bytes v))]
[(annotated a v) (write-byte #x85 out-port) (output a) (output v)]

View File

@ -2,7 +2,6 @@
;; Preserve, as in Fruit Preserve, as in a remarkably weak pun on pickling/dehydration etc
(provide (all-from-out "record.rkt")
(all-from-out "float.rkt")
(all-from-out "annotation.rkt")
(all-from-out "order.rkt")
(all-from-out "embedded.rkt")
@ -31,7 +30,6 @@
(require (only-in racket/port port->list))
(require "record.rkt")
(require "float.rkt")
(require "annotation.rkt")
(require "order.rkt")
(require "embedded.rkt")

View File

@ -12,7 +12,6 @@
(require (for-syntax racket/base))
(require "record.rkt")
(require "annotation.rkt")
(require "float.rkt")
(require racket/set)
(require racket/dict)
(require data/order)
@ -24,7 +23,7 @@
(define (typecode v)
(match v
[(? boolean?) 0]
[(or (? float?) (? single-flonum?)) 1]
;; [(or (? float?) (? single-flonum?)) 1]
[(? double-flonum?) 2]
[(? integer? x) 3]
[(? string?) 4]

View File

@ -6,7 +6,6 @@
(require racket/match)
(require "record.rkt")
(require "embedded.rkt")
(require "float.rkt")
(require "float-bytes.rkt")
(require "annotation.rkt")
(require "varint.rkt")
@ -76,7 +75,6 @@
(next)))]
[#x86 (embedded (decode-embedded (next)))]
[#x87 (match (next-varint)
[4 (bytes->float (next-bytes 4))]
[8 (bytes->double (next-bytes 8))]
[n (return (on-fail "Invalid Preserves IEEE754 size: ~v" n))])]
[#xB0 (next-integer (next-varint))]

View File

@ -12,7 +12,6 @@
(require racket/match)
(require "embedded.rkt")
(require "annotation.rkt")
(require "float.rkt")
(require "float-bytes.rkt")
(require syntax/readerr)
(require (only-in file/sha1 hex-string->bytes))
@ -112,8 +111,7 @@
[#\" (read-literal-binary)]
[#\x (match (next-char*)
[#\" (read-hex-binary '())]
[#\f (read-hex-float 'float)]
[#\d (read-hex-float 'double)]
[#\d (read-hex-float)]
[c (parse-error* "Invalid #x syntax: ~v" c)])]
[#\[ (read-base64-binary '())]
[#\! (embedded (decode-embedded (next)))]
@ -242,15 +240,13 @@
;;---------------------------------------------------------------------------
;; Hex-encoded floating point numbers
(define (read-hex-float precision)
(define (read-hex-float)
(unless (eqv? (next-char*) #\")
(parse-error* "Missing open-double-quote in hex-encoded floating-point number"))
(define bs (read-hex-binary '()))
(unless (= (bytes-length bs) (match precision ['float 4] ['double 8]))
(unless (= (bytes-length bs) 8)
(parse-error* "Incorrect number of bytes in hex-encoded floating-point number"))
(match precision
['float (bytes->float bs)]
['double (bytes->double bs)]))
(bytes->double bs))
;;---------------------------------------------------------------------------
;; Base64-encoded ByteStrings
@ -296,12 +292,8 @@
(define (analyze-number input)
(match input
[(pregexp #px"^([-+]?\\d+)(((\\.\\d+([eE][-+]?\\d+)?)|([eE][-+]?\\d+))([fF]?))?$"
(list _ whole _ frac _ _ _ f))
(define n (string->number (if frac (string-append whole frac) whole)))
(cond [(not n) #f]
[(and f (positive? (string-length f))) (float n)]
[else n])]
[(pregexp #px"^([-+]?\\d+)((\\.\\d+([eE][-+]?\\d+)?)|([eE][-+]?\\d+))?$" (? list?))
(string->number input)]
[_ #f]))
;;---------------------------------------------------------------------------

View File

@ -119,32 +119,6 @@
double15: @"-sNaN" <Test #x"8708fff8000000000111" #xd"fff8000000000111">
double16: @"+sNaN" <Test #x"87087ff8000000000001" #xd"7ff8000000000001">
double17: @"+sNaN" <Test #x"87087ff8000000000111" #xd"7ff8000000000111">
float0: <Test #x"870400000000" 0.0f>
float+0: <Test #x"870400000000" +0.0f>
float-0: <Test #x"870480000000" -0.0f>
float1: <Test #x"87043f800000" 1.0f>
float1u: <Test #x"87043f800000" 1.0F>
float1a: <Test #x"87043f800000" 1e0f>
float1b: <Test #x"87043f800000" 1.0e0f>
float1c: <Test #x"87043f800000" 1e-0f>
float1d: <Test #x"87043f800000" 1.0e-0f>
float1e: <Test #x"87043f800000" 1e+0f>
float1f: <Test #x"87043f800000" 1.0e+0f>
float2: <Test #x"870412345678" #xf"12 34 56 78">
float3: @"Fewer than 8 digits" <ParseError "#xf\"123456\"">
float4: @"More than 8 digits" <ParseError "#xf\"123456789a\"">
float5: @"Invalid chars" <ParseError "#xf\"12zz5678\"">
float6: @"Positive infinity" <Test #x"87047f800000" #xf"7f800000">
float7: @"Negative infinity" <Test #x"8704ff800000" #xf"ff800000">
float8: @"+sNaN" <Test #x"87047f800001" #xf"7f800001">
float9: @"+sNaN" <Test #x"87047f800111" #xf"7f800111">
float10: @"-sNaN" <Test #x"8704ff800001" #xf"ff800001">
float11: @"-sNaN" <Test #x"8704ff800111" #xf"ff800111">
float12: @"Bad spacing" <ParseError "#xf\"12345 678\"">
float13: @"+qNaN" <Test #x"87047fc00001" #xf"7fc00001">
float14: @"+qNaN" <Test #x"87047fc00111" #xf"7fc00111">
float15: @"-qNaN" <Test #x"8704ffc00001" #xf"ffc00001">
float16: @"-qNaN" <Test #x"8704ffc00111" #xf"ffc00111">
int-98765432109876543210987654321098765432109: <Test #x"b012feddc125aed4226c770369269596ce3f0ad3" -98765432109876543210987654321098765432109>
int-12345678123456781234567812345678: <Test #x"b00eff642cf6684f11d1dad08c4a10b2" -12345678123456781234567812345678>
int-1234567812345678123456781234567: <Test #x"b00df06ae570d4b4fb62ae746dce79" -1234567812345678123456781234567>

View File

@ -7,7 +7,6 @@
(require (only-in racket/port call-with-output-bytes))
(require "record.rkt")
(require "embedded.rkt")
(require "float.rkt")
(require "float-bytes.rkt")
(require "annotation.rkt")
(require "varint.rkt")
@ -87,10 +86,6 @@
[#f (output-byte #x80)]
[#t (output-byte #x81)]
[(float _)
(output-byte #x87)
(output-byte 4)
(output-bytes (float->bytes v))]
[(? flonum?)
(output-byte #x87)
(output-byte 8)

View File

@ -11,7 +11,6 @@
(require net/base64)
(require "embedded.rkt")
(require "annotation.rkt")
(require "float.rkt")
(require "float-bytes.rkt")
(require "record.rkt")
(require "object-id.rkt")
@ -135,14 +134,10 @@
(write-binary-stringlike v)
(write-binary-base64 outer-distance v)))))
(define (write-float v precision)
(define (write-float v)
(if (or (nan? v) (infinite? v))
(! "#x~a\"~a\""
(match precision ['float "f"] ['double "d"])
(bytes->hex-string (match precision
['float (float->bytes (float v))]
['double (double->bytes v)])))
(! "~v~a" v (match precision ['float "f"] ['double ""]))))
(! "#xd\"~a\"" (bytes->hex-string (double->bytes v)))
(! "~v" v)))
(define (write-value distance v)
(match v
@ -155,8 +150,7 @@
(write-value distance item)]
[#f (! "#f")]
[#t (! "#t")]
[(float v) (write-float v 'float)]
[(? flonum?) (write-float v 'double)]
[(? flonum?) (write-float v)]
[(? integer? x) (! "~v" v)]
[(? string?)
(! "\"")

View File

@ -1,6 +1,6 @@
[package]
name = "preserves-path"
version = "5.992.0"
version = "5.993.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
description = "Implementation of preserves-path, a query language for Preserves documents."
@ -9,11 +9,11 @@ repository = "https://gitlab.com/preserves/preserves"
license = "Apache-2.0"
[build-dependencies]
preserves-schema = { path = "../preserves-schema", version = "5.992.0"}
preserves-schema = { path = "../preserves-schema", version = "5.993.0"}
[dependencies]
preserves = { path = "../preserves", version = "4.992.1"}
preserves-schema = { path = "../preserves-schema", version = "5.992.0"}
preserves = { path = "../preserves", version = "4.993.0"}
preserves-schema = { path = "../preserves-schema", version = "5.993.0"}
num = "0.4"
regex = "1.5"

View File

@ -1,5 +1,5 @@
´³schema·³version°³ definitions·³Axis´³orµµ±values´³rec´³lit³values„´³tupleµ„„„„µ± descendants´³rec´³lit³ descendants„´³tupleµ„„„„µ±at´³rec´³lit³at„´³tupleµ´³named³key³any„„„„„µ±label´³rec´³lit³label„´³tupleµ„„„„µ±keys´³rec´³lit³keys„´³tupleµ„„„„µ±length´³rec´³lit³length„´³tupleµ„„„„µ± annotations´³rec´³lit³ annotations„´³tupleµ„„„„µ±embedded´³rec´³lit³embedded„´³tupleµ„„„„µ±parse´³rec´³lit³parse„´³tupleµ´³named³module´³seqof´³atom³Symbol„„„´³named³name´³atom³Symbol„„„„„„µ±unparse´³rec´³lit³unparse„´³tupleµ´³named³module´³seqof´³atom³Symbol„„„´³named³name´³atom³Symbol„„„„„„„„³Step´³orµµ±Axis´³refµ„³Axis„„µ±Filter´³refµ„³Filter„„µ±Function´³refµ„³Function„„„„³Filter´³orµµ±nop´³rec´³lit³nop„´³tupleµ„„„„µ±compare´³rec´³lit³compare„´³tupleµ´³named³op´³refµ„³
Comparison„„´³named³literal³any„„„„„µ±regex´³rec´³lit³regex„´³tupleµ´³named³regex´³atom³String„„„„„„µ±test´³rec´³lit³test„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±real´³rec´³lit³real„´³tupleµ„„„„µ±int´³rec´³lit³int„´³tupleµ„„„„µ±kind´³rec´³lit³kind„´³tupleµ´³named³kind´³refµ„³ ValueKind„„„„„„„„³Function´³rec´³lit³count„´³tupleµ´³named³selector´³refµ„³Selector„„„„„³Selector´³seqof´³refµ„³Step„„³ Predicate´³orµµ±Selector´³refµ„³Selector„„µ±not´³rec´³lit³not„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±or´³rec´³lit³or„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„µ±and´³rec´³lit³and„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„„„³ ValueKind´³orµµ±Boolean´³lit³Boolean„„µ±Float´³lit³Float„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
Comparison„„´³named³literal³any„„„„„µ±regex´³rec´³lit³regex„´³tupleµ´³named³regex´³atom³String„„„„„„µ±test´³rec´³lit³test„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±real´³rec´³lit³real„´³tupleµ„„„„µ±int´³rec´³lit³int„´³tupleµ„„„„µ±kind´³rec´³lit³kind„´³tupleµ´³named³kind´³refµ„³ ValueKind„„„„„„„„³Function´³rec´³lit³count„´³tupleµ´³named³selector´³refµ„³Selector„„„„„³Selector´³seqof´³refµ„³Step„„³ Predicate´³orµµ±Selector´³refµ„³Selector„„µ±not´³rec´³lit³not„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±or´³rec´³lit³or„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„µ±and´³rec´³lit³and„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„„„³ ValueKind´³orµµ±Boolean´³lit³Boolean„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
ByteString´³lit³
ByteString„„µ±Symbol´³lit³Symbol„„µ±Record´³lit³Record„„µ±Sequence´³lit³Sequence„„µ±Set´³lit³Set„„µ±
Dictionary´³lit³

View File

@ -244,7 +244,6 @@ fn parse_step<'a>(
path::Step::from(path::ValueKind::Boolean),
remainder,
))),
"float" => Ok(Some((path::Step::from(path::ValueKind::Float), remainder))),
"double" => Ok(Some((path::Step::from(path::ValueKind::Double), remainder))),
"int" => Ok(Some((
path::Step::from(path::ValueKind::SignedInteger),

View File

@ -305,7 +305,6 @@ impl StepMaker for path::Filter {
path::Filter::Kind { kind } => Ok(Node::new(KindStep {
kind: match &**kind {
path::ValueKind::Boolean => ValueClass::Atomic(AtomClass::Boolean),
path::ValueKind::Float => ValueClass::Atomic(AtomClass::Float),
path::ValueKind::Double => ValueClass::Atomic(AtomClass::Double),
path::ValueKind::SignedInteger => ValueClass::Atomic(AtomClass::SignedInteger),
path::ValueKind::String => ValueClass::Atomic(AtomClass::String),
@ -373,7 +372,6 @@ impl Step for RealStep {
self.step.accept(ctxt, &IOValue::new(r))
}
}
Value::Float(f) => self.step.accept(ctxt, &IOValue::new(f32::from(*f) as f64)),
Value::Double(_) => self.step.accept(ctxt, value),
_ => (),
}
@ -386,11 +384,6 @@ impl Step for IntStep {
fn accept(&mut self, ctxt: &mut Context, value: &IOValue) {
match value.value() {
Value::SignedInteger(_) => self.step.accept(ctxt, value),
Value::Float(f) => {
if let Some(i) = BigInt::from_f32(f32::from(*f)) {
self.step.accept(ctxt, &IOValue::new(i))
}
}
Value::Double(d) => {
if let Some(i) = BigInt::from_f64(f64::from(*d)) {
self.step.accept(ctxt, &IOValue::new(i))

View File

@ -1,6 +1,6 @@
[package]
name = "preserves-schema-macros"
version = "0.992.1"
version = "0.993.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
description = "Implementation of Preserves Schema code generation macros for Rust."
@ -12,8 +12,8 @@ license = "Apache-2.0"
proc-macro = true
[dependencies]
preserves = { path = "../preserves", version = "4.992.1" }
preserves-schema = { path = "../preserves-schema", version = "5.992.0" }
preserves = { path = "../preserves", version = "4.993.0" }
preserves-schema = { path = "../preserves-schema", version = "5.993.0" }
proc-macro2 = { version = "1", features = ["span-locations"] }
quote = "1"

View File

@ -1,6 +1,6 @@
[package]
name = "preserves-schema"
version = "5.992.0"
version = "5.993.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
description = "Implementation of Preserves Schema code generation and support for Rust."
@ -9,7 +9,7 @@ repository = "https://gitlab.com/preserves/preserves"
license = "Apache-2.0"
[dependencies]
preserves = { path = "../preserves", version = "4.992.1"}
preserves = { path = "../preserves", version = "4.993.0"}
convert_case = "0.4.0"
glob = "0.3.0"

View File

@ -202,7 +202,6 @@ fn simple_pattern_parser(
SimplePattern::Atom { atom_kind: k } => {
let converter = match &**k {
AtomKind::Boolean => "to_boolean",
AtomKind::Float => "to_float",
AtomKind::Double => "to_double",
AtomKind::SignedInteger => "to_signedinteger",
AtomKind::String => "to_string",

View File

@ -364,7 +364,6 @@ fn read_expected_literals_cases(
true => " if *w".to_owned(),
false => " if !*w".to_owned(),
},
AtomClass::Float |
AtomClass::Double =>
format!(" if w.0 == {:?}", p.0),
AtomClass::SignedInteger =>
@ -441,7 +440,6 @@ fn simple_pattern_reader(
SimplePattern::Atom { atom_kind: k } => {
let reader = match &**k {
AtomKind::Boolean => "r.next_boolean()?",
AtomKind::Float => "r.next_float()?",
AtomKind::Double => "r.next_double()?",
AtomKind::SignedInteger => "r.next_signedinteger()?",
AtomKind::String => "r.next_str()?.into_owned()",

View File

@ -213,7 +213,6 @@ pub fn field_type(p: &SimplePattern) -> TField {
SimplePattern::Any => TField::Any,
SimplePattern::Atom { atom_kind: k } => match **k {
AtomKind::Boolean => TField::Base("bool".to_owned()),
AtomKind::Float => TField::Base("preserves::value::Float".to_owned()),
AtomKind::Double => TField::Base("preserves::value::Double".to_owned()),
AtomKind::SignedInteger => {
TField::Base("preserves::value::signed_integer::SignedInteger".to_owned())

View File

@ -7,69 +7,67 @@ use _support::preserves;
#[allow(non_snake_case)]
pub struct Language<N: preserves::value::NestedValue> {
pub LIT_15_FALSE: N /* #f */,
pub LIT_28_1: N /* 1 */,
pub LIT_14_FALSE: N /* #f */,
pub LIT_27_1: N /* 1 */,
pub LIT_0_BOOLEAN: N /* Boolean */,
pub LIT_5_BYTE_STRING: N /* ByteString */,
pub LIT_2_DOUBLE: N /* Double */,
pub LIT_1_FLOAT: N /* Float */,
pub LIT_3_SIGNED_INTEGER: N /* SignedInteger */,
pub LIT_4_STRING: N /* String */,
pub LIT_6_SYMBOL: N /* Symbol */,
pub LIT_14_AND: N /* and */,
pub LIT_21_ANY: N /* any */,
pub LIT_22_ATOM: N /* atom */,
pub LIT_8_BUNDLE: N /* bundle */,
pub LIT_18_DEFINITIONS: N /* definitions */,
pub LIT_12_DICT: N /* dict */,
pub LIT_27_DICTOF: N /* dictof */,
pub LIT_23_EMBEDDED: N /* embedded */,
pub LIT_19_EMBEDDED_TYPE: N /* embeddedType */,
pub LIT_24_LIT: N /* lit */,
pub LIT_7_NAMED: N /* named */,
pub LIT_13_OR: N /* or */,
pub LIT_9_REC: N /* rec */,
pub LIT_16_REF: N /* ref */,
pub LIT_17_SCHEMA: N /* schema */,
pub LIT_25_SEQOF: N /* seqof */,
pub LIT_26_SETOF: N /* setof */,
pub LIT_10_TUPLE: N /* tuple */,
pub LIT_11_TUPLE_PREFIX: N /* tuplePrefix */,
pub LIT_20_VERSION: N /* version */
pub LIT_4_BYTE_STRING: N /* ByteString */,
pub LIT_1_DOUBLE: N /* Double */,
pub LIT_2_SIGNED_INTEGER: N /* SignedInteger */,
pub LIT_3_STRING: N /* String */,
pub LIT_5_SYMBOL: N /* Symbol */,
pub LIT_13_AND: N /* and */,
pub LIT_20_ANY: N /* any */,
pub LIT_21_ATOM: N /* atom */,
pub LIT_7_BUNDLE: N /* bundle */,
pub LIT_17_DEFINITIONS: N /* definitions */,
pub LIT_11_DICT: N /* dict */,
pub LIT_26_DICTOF: N /* dictof */,
pub LIT_22_EMBEDDED: N /* embedded */,
pub LIT_18_EMBEDDED_TYPE: N /* embeddedType */,
pub LIT_23_LIT: N /* lit */,
pub LIT_6_NAMED: N /* named */,
pub LIT_12_OR: N /* or */,
pub LIT_8_REC: N /* rec */,
pub LIT_15_REF: N /* ref */,
pub LIT_16_SCHEMA: N /* schema */,
pub LIT_24_SEQOF: N /* seqof */,
pub LIT_25_SETOF: N /* setof */,
pub LIT_9_TUPLE: N /* tuple */,
pub LIT_10_TUPLE_PREFIX: N /* tuplePrefix */,
pub LIT_19_VERSION: N /* version */
}
impl<N: preserves::value::NestedValue> Default for Language<N> {
fn default() -> Self {
Language {
LIT_15_FALSE: /* #f */ _support::decode_lit(&[128]).unwrap(),
LIT_28_1: /* 1 */ _support::decode_lit(&[176, 1, 1]).unwrap(),
LIT_14_FALSE: /* #f */ _support::decode_lit(&[128]).unwrap(),
LIT_27_1: /* 1 */ _support::decode_lit(&[176, 1, 1]).unwrap(),
LIT_0_BOOLEAN: /* Boolean */ _support::decode_lit(&[179, 7, 66, 111, 111, 108, 101, 97, 110]).unwrap(),
LIT_5_BYTE_STRING: /* ByteString */ _support::decode_lit(&[179, 10, 66, 121, 116, 101, 83, 116, 114, 105, 110, 103]).unwrap(),
LIT_2_DOUBLE: /* Double */ _support::decode_lit(&[179, 6, 68, 111, 117, 98, 108, 101]).unwrap(),
LIT_1_FLOAT: /* Float */ _support::decode_lit(&[179, 5, 70, 108, 111, 97, 116]).unwrap(),
LIT_3_SIGNED_INTEGER: /* SignedInteger */ _support::decode_lit(&[179, 13, 83, 105, 103, 110, 101, 100, 73, 110, 116, 101, 103, 101, 114]).unwrap(),
LIT_4_STRING: /* String */ _support::decode_lit(&[179, 6, 83, 116, 114, 105, 110, 103]).unwrap(),
LIT_6_SYMBOL: /* Symbol */ _support::decode_lit(&[179, 6, 83, 121, 109, 98, 111, 108]).unwrap(),
LIT_14_AND: /* and */ _support::decode_lit(&[179, 3, 97, 110, 100]).unwrap(),
LIT_21_ANY: /* any */ _support::decode_lit(&[179, 3, 97, 110, 121]).unwrap(),
LIT_22_ATOM: /* atom */ _support::decode_lit(&[179, 4, 97, 116, 111, 109]).unwrap(),
LIT_8_BUNDLE: /* bundle */ _support::decode_lit(&[179, 6, 98, 117, 110, 100, 108, 101]).unwrap(),
LIT_18_DEFINITIONS: /* definitions */ _support::decode_lit(&[179, 11, 100, 101, 102, 105, 110, 105, 116, 105, 111, 110, 115]).unwrap(),
LIT_12_DICT: /* dict */ _support::decode_lit(&[179, 4, 100, 105, 99, 116]).unwrap(),
LIT_27_DICTOF: /* dictof */ _support::decode_lit(&[179, 6, 100, 105, 99, 116, 111, 102]).unwrap(),
LIT_23_EMBEDDED: /* embedded */ _support::decode_lit(&[179, 8, 101, 109, 98, 101, 100, 100, 101, 100]).unwrap(),
LIT_19_EMBEDDED_TYPE: /* embeddedType */ _support::decode_lit(&[179, 12, 101, 109, 98, 101, 100, 100, 101, 100, 84, 121, 112, 101]).unwrap(),
LIT_24_LIT: /* lit */ _support::decode_lit(&[179, 3, 108, 105, 116]).unwrap(),
LIT_7_NAMED: /* named */ _support::decode_lit(&[179, 5, 110, 97, 109, 101, 100]).unwrap(),
LIT_13_OR: /* or */ _support::decode_lit(&[179, 2, 111, 114]).unwrap(),
LIT_9_REC: /* rec */ _support::decode_lit(&[179, 3, 114, 101, 99]).unwrap(),
LIT_16_REF: /* ref */ _support::decode_lit(&[179, 3, 114, 101, 102]).unwrap(),
LIT_17_SCHEMA: /* schema */ _support::decode_lit(&[179, 6, 115, 99, 104, 101, 109, 97]).unwrap(),
LIT_25_SEQOF: /* seqof */ _support::decode_lit(&[179, 5, 115, 101, 113, 111, 102]).unwrap(),
LIT_26_SETOF: /* setof */ _support::decode_lit(&[179, 5, 115, 101, 116, 111, 102]).unwrap(),
LIT_10_TUPLE: /* tuple */ _support::decode_lit(&[179, 5, 116, 117, 112, 108, 101]).unwrap(),
LIT_11_TUPLE_PREFIX: /* tuplePrefix */ _support::decode_lit(&[179, 11, 116, 117, 112, 108, 101, 80, 114, 101, 102, 105, 120]).unwrap(),
LIT_20_VERSION: /* version */ _support::decode_lit(&[179, 7, 118, 101, 114, 115, 105, 111, 110]).unwrap()
LIT_4_BYTE_STRING: /* ByteString */ _support::decode_lit(&[179, 10, 66, 121, 116, 101, 83, 116, 114, 105, 110, 103]).unwrap(),
LIT_1_DOUBLE: /* Double */ _support::decode_lit(&[179, 6, 68, 111, 117, 98, 108, 101]).unwrap(),
LIT_2_SIGNED_INTEGER: /* SignedInteger */ _support::decode_lit(&[179, 13, 83, 105, 103, 110, 101, 100, 73, 110, 116, 101, 103, 101, 114]).unwrap(),
LIT_3_STRING: /* String */ _support::decode_lit(&[179, 6, 83, 116, 114, 105, 110, 103]).unwrap(),
LIT_5_SYMBOL: /* Symbol */ _support::decode_lit(&[179, 6, 83, 121, 109, 98, 111, 108]).unwrap(),
LIT_13_AND: /* and */ _support::decode_lit(&[179, 3, 97, 110, 100]).unwrap(),
LIT_20_ANY: /* any */ _support::decode_lit(&[179, 3, 97, 110, 121]).unwrap(),
LIT_21_ATOM: /* atom */ _support::decode_lit(&[179, 4, 97, 116, 111, 109]).unwrap(),
LIT_7_BUNDLE: /* bundle */ _support::decode_lit(&[179, 6, 98, 117, 110, 100, 108, 101]).unwrap(),
LIT_17_DEFINITIONS: /* definitions */ _support::decode_lit(&[179, 11, 100, 101, 102, 105, 110, 105, 116, 105, 111, 110, 115]).unwrap(),
LIT_11_DICT: /* dict */ _support::decode_lit(&[179, 4, 100, 105, 99, 116]).unwrap(),
LIT_26_DICTOF: /* dictof */ _support::decode_lit(&[179, 6, 100, 105, 99, 116, 111, 102]).unwrap(),
LIT_22_EMBEDDED: /* embedded */ _support::decode_lit(&[179, 8, 101, 109, 98, 101, 100, 100, 101, 100]).unwrap(),
LIT_18_EMBEDDED_TYPE: /* embeddedType */ _support::decode_lit(&[179, 12, 101, 109, 98, 101, 100, 100, 101, 100, 84, 121, 112, 101]).unwrap(),
LIT_23_LIT: /* lit */ _support::decode_lit(&[179, 3, 108, 105, 116]).unwrap(),
LIT_6_NAMED: /* named */ _support::decode_lit(&[179, 5, 110, 97, 109, 101, 100]).unwrap(),
LIT_12_OR: /* or */ _support::decode_lit(&[179, 2, 111, 114]).unwrap(),
LIT_8_REC: /* rec */ _support::decode_lit(&[179, 3, 114, 101, 99]).unwrap(),
LIT_15_REF: /* ref */ _support::decode_lit(&[179, 3, 114, 101, 102]).unwrap(),
LIT_16_SCHEMA: /* schema */ _support::decode_lit(&[179, 6, 115, 99, 104, 101, 109, 97]).unwrap(),
LIT_24_SEQOF: /* seqof */ _support::decode_lit(&[179, 5, 115, 101, 113, 111, 102]).unwrap(),
LIT_25_SETOF: /* setof */ _support::decode_lit(&[179, 5, 115, 101, 116, 111, 102]).unwrap(),
LIT_9_TUPLE: /* tuple */ _support::decode_lit(&[179, 5, 116, 117, 112, 108, 101]).unwrap(),
LIT_10_TUPLE_PREFIX: /* tuplePrefix */ _support::decode_lit(&[179, 11, 116, 117, 112, 108, 101, 80, 114, 101, 102, 105, 120]).unwrap(),
LIT_19_VERSION: /* version */ _support::decode_lit(&[179, 7, 118, 101, 114, 115, 105, 111, 110]).unwrap()
}
}
}
@ -125,141 +123,139 @@ pub fn _bundle() -> &'static [u8] {
\x6e\xb4\xb3\x03\x6c\x69\x74\xb0\x01\x01\x84\xb3\x08\x41\x74\x6f\
\x6d\x4b\x69\x6e\x64\xb4\xb3\x02\x6f\x72\xb5\xb5\xb1\x07\x42\x6f\
\x6f\x6c\x65\x61\x6e\xb4\xb3\x03\x6c\x69\x74\xb3\x07\x42\x6f\x6f\
\x6c\x65\x61\x6e\x84\x84\xb5\xb1\x05\x46\x6c\x6f\x61\x74\xb4\xb3\
\x03\x6c\x69\x74\xb3\x05\x46\x6c\x6f\x61\x74\x84\x84\xb5\xb1\x06\
\x44\x6f\x75\x62\x6c\x65\xb4\xb3\x03\x6c\x69\x74\xb3\x06\x44\x6f\
\x75\x62\x6c\x65\x84\x84\xb5\xb1\x0d\x53\x69\x67\x6e\x65\x64\x49\
\x6e\x74\x65\x67\x65\x72\xb4\xb3\x03\x6c\x69\x74\xb3\x0d\x53\x69\
\x67\x6e\x65\x64\x49\x6e\x74\x65\x67\x65\x72\x84\x84\xb5\xb1\x06\
\x53\x74\x72\x69\x6e\x67\xb4\xb3\x03\x6c\x69\x74\xb3\x06\x53\x74\
\x72\x69\x6e\x67\x84\x84\xb5\xb1\x0a\x42\x79\x74\x65\x53\x74\x72\
\x69\x6e\x67\xb4\xb3\x03\x6c\x69\x74\xb3\x0a\x42\x79\x74\x65\x53\
\x74\x72\x69\x6e\x67\x84\x84\xb5\xb1\x06\x53\x79\x6d\x62\x6f\x6c\
\xb4\xb3\x03\x6c\x69\x74\xb3\x06\x53\x79\x6d\x62\x6f\x6c\x84\x84\
\x84\x84\xb3\x0a\x44\x65\x66\x69\x6e\x69\x74\x69\x6f\x6e\xb4\xb3\
\x02\x6f\x72\xb5\xb5\xb1\x02\x6f\x72\xb4\xb3\x03\x72\x65\x63\xb4\
\xb3\x03\x6c\x69\x74\xb3\x02\x6f\x72\x84\xb4\xb3\x05\x74\x75\x70\
\x6c\x65\xb5\xb4\xb3\x0b\x74\x75\x70\x6c\x65\x50\x72\x65\x66\x69\
\x78\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x70\x61\x74\x74\
\x65\x72\x6e\x30\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x10\x4e\x61\
\x6d\x65\x64\x41\x6c\x74\x65\x72\x6e\x61\x74\x69\x76\x65\x84\x84\
\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x70\x61\x74\x74\x65\x72\
\x6e\x31\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x10\x4e\x61\x6d\x65\
\x64\x41\x6c\x74\x65\x72\x6e\x61\x74\x69\x76\x65\x84\x84\x84\xb4\
\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x70\x61\x74\x74\x65\x72\x6e\
\x4e\xb4\xb3\x05\x73\x65\x71\x6f\x66\xb4\xb3\x03\x72\x65\x66\xb5\
\x84\xb3\x10\x4e\x61\x6d\x65\x64\x41\x6c\x74\x65\x72\x6e\x61\x74\
\x69\x76\x65\x84\x84\x84\x84\x84\x84\x84\x84\xb5\xb1\x03\x61\x6e\
\x64\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x03\x61\
\x6e\x64\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x0b\x74\
\x6c\x65\x61\x6e\x84\x84\xb5\xb1\x06\x44\x6f\x75\x62\x6c\x65\xb4\
\xb3\x03\x6c\x69\x74\xb3\x06\x44\x6f\x75\x62\x6c\x65\x84\x84\xb5\
\xb1\x0d\x53\x69\x67\x6e\x65\x64\x49\x6e\x74\x65\x67\x65\x72\xb4\
\xb3\x03\x6c\x69\x74\xb3\x0d\x53\x69\x67\x6e\x65\x64\x49\x6e\x74\
\x65\x67\x65\x72\x84\x84\xb5\xb1\x06\x53\x74\x72\x69\x6e\x67\xb4\
\xb3\x03\x6c\x69\x74\xb3\x06\x53\x74\x72\x69\x6e\x67\x84\x84\xb5\
\xb1\x0a\x42\x79\x74\x65\x53\x74\x72\x69\x6e\x67\xb4\xb3\x03\x6c\
\x69\x74\xb3\x0a\x42\x79\x74\x65\x53\x74\x72\x69\x6e\x67\x84\x84\
\xb5\xb1\x06\x53\x79\x6d\x62\x6f\x6c\xb4\xb3\x03\x6c\x69\x74\xb3\
\x06\x53\x79\x6d\x62\x6f\x6c\x84\x84\x84\x84\xb3\x0a\x44\x65\x66\
\x69\x6e\x69\x74\x69\x6f\x6e\xb4\xb3\x02\x6f\x72\xb5\xb5\xb1\x02\
\x6f\x72\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x02\
\x6f\x72\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x0b\x74\
\x75\x70\x6c\x65\x50\x72\x65\x66\x69\x78\xb5\xb4\xb3\x05\x6e\x61\
\x6d\x65\x64\xb3\x08\x70\x61\x74\x74\x65\x72\x6e\x30\xb4\xb3\x03\
\x72\x65\x66\xb5\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\
\x65\x72\x6e\x84\x84\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x70\
\x61\x74\x74\x65\x72\x6e\x31\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\
\x0c\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\
\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x70\x61\x74\x74\x65\x72\
\x6e\x4e\xb4\xb3\x05\x73\x65\x71\x6f\x66\xb4\xb3\x03\x72\x65\x66\
\xb5\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\x65\x72\x6e\
\x84\x84\x84\x84\x84\x84\x84\x84\xb5\xb1\x07\x50\x61\x74\x74\x65\
\x72\x6e\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x07\x50\x61\x74\x74\
\x65\x72\x6e\x84\x84\x84\x84\xb3\x0a\x4d\x6f\x64\x75\x6c\x65\x50\
\x61\x74\x68\xb4\xb3\x05\x73\x65\x71\x6f\x66\xb4\xb3\x04\x61\x74\
\x6f\x6d\xb3\x06\x53\x79\x6d\x62\x6f\x6c\x84\x84\xb3\x0b\x44\x65\
\x66\x69\x6e\x69\x74\x69\x6f\x6e\x73\xb4\xb3\x06\x64\x69\x63\x74\
\x6f\x66\xb4\xb3\x04\x61\x74\x6f\x6d\xb3\x06\x53\x79\x6d\x62\x6f\
\x6c\x84\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0a\x44\x65\x66\x69\
\x6e\x69\x74\x69\x6f\x6e\x84\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\
\x61\x74\x74\x65\x72\x6e\xb4\xb3\x02\x6f\x72\xb5\xb5\xb1\x05\x6e\
\x61\x6d\x65\x64\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x07\x42\x69\
\x6e\x64\x69\x6e\x67\x84\x84\xb5\xb1\x09\x61\x6e\x6f\x6e\x79\x6d\
\x6f\x75\x73\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x07\x50\x61\x74\
\x74\x65\x72\x6e\x84\x84\x84\x84\xb3\x0d\x53\x69\x6d\x70\x6c\x65\
\x50\x61\x74\x74\x65\x72\x6e\xb4\xb3\x02\x6f\x72\xb5\xb5\xb1\x03\
\x61\x6e\x79\xb4\xb3\x03\x6c\x69\x74\xb3\x03\x61\x6e\x79\x84\x84\
\xb5\xb1\x04\x61\x74\x6f\x6d\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\
\x6c\x69\x74\xb3\x04\x61\x74\x6f\x6d\x84\xb4\xb3\x05\x74\x75\x70\
\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x61\x74\x6f\
\x6d\x4b\x69\x6e\x64\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x08\x41\
\x74\x6f\x6d\x4b\x69\x6e\x64\x84\x84\x84\x84\x84\x84\xb5\xb1\x08\
\x65\x6d\x62\x65\x64\x64\x65\x64\xb4\xb3\x03\x72\x65\x63\xb4\xb3\
\x03\x6c\x69\x74\xb3\x08\x65\x6d\x62\x65\x64\x64\x65\x64\x84\xb4\
\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\
\xb3\x09\x69\x6e\x74\x65\x72\x66\x61\x63\x65\xb4\xb3\x03\x72\x65\
\x66\xb5\x84\xb3\x0d\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\
\x72\x6e\x84\x84\x84\x84\x84\x84\xb5\xb1\x03\x6c\x69\x74\xb4\xb3\
\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x03\x6c\x69\x74\x84\
\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\
\x64\xb3\x05\x76\x61\x6c\x75\x65\xb3\x03\x61\x6e\x79\x84\x84\x84\
\x84\x84\xb5\xb1\x05\x73\x65\x71\x6f\x66\xb4\xb3\x03\x72\x65\x63\
\xb4\xb3\x03\x6c\x69\x74\xb3\x05\x73\x65\x71\x6f\x66\x84\xb4\xb3\
\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\
\x07\x70\x61\x74\x74\x65\x72\x6e\xb4\xb3\x03\x72\x65\x66\xb5\x84\
\xb3\x0d\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\x84\
\x84\x84\x84\x84\x84\xb5\xb1\x05\x73\x65\x74\x6f\x66\xb4\xb3\x03\
\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x05\x73\x65\x74\x6f\x66\
\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\
\x65\x64\xb3\x07\x70\x61\x74\x74\x65\x72\x6e\xb4\xb3\x03\x72\x65\
\x66\xb5\x84\xb3\x0d\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\
\x72\x6e\x84\x84\x84\x84\x84\x84\xb5\xb1\x06\x64\x69\x63\x74\x6f\
\x66\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x06\x64\
\x69\x63\x74\x6f\x66\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\
\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x03\x6b\x65\x79\xb4\xb3\x03\x72\
\x65\x66\xb5\x84\xb3\x0d\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\
\x65\x72\x6e\x84\x84\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x05\x76\
\x61\x6c\x75\x65\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0d\x53\x69\
\x72\x65\x66\xb5\x84\xb3\x10\x4e\x61\x6d\x65\x64\x41\x6c\x74\x65\
\x72\x6e\x61\x74\x69\x76\x65\x84\x84\xb4\xb3\x05\x6e\x61\x6d\x65\
\x64\xb3\x08\x70\x61\x74\x74\x65\x72\x6e\x31\xb4\xb3\x03\x72\x65\
\x66\xb5\x84\xb3\x10\x4e\x61\x6d\x65\x64\x41\x6c\x74\x65\x72\x6e\
\x61\x74\x69\x76\x65\x84\x84\x84\xb4\xb3\x05\x6e\x61\x6d\x65\x64\
\xb3\x08\x70\x61\x74\x74\x65\x72\x6e\x4e\xb4\xb3\x05\x73\x65\x71\
\x6f\x66\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x10\x4e\x61\x6d\x65\
\x64\x41\x6c\x74\x65\x72\x6e\x61\x74\x69\x76\x65\x84\x84\x84\x84\
\x84\x84\x84\x84\xb5\xb1\x03\x61\x6e\x64\xb4\xb3\x03\x72\x65\x63\
\xb4\xb3\x03\x6c\x69\x74\xb3\x03\x61\x6e\x64\x84\xb4\xb3\x05\x74\
\x75\x70\x6c\x65\xb5\xb4\xb3\x0b\x74\x75\x70\x6c\x65\x50\x72\x65\
\x66\x69\x78\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x70\x61\
\x74\x74\x65\x72\x6e\x30\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0c\
\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\x65\x72\x6e\x84\x84\xb4\xb3\
\x05\x6e\x61\x6d\x65\x64\xb3\x08\x70\x61\x74\x74\x65\x72\x6e\x31\
\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\
\x61\x74\x74\x65\x72\x6e\x84\x84\x84\xb4\xb3\x05\x6e\x61\x6d\x65\
\x64\xb3\x08\x70\x61\x74\x74\x65\x72\x6e\x4e\xb4\xb3\x05\x73\x65\
\x71\x6f\x66\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0c\x4e\x61\x6d\
\x65\x64\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\x84\x84\x84\
\x84\xb5\xb1\x07\x50\x61\x74\x74\x65\x72\x6e\xb4\xb3\x03\x72\x65\
\x66\xb5\x84\xb3\x07\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\
\xb3\x0a\x4d\x6f\x64\x75\x6c\x65\x50\x61\x74\x68\xb4\xb3\x05\x73\
\x65\x71\x6f\x66\xb4\xb3\x04\x61\x74\x6f\x6d\xb3\x06\x53\x79\x6d\
\x62\x6f\x6c\x84\x84\xb3\x0b\x44\x65\x66\x69\x6e\x69\x74\x69\x6f\
\x6e\x73\xb4\xb3\x06\x64\x69\x63\x74\x6f\x66\xb4\xb3\x04\x61\x74\
\x6f\x6d\xb3\x06\x53\x79\x6d\x62\x6f\x6c\x84\xb4\xb3\x03\x72\x65\
\x66\xb5\x84\xb3\x0a\x44\x65\x66\x69\x6e\x69\x74\x69\x6f\x6e\x84\
\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\x65\x72\x6e\xb4\
\xb3\x02\x6f\x72\xb5\xb5\xb1\x05\x6e\x61\x6d\x65\x64\xb4\xb3\x03\
\x72\x65\x66\xb5\x84\xb3\x07\x42\x69\x6e\x64\x69\x6e\x67\x84\x84\
\xb5\xb1\x09\x61\x6e\x6f\x6e\x79\x6d\x6f\x75\x73\xb4\xb3\x03\x72\
\x65\x66\xb5\x84\xb3\x07\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\
\x84\xb3\x0d\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\
\xb4\xb3\x02\x6f\x72\xb5\xb5\xb1\x03\x61\x6e\x79\xb4\xb3\x03\x6c\
\x69\x74\xb3\x03\x61\x6e\x79\x84\x84\xb5\xb1\x04\x61\x74\x6f\x6d\
\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x04\x61\x74\
\x6f\x6d\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\
\x61\x6d\x65\x64\xb3\x08\x61\x74\x6f\x6d\x4b\x69\x6e\x64\xb4\xb3\
\x03\x72\x65\x66\xb5\x84\xb3\x08\x41\x74\x6f\x6d\x4b\x69\x6e\x64\
\x84\x84\x84\x84\x84\x84\xb5\xb1\x08\x65\x6d\x62\x65\x64\x64\x65\
\x64\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x08\x65\
\x6d\x62\x65\x64\x64\x65\x64\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\
\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x09\x69\x6e\x74\x65\x72\
\x66\x61\x63\x65\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0d\x53\x69\
\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\x84\
\x84\xb5\xb1\x03\x52\x65\x66\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\
\x03\x52\x65\x66\x84\x84\x84\x84\xb3\x0f\x43\x6f\x6d\x70\x6f\x75\
\x6e\x64\x50\x61\x74\x74\x65\x72\x6e\xb4\xb3\x02\x6f\x72\xb5\xb5\
\xb1\x03\x72\x65\x63\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\
\x74\xb3\x03\x72\x65\x63\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\
\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x05\x6c\x61\x62\x65\x6c\xb4\
\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\x61\
\x74\x74\x65\x72\x6e\x84\x84\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\
\x06\x66\x69\x65\x6c\x64\x73\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\
\x0c\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\
\x84\x84\x84\xb5\xb1\x05\x74\x75\x70\x6c\x65\xb4\xb3\x03\x72\x65\
\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x05\x74\x75\x70\x6c\x65\x84\xb4\
\x84\xb5\xb1\x03\x6c\x69\x74\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\
\x6c\x69\x74\xb3\x03\x6c\x69\x74\x84\xb4\xb3\x05\x74\x75\x70\x6c\
\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x05\x76\x61\x6c\x75\
\x65\xb3\x03\x61\x6e\x79\x84\x84\x84\x84\x84\xb5\xb1\x05\x73\x65\
\x71\x6f\x66\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\
\x05\x73\x65\x71\x6f\x66\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\
\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x07\x70\x61\x74\x74\x65\x72\
\x6e\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0d\x53\x69\x6d\x70\x6c\
\x65\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\x84\x84\xb5\xb1\
\x05\x73\x65\x74\x6f\x66\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\
\x69\x74\xb3\x05\x73\x65\x74\x6f\x66\x84\xb4\xb3\x05\x74\x75\x70\
\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x07\x70\x61\x74\
\x74\x65\x72\x6e\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0d\x53\x69\
\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\x84\
\x84\xb5\xb1\x06\x64\x69\x63\x74\x6f\x66\xb4\xb3\x03\x72\x65\x63\
\xb4\xb3\x03\x6c\x69\x74\xb3\x06\x64\x69\x63\x74\x6f\x66\x84\xb4\
\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\
\xb3\x08\x70\x61\x74\x74\x65\x72\x6e\x73\xb4\xb3\x05\x73\x65\x71\
\x6f\x66\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0c\x4e\x61\x6d\x65\
\x64\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\x84\x84\x84\xb5\
\xb1\x0b\x74\x75\x70\x6c\x65\x50\x72\x65\x66\x69\x78\xb4\xb3\x03\
\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x0b\x74\x75\x70\x6c\x65\
\x50\x72\x65\x66\x69\x78\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\
\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x05\x66\x69\x78\x65\x64\xb4\
\xb3\x05\x73\x65\x71\x6f\x66\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\
\x0c\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\
\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x76\x61\x72\x69\x61\x62\
\x6c\x65\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x12\x4e\x61\x6d\x65\
\x64\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\x84\x84\
\x84\x84\x84\x84\xb5\xb1\x04\x64\x69\x63\x74\xb4\xb3\x03\x72\x65\
\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x04\x64\x69\x63\x74\x84\xb4\xb3\
\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\
\x07\x65\x6e\x74\x72\x69\x65\x73\xb4\xb3\x03\x72\x65\x66\xb5\x84\
\xb3\x11\x44\x69\x63\x74\x69\x6f\x6e\x61\x72\x79\x45\x6e\x74\x72\
\x69\x65\x73\x84\x84\x84\x84\x84\x84\x84\x84\xb3\x10\x45\x6d\x62\
\x65\x64\x64\x65\x64\x54\x79\x70\x65\x4e\x61\x6d\x65\xb4\xb3\x02\
\x6f\x72\xb5\xb5\xb1\x05\x66\x61\x6c\x73\x65\xb4\xb3\x03\x6c\x69\
\x74\x80\x84\x84\xb5\xb1\x03\x52\x65\x66\xb4\xb3\x03\x72\x65\x66\
\xb5\x84\xb3\x03\x52\x65\x66\x84\x84\x84\x84\xb3\x10\x4e\x61\x6d\
\x65\x64\x41\x6c\x74\x65\x72\x6e\x61\x74\x69\x76\x65\xb4\xb3\x05\
\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x0c\
\x76\x61\x72\x69\x61\x6e\x74\x4c\x61\x62\x65\x6c\xb4\xb3\x04\x61\
\x74\x6f\x6d\xb3\x06\x53\x74\x72\x69\x6e\x67\x84\x84\xb4\xb3\x05\
\x6e\x61\x6d\x65\x64\xb3\x07\x70\x61\x74\x74\x65\x72\x6e\xb4\xb3\
\x03\x72\x65\x66\xb5\x84\xb3\x07\x50\x61\x74\x74\x65\x72\x6e\x84\
\x84\x84\x84\xb3\x11\x44\x69\x63\x74\x69\x6f\x6e\x61\x72\x79\x45\
\x6e\x74\x72\x69\x65\x73\xb4\xb3\x06\x64\x69\x63\x74\x6f\x66\xb3\
\x03\x61\x6e\x79\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x12\x4e\x61\
\x6d\x65\x64\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\
\x84\x84\xb3\x12\x4e\x61\x6d\x65\x64\x53\x69\x6d\x70\x6c\x65\x50\
\x61\x74\x74\x65\x72\x6e\xb4\xb3\x02\x6f\x72\xb5\xb5\xb1\x05\x6e\
\x61\x6d\x65\x64\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x07\x42\x69\
\x6e\x64\x69\x6e\x67\x84\x84\xb5\xb1\x09\x61\x6e\x6f\x6e\x79\x6d\
\x6f\x75\x73\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0d\x53\x69\x6d\
\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\x84\xb3\
\x0c\x65\x6d\x62\x65\x64\x64\x65\x64\x54\x79\x70\x65\x80\x84\x84\
\x84\x84"
\xb3\x03\x6b\x65\x79\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0d\x53\
\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\x84\x84\xb4\xb3\
\x05\x6e\x61\x6d\x65\x64\xb3\x05\x76\x61\x6c\x75\x65\xb4\xb3\x03\
\x72\x65\x66\xb5\x84\xb3\x0d\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\
\x74\x65\x72\x6e\x84\x84\x84\x84\x84\x84\xb5\xb1\x03\x52\x65\x66\
\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x03\x52\x65\x66\x84\x84\x84\
\x84\xb3\x0f\x43\x6f\x6d\x70\x6f\x75\x6e\x64\x50\x61\x74\x74\x65\
\x72\x6e\xb4\xb3\x02\x6f\x72\xb5\xb5\xb1\x03\x72\x65\x63\xb4\xb3\
\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\xb3\x03\x72\x65\x63\x84\
\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\
\x64\xb3\x05\x6c\x61\x62\x65\x6c\xb4\xb3\x03\x72\x65\x66\xb5\x84\
\xb3\x0c\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\x65\x72\x6e\x84\x84\
\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x06\x66\x69\x65\x6c\x64\x73\
\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\
\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\x84\x84\xb5\xb1\x05\x74\
\x75\x70\x6c\x65\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\
\xb3\x05\x74\x75\x70\x6c\x65\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\
\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x08\x70\x61\x74\x74\x65\
\x72\x6e\x73\xb4\xb3\x05\x73\x65\x71\x6f\x66\xb4\xb3\x03\x72\x65\
\x66\xb5\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\x61\x74\x74\x65\x72\
\x6e\x84\x84\x84\x84\x84\x84\x84\xb5\xb1\x0b\x74\x75\x70\x6c\x65\
\x50\x72\x65\x66\x69\x78\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\
\x69\x74\xb3\x0b\x74\x75\x70\x6c\x65\x50\x72\x65\x66\x69\x78\x84\
\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\xb3\x05\x6e\x61\x6d\x65\
\x64\xb3\x05\x66\x69\x78\x65\x64\xb4\xb3\x05\x73\x65\x71\x6f\x66\
\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x0c\x4e\x61\x6d\x65\x64\x50\
\x61\x74\x74\x65\x72\x6e\x84\x84\x84\xb4\xb3\x05\x6e\x61\x6d\x65\
\x64\xb3\x08\x76\x61\x72\x69\x61\x62\x6c\x65\xb4\xb3\x03\x72\x65\
\x66\xb5\x84\xb3\x12\x4e\x61\x6d\x65\x64\x53\x69\x6d\x70\x6c\x65\
\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\x84\x84\xb5\xb1\x04\
\x64\x69\x63\x74\xb4\xb3\x03\x72\x65\x63\xb4\xb3\x03\x6c\x69\x74\
\xb3\x04\x64\x69\x63\x74\x84\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\
\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x07\x65\x6e\x74\x72\x69\x65\
\x73\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x11\x44\x69\x63\x74\x69\
\x6f\x6e\x61\x72\x79\x45\x6e\x74\x72\x69\x65\x73\x84\x84\x84\x84\
\x84\x84\x84\x84\xb3\x10\x45\x6d\x62\x65\x64\x64\x65\x64\x54\x79\
\x70\x65\x4e\x61\x6d\x65\xb4\xb3\x02\x6f\x72\xb5\xb5\xb1\x05\x66\
\x61\x6c\x73\x65\xb4\xb3\x03\x6c\x69\x74\x80\x84\x84\xb5\xb1\x03\
\x52\x65\x66\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\x03\x52\x65\x66\
\x84\x84\x84\x84\xb3\x10\x4e\x61\x6d\x65\x64\x41\x6c\x74\x65\x72\
\x6e\x61\x74\x69\x76\x65\xb4\xb3\x05\x74\x75\x70\x6c\x65\xb5\xb4\
\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x0c\x76\x61\x72\x69\x61\x6e\x74\
\x4c\x61\x62\x65\x6c\xb4\xb3\x04\x61\x74\x6f\x6d\xb3\x06\x53\x74\
\x72\x69\x6e\x67\x84\x84\xb4\xb3\x05\x6e\x61\x6d\x65\x64\xb3\x07\
\x70\x61\x74\x74\x65\x72\x6e\xb4\xb3\x03\x72\x65\x66\xb5\x84\xb3\
\x07\x50\x61\x74\x74\x65\x72\x6e\x84\x84\x84\x84\xb3\x11\x44\x69\
\x63\x74\x69\x6f\x6e\x61\x72\x79\x45\x6e\x74\x72\x69\x65\x73\xb4\
\xb3\x06\x64\x69\x63\x74\x6f\x66\xb3\x03\x61\x6e\x79\xb4\xb3\x03\
\x72\x65\x66\xb5\x84\xb3\x12\x4e\x61\x6d\x65\x64\x53\x69\x6d\x70\
\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\x84\x84\xb3\x12\x4e\x61\x6d\
\x65\x64\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\x65\x72\x6e\xb4\
\xb3\x02\x6f\x72\xb5\xb5\xb1\x05\x6e\x61\x6d\x65\x64\xb4\xb3\x03\
\x72\x65\x66\xb5\x84\xb3\x07\x42\x69\x6e\x64\x69\x6e\x67\x84\x84\
\xb5\xb1\x09\x61\x6e\x6f\x6e\x79\x6d\x6f\x75\x73\xb4\xb3\x03\x72\
\x65\x66\xb5\x84\xb3\x0d\x53\x69\x6d\x70\x6c\x65\x50\x61\x74\x74\
\x65\x72\x6e\x84\x84\x84\x84\x84\xb3\x0c\x65\x6d\x62\x65\x64\x64\
\x65\x64\x54\x79\x70\x65\x80\x84\x84\x84\x84"
}

View File

@ -14,7 +14,6 @@ use preserves::value::NestedValue;
#[derive(Debug, PartialOrd, Ord, PartialEq, Eq, Clone, Hash)]
pub enum AtomKind {
Boolean,
Float,
Double,
SignedInteger,
String,
@ -36,18 +35,6 @@ fn read_atom_kind_boolean<'de, _Value: preserves::value::NestedValue, R: _suppor
Ok(AtomKind::Boolean)
}
fn read_atom_kind_float<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<AtomKind, _support::ParseError> {
match r.next_token(true)? {
preserves::value::Token::Atom(v) => match v.value() {
preserves::value::Value::Symbol(w) if w == "Float" => {}
_ => return Err(_support::ParseError::conformance_error("schema.AtomKind::Float"))?,
}
_ => return Err(_support::ParseError::conformance_error("schema.AtomKind::Float"))?,
}
let _tmp0 = ();
Ok(AtomKind::Float)
}
fn read_atom_kind_double<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<AtomKind, _support::ParseError> {
match r.next_token(true)? {
preserves::value::Token::Atom(v) => match v.value() {
@ -112,7 +99,6 @@ impl<_Value: preserves::value::NestedValue> _support::Deserialize<_Value> for At
fn deserialize<'de, R: _support::Reader<'de, _Value>>(r: &mut R) -> std::result::Result<Self, _support::ParseError> {
let _mark = r.mark()?;
match read_atom_kind_boolean(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_atom_kind_float(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_atom_kind_double(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_atom_kind_signed_integer(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
match read_atom_kind_string(r) { Err(e) if e.is_conformance_error() => r.restore(&_mark)?, result => return result }
@ -132,22 +118,12 @@ fn parse_atom_kind_boolean<
Ok(AtomKind::Boolean)
}
fn parse_atom_kind_float<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_1_FLOAT { return Err(_support::ParseError::conformance_error("schema.AtomKind::Float")); }
let _tmp0 = ();
Ok(AtomKind::Float)
}
fn parse_atom_kind_double<
'a,
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_2_DOUBLE { return Err(_support::ParseError::conformance_error("schema.AtomKind::Double")); }
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_1_DOUBLE { return Err(_support::ParseError::conformance_error("schema.AtomKind::Double")); }
let _tmp0 = ();
Ok(AtomKind::Double)
}
@ -157,7 +133,7 @@ fn parse_atom_kind_signed_integer<
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_3_SIGNED_INTEGER { return Err(_support::ParseError::conformance_error("schema.AtomKind::SignedInteger")); }
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_2_SIGNED_INTEGER { return Err(_support::ParseError::conformance_error("schema.AtomKind::SignedInteger")); }
let _tmp0 = ();
Ok(AtomKind::SignedInteger)
}
@ -167,7 +143,7 @@ fn parse_atom_kind_string<
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_4_STRING { return Err(_support::ParseError::conformance_error("schema.AtomKind::String")); }
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_3_STRING { return Err(_support::ParseError::conformance_error("schema.AtomKind::String")); }
let _tmp0 = ();
Ok(AtomKind::String)
}
@ -177,7 +153,7 @@ fn parse_atom_kind_byte_string<
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_5_BYTE_STRING { return Err(_support::ParseError::conformance_error("schema.AtomKind::ByteString")); }
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_4_BYTE_STRING { return Err(_support::ParseError::conformance_error("schema.AtomKind::ByteString")); }
let _tmp0 = ();
Ok(AtomKind::ByteString)
}
@ -187,7 +163,7 @@ fn parse_atom_kind_symbol<
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_6_SYMBOL { return Err(_support::ParseError::conformance_error("schema.AtomKind::Symbol")); }
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_5_SYMBOL { return Err(_support::ParseError::conformance_error("schema.AtomKind::Symbol")); }
let _tmp0 = ();
Ok(AtomKind::Symbol)
}
@ -199,7 +175,6 @@ impl<
> _support::Parse<_L, _Value> for AtomKind {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if let Ok(r) = parse_atom_kind_boolean(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_atom_kind_float(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_atom_kind_double(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_atom_kind_signed_integer(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_atom_kind_string(_ctxt, value) { return Ok(r); }
@ -217,14 +192,13 @@ impl<
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
AtomKind::Boolean => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_0_BOOLEAN).clone(),
AtomKind::Float => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_1_FLOAT).clone(),
AtomKind::Double => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_2_DOUBLE).clone(),
AtomKind::Double => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_1_DOUBLE).clone(),
AtomKind::SignedInteger => (
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_3_SIGNED_INTEGER
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_2_SIGNED_INTEGER
).clone(),
AtomKind::String => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_4_STRING).clone(),
AtomKind::ByteString => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_5_BYTE_STRING).clone(),
AtomKind::Symbol => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_6_SYMBOL).clone(),
AtomKind::String => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_3_STRING).clone(),
AtomKind::ByteString => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_4_BYTE_STRING).clone(),
AtomKind::Symbol => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_5_SYMBOL).clone(),
}
}
}
@ -269,7 +243,7 @@ impl<
> _support::Parse<_L, _Value> for Binding<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_7_NAMED { return Err(_support::ParseError::conformance_error("schema.Binding")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_6_NAMED { return Err(_support::ParseError::conformance_error("schema.Binding")); }
let _tmp1 = ();
if _tmp0.fields().len() < 2 { return Err(_support::ParseError::conformance_error("schema.Binding")); }
let _tmp2 = (&_tmp0.fields()[0]).value().to_symbol()?;
@ -286,7 +260,7 @@ impl<
fn unparse(&self, _ctxt: _L) -> _Value {
let Binding {name: _tmp0, pattern: _tmp1} = self;
{
let mut _tmp2 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_7_NAMED).clone()]);
let mut _tmp2 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_6_NAMED).clone()]);
_tmp2.fields_vec_mut().push(preserves::value::Value::symbol(_tmp0).wrap());
_tmp2.fields_vec_mut().push(_tmp1.unparse(_ctxt));
_tmp2.finish().wrap()
@ -330,7 +304,7 @@ impl<
> _support::Parse<_L, _Value> for Bundle<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_8_BUNDLE { return Err(_support::ParseError::conformance_error("schema.Bundle")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_7_BUNDLE { return Err(_support::ParseError::conformance_error("schema.Bundle")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.Bundle")); }
let _tmp2 = Modules::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -346,7 +320,7 @@ impl<
fn unparse(&self, _ctxt: _L) -> _Value {
let Bundle {modules: _tmp0} = self;
{
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_8_BUNDLE).clone()]);
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_7_BUNDLE).clone()]);
_tmp1.fields_vec_mut().push(_tmp0.unparse(_ctxt));
_tmp1.finish().wrap()
}
@ -494,7 +468,7 @@ fn parse_compound_pattern_rec<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_9_REC { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::rec")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_8_REC { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::rec")); }
let _tmp1 = ();
if _tmp0.fields().len() < 2 { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::rec")); }
let _tmp2 = NamedPattern::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -508,7 +482,7 @@ fn parse_compound_pattern_tuple<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_10_TUPLE { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuple")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_9_TUPLE { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuple")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuple")); }
let _tmp3 = (&_tmp0.fields()[0]).value().to_sequence()?;
@ -526,7 +500,7 @@ fn parse_compound_pattern_tuple_prefix<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_11_TUPLE_PREFIX { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuplePrefix")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_10_TUPLE_PREFIX { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuplePrefix")); }
let _tmp1 = ();
if _tmp0.fields().len() < 2 { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuplePrefix")); }
let _tmp3 = (&_tmp0.fields()[0]).value().to_sequence()?;
@ -545,7 +519,7 @@ fn parse_compound_pattern_dict<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_12_DICT { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::dict")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_11_DICT { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::dict")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::dict")); }
let _tmp2 = DictionaryEntries::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -574,13 +548,13 @@ impl<
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
CompoundPattern::Rec {label: _tmp0, fields: _tmp1} => {
let mut _tmp2 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_9_REC).clone()]);
let mut _tmp2 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_8_REC).clone()]);
_tmp2.fields_vec_mut().push(_tmp0.as_ref().unparse(_ctxt));
_tmp2.fields_vec_mut().push(_tmp1.as_ref().unparse(_ctxt));
_tmp2.finish().wrap()
},
CompoundPattern::Tuple {patterns: _tmp0} => {
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_10_TUPLE).clone()]);
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_9_TUPLE).clone()]);
_tmp1.fields_vec_mut().push(
{
let mut _tmp2 = std::vec::Vec::new();
@ -594,7 +568,7 @@ impl<
},
CompoundPattern::TuplePrefix {fixed: _tmp0, variable: _tmp1} => {
let mut _tmp2 = preserves::value::Record(vec![(
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_11_TUPLE_PREFIX
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_10_TUPLE_PREFIX
).clone()]);
_tmp2.fields_vec_mut().push(
{
@ -609,7 +583,7 @@ impl<
_tmp2.finish().wrap()
},
CompoundPattern::Dict {entries: _tmp0} => {
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_12_DICT).clone()]);
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_11_DICT).clone()]);
_tmp1.fields_vec_mut().push(_tmp0.as_ref().unparse(_ctxt));
_tmp1.finish().wrap()
},
@ -733,7 +707,7 @@ fn parse_definition_or<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_13_OR { return Err(_support::ParseError::conformance_error("schema.Definition::or")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_12_OR { return Err(_support::ParseError::conformance_error("schema.Definition::or")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.Definition::or")); }
let _tmp2 = (&_tmp0.fields()[0]).value().to_sequence()?;
@ -758,7 +732,7 @@ fn parse_definition_and<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_14_AND { return Err(_support::ParseError::conformance_error("schema.Definition::and")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_13_AND { return Err(_support::ParseError::conformance_error("schema.Definition::and")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.Definition::and")); }
let _tmp2 = (&_tmp0.fields()[0]).value().to_sequence()?;
@ -807,7 +781,7 @@ impl<
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
Definition::Or {pattern_0: _tmp0, pattern_1: _tmp1, pattern_n: _tmp2} => {
let mut _tmp3 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_13_OR).clone()]);
let mut _tmp3 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_12_OR).clone()]);
_tmp3.fields_vec_mut().push(
{
let mut _tmp4 = std::vec::Vec::new();
@ -822,7 +796,7 @@ impl<
_tmp3.finish().wrap()
},
Definition::And {pattern_0: _tmp0, pattern_1: _tmp1, pattern_n: _tmp2} => {
let mut _tmp3 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_14_AND).clone()]);
let mut _tmp3 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_13_AND).clone()]);
_tmp3.fields_vec_mut().push(
{
let mut _tmp4 = std::vec::Vec::new();
@ -982,7 +956,7 @@ fn parse_embedded_type_name_false<
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_15_FALSE { return Err(_support::ParseError::conformance_error("schema.EmbeddedTypeName::false")); }
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_14_FALSE { return Err(_support::ParseError::conformance_error("schema.EmbeddedTypeName::false")); }
let _tmp0 = ();
Ok(EmbeddedTypeName::False)
}
@ -1015,7 +989,7 @@ impl<
> _support::Unparse<_L, _Value> for EmbeddedTypeName {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
EmbeddedTypeName::False => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_15_FALSE).clone(),
EmbeddedTypeName::False => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_14_FALSE).clone(),
EmbeddedTypeName::Ref(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
}
}
@ -1429,7 +1403,7 @@ impl<
> _support::Parse<_L, _Value> for Ref {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_16_REF { return Err(_support::ParseError::conformance_error("schema.Ref")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_15_REF { return Err(_support::ParseError::conformance_error("schema.Ref")); }
let _tmp1 = ();
if _tmp0.fields().len() < 2 { return Err(_support::ParseError::conformance_error("schema.Ref")); }
let _tmp2 = ModulePath::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -1446,7 +1420,7 @@ impl<
fn unparse(&self, _ctxt: _L) -> _Value {
let Ref {module: _tmp0, name: _tmp1} = self;
{
let mut _tmp2 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_16_REF).clone()]);
let mut _tmp2 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_15_REF).clone()]);
_tmp2.fields_vec_mut().push(_tmp0.unparse(_ctxt));
_tmp2.fields_vec_mut().push(preserves::value::Value::symbol(_tmp1).wrap());
_tmp2.finish().wrap()
@ -1528,19 +1502,19 @@ impl<
> _support::Parse<_L, _Value> for Schema<_Value> {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_17_SCHEMA { return Err(_support::ParseError::conformance_error("schema.Schema")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_16_SCHEMA { return Err(_support::ParseError::conformance_error("schema.Schema")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.Schema")); }
let _tmp2 = (&_tmp0.fields()[0]).value().to_dictionary()?;
let _tmp3 = _tmp2.get(
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_18_DEFINITIONS
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_17_DEFINITIONS
).ok_or_else(|| _support::ParseError::conformance_error("schema.Schema"))?;
let _tmp4 = Definitions::parse(_ctxt, _tmp3)?;
let _tmp5 = _tmp2.get(
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_19_EMBEDDED_TYPE
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_18_EMBEDDED_TYPE
).ok_or_else(|| _support::ParseError::conformance_error("schema.Schema"))?;
let _tmp6 = EmbeddedTypeName::parse(_ctxt, _tmp5)?;
let _tmp7 = _tmp2.get(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_20_VERSION).ok_or_else(|| _support::ParseError::conformance_error("schema.Schema"))?;
let _tmp7 = _tmp2.get(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_19_VERSION).ok_or_else(|| _support::ParseError::conformance_error("schema.Schema"))?;
let _tmp8 = Version::parse(_ctxt, _tmp7)?;
Ok(Schema {definitions: _tmp4, embedded_type: _tmp6, version: _tmp8})
}
@ -1554,24 +1528,24 @@ impl<
fn unparse(&self, _ctxt: _L) -> _Value {
let Schema {definitions: _tmp0, embedded_type: _tmp1, version: _tmp2} = self;
{
let mut _tmp3 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_17_SCHEMA).clone()]);
let mut _tmp3 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_16_SCHEMA).clone()]);
_tmp3.fields_vec_mut().push(
{
let mut _tmp4 = preserves::value::Map::new();
_tmp4.insert(
(
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_18_DEFINITIONS
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_17_DEFINITIONS
).clone(),
_tmp0.unparse(_ctxt)
);
_tmp4.insert(
(
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_19_EMBEDDED_TYPE
&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_18_EMBEDDED_TYPE
).clone(),
_tmp1.unparse(_ctxt)
);
_tmp4.insert(
(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_20_VERSION).clone(),
(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_19_VERSION).clone(),
_tmp2.unparse(_ctxt)
);
preserves::value::Value::Dictionary(_tmp4).wrap()
@ -1769,7 +1743,7 @@ fn parse_simple_pattern_any<
_L: Copy + Into<&'a crate::gen::Language<_Value>>,
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_21_ANY { return Err(_support::ParseError::conformance_error("schema.SimplePattern::any")); }
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_20_ANY { return Err(_support::ParseError::conformance_error("schema.SimplePattern::any")); }
let _tmp0 = ();
Ok(SimplePattern::Any)
}
@ -1780,7 +1754,7 @@ fn parse_simple_pattern_atom<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_22_ATOM { return Err(_support::ParseError::conformance_error("schema.SimplePattern::atom")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_21_ATOM { return Err(_support::ParseError::conformance_error("schema.SimplePattern::atom")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.SimplePattern::atom")); }
let _tmp2 = AtomKind::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -1793,7 +1767,7 @@ fn parse_simple_pattern_embedded<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_23_EMBEDDED { return Err(_support::ParseError::conformance_error("schema.SimplePattern::embedded")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_22_EMBEDDED { return Err(_support::ParseError::conformance_error("schema.SimplePattern::embedded")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.SimplePattern::embedded")); }
let _tmp2 = SimplePattern::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -1806,7 +1780,7 @@ fn parse_simple_pattern_lit<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_24_LIT { return Err(_support::ParseError::conformance_error("schema.SimplePattern::lit")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_23_LIT { return Err(_support::ParseError::conformance_error("schema.SimplePattern::lit")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.SimplePattern::lit")); }
let _tmp2 = (&_tmp0.fields()[0]);
@ -1819,7 +1793,7 @@ fn parse_simple_pattern_seqof<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_25_SEQOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::seqof")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_24_SEQOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::seqof")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.SimplePattern::seqof")); }
let _tmp2 = SimplePattern::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -1832,7 +1806,7 @@ fn parse_simple_pattern_setof<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_26_SETOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::setof")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_25_SETOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::setof")); }
let _tmp1 = ();
if _tmp0.fields().len() < 1 { return Err(_support::ParseError::conformance_error("schema.SimplePattern::setof")); }
let _tmp2 = SimplePattern::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -1845,7 +1819,7 @@ fn parse_simple_pattern_dictof<
_Value: preserves::value::NestedValue + 'a
>(_ctxt: _L, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_27_DICTOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::dictof")); }
if _tmp0.label() != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_26_DICTOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::dictof")); }
let _tmp1 = ();
if _tmp0.fields().len() < 2 { return Err(_support::ParseError::conformance_error("schema.SimplePattern::dictof")); }
let _tmp2 = SimplePattern::parse(_ctxt, (&_tmp0.fields()[0]))?;
@ -1887,34 +1861,34 @@ impl<
> _support::Unparse<_L, _Value> for SimplePattern<_Value> {
fn unparse(&self, _ctxt: _L) -> _Value {
match self {
SimplePattern::Any => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_21_ANY).clone(),
SimplePattern::Any => (&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_20_ANY).clone(),
SimplePattern::Atom {atom_kind: _tmp0} => {
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_22_ATOM).clone()]);
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_21_ATOM).clone()]);
_tmp1.fields_vec_mut().push(_tmp0.as_ref().unparse(_ctxt));
_tmp1.finish().wrap()
},
SimplePattern::Embedded {interface: _tmp0} => {
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_23_EMBEDDED).clone()]);
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_22_EMBEDDED).clone()]);
_tmp1.fields_vec_mut().push(_tmp0.as_ref().unparse(_ctxt));
_tmp1.finish().wrap()
},
SimplePattern::Lit {value: _tmp0} => {
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_24_LIT).clone()]);
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_23_LIT).clone()]);
_tmp1.fields_vec_mut().push(_tmp0.clone());
_tmp1.finish().wrap()
},
SimplePattern::Seqof {pattern: _tmp0} => {
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_25_SEQOF).clone()]);
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_24_SEQOF).clone()]);
_tmp1.fields_vec_mut().push(_tmp0.as_ref().unparse(_ctxt));
_tmp1.finish().wrap()
},
SimplePattern::Setof {pattern: _tmp0} => {
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_26_SETOF).clone()]);
let mut _tmp1 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_25_SETOF).clone()]);
_tmp1.fields_vec_mut().push(_tmp0.as_ref().unparse(_ctxt));
_tmp1.finish().wrap()
},
SimplePattern::Dictof {key: _tmp0, value: _tmp1} => {
let mut _tmp2 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_27_DICTOF).clone()]);
let mut _tmp2 = preserves::value::Record(vec![(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_26_DICTOF).clone()]);
_tmp2.fields_vec_mut().push(_tmp0.as_ref().unparse(_ctxt));
_tmp2.fields_vec_mut().push(_tmp1.as_ref().unparse(_ctxt));
_tmp2.finish().wrap()
@ -1949,7 +1923,7 @@ impl<
_Value: preserves::value::NestedValue + 'a
> _support::Parse<_L, _Value> for Version {
fn parse(_ctxt: _L, value: &_Value) -> std::result::Result<Self, _support::ParseError> {
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_28_1 { return Err(_support::ParseError::conformance_error("schema.Version")); }
if value != &<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_27_1 { return Err(_support::ParseError::conformance_error("schema.Version")); }
let _tmp0 = ();
Ok(Version)
}
@ -1962,6 +1936,6 @@ impl<
> _support::Unparse<_L, _Value> for Version {
fn unparse(&self, _ctxt: _L) -> _Value {
let Version = self;
(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_28_1).clone()
(&<_L as Into<&'a crate::gen::Language<_Value>>>::into(_ctxt).LIT_27_1).clone()
}
}

View File

@ -136,7 +136,6 @@ impl<V: NestedValue> SimplePattern<V> {
SimplePattern::Any => Some(DynField::Simple(v.clone())),
SimplePattern::Atom { atom_kind } => match &**atom_kind {
AtomKind::Boolean => v.value().is_boolean().then(|| DynField::Simple(v.clone())),
AtomKind::Float => v.value().is_float().then(|| DynField::Simple(v.clone())),
AtomKind::Double => v.value().is_double().then(|| DynField::Simple(v.clone())),
AtomKind::SignedInteger => v
.value()

View File

@ -1,6 +1,6 @@
[package]
name = "preserves-tools"
version = "4.992.2"
version = "4.993.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
description = "Command-line utilities for working with Preserves documents."
@ -9,9 +9,9 @@ repository = "https://gitlab.com/preserves/preserves"
license = "Apache-2.0"
[dependencies]
preserves = { path = "../preserves", version = "4.992.1"}
preserves-path = { path = "../preserves-path", version = "5.992.0"}
preserves-schema = { path = "../preserves-schema", version = "5.992.0"}
preserves = { path = "../preserves", version = "4.993.0"}
preserves-path = { path = "../preserves-path", version = "5.993.0"}
preserves-schema = { path = "../preserves-schema", version = "5.993.0"}
bytes = "1.0"
clap = { version = "3", features = ["derive"] }

View File

@ -1,6 +1,6 @@
[package]
name = "preserves"
version = "4.992.2"
version = "4.993.0"
authors = ["Tony Garnock-Jones <tonyg@leastfixedpoint.com>"]
edition = "2018"
description = "Implementation of the Preserves serialization format via serde."

View File

@ -163,7 +163,7 @@ impl<'r, 'de, 'a, R: Reader<'de, IOValue>> serde::de::Deserializer<'de>
where
V: Visitor<'de>,
{
visitor.visit_f32(self.read.next_f32()?)
visitor.visit_f32(self.read.next_f64()? as f32)
}
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value>

View File

@ -81,157 +81,12 @@ mod ieee754_section_5_10_total_order_tests {
use std::cmp::Ordering::{Equal, Greater, Less};
use crate::value::{PlainValue, Value};
fn f(val: f32) -> Value<PlainValue<Dom>> {
Value::from(val)
}
fn d(val: f64) -> Value<PlainValue<Dom>> {
Value::from(val)
}
// TODO: Test cases with a few different signalling and non-signalling NaNs
#[test]
fn case32_a_1() {
assert_eq!(f(1.0).cmp(&f(2.0)), Less)
}
#[test]
fn case32_a_2() {
assert_eq!(f(-1.0).cmp(&f(1.0)), Less)
}
#[test]
fn case32_a_3() {
assert_eq!(f(0.0).cmp(&f(1.0)), Less)
}
#[test]
fn case32_a_4() {
assert_eq!(f(-1.0).cmp(&f(0.0)), Less)
}
#[test]
fn case32_a_5() {
assert_eq!(f(-1e32).cmp(&f(-1e31)), Less)
}
#[test]
fn case32_a_6() {
assert_eq!(f(-1e32).cmp(&f(1e33)), Less)
}
#[test]
fn case32_a_7() {
assert_eq!(f(std::f32::NEG_INFINITY).cmp(&f(std::f32::INFINITY)), Less)
}
#[test]
fn case32_a_8() {
assert_eq!(f(std::f32::NEG_INFINITY).cmp(&f(0.0)), Less)
}
#[test]
fn case32_a_9() {
assert_eq!(f(std::f32::NEG_INFINITY).cmp(&f(1.0)), Less)
}
#[test]
fn case32_a_10() {
assert_eq!(f(std::f32::NEG_INFINITY).cmp(&f(1e33)), Less)
}
#[test]
fn case32_a_11() {
assert_eq!(f(0.0).cmp(&f(std::f32::INFINITY)), Less)
}
#[test]
fn case32_a_12() {
assert_eq!(f(1.0).cmp(&f(std::f32::INFINITY)), Less)
}
#[test]
fn case32_a_13() {
assert_eq!(f(1e33).cmp(&f(std::f32::INFINITY)), Less)
}
#[test]
fn case32_b_1() {
assert_eq!(f(2.0).cmp(&f(1.0)), Greater)
}
#[test]
fn case32_b_2() {
assert_eq!(f(1.0).cmp(&f(-1.0)), Greater)
}
#[test]
fn case32_b_3() {
assert_eq!(f(1.0).cmp(&f(0.0)), Greater)
}
#[test]
fn case32_b_4() {
assert_eq!(f(0.0).cmp(&f(-1.0)), Greater)
}
#[test]
fn case32_b_5() {
assert_eq!(f(-1e31).cmp(&f(-1e32)), Greater)
}
#[test]
fn case32_b_6() {
assert_eq!(f(1e33).cmp(&f(-1e32)), Greater)
}
#[test]
fn case32_b_7() {
assert_eq!(
f(std::f32::INFINITY).cmp(&f(std::f32::NEG_INFINITY)),
Greater
)
}
#[test]
fn case32_b_8() {
assert_eq!(f(std::f32::INFINITY).cmp(&f(0.0)), Greater)
}
#[test]
fn case32_b_9() {
assert_eq!(f(std::f32::INFINITY).cmp(&f(1.0)), Greater)
}
#[test]
fn case32_b_10() {
assert_eq!(f(std::f32::INFINITY).cmp(&f(1e33)), Greater)
}
#[test]
fn case32_b_11() {
assert_eq!(f(0.0).cmp(&f(std::f32::NEG_INFINITY)), Greater)
}
#[test]
fn case32_b_12() {
assert_eq!(f(1.0).cmp(&f(std::f32::NEG_INFINITY)), Greater)
}
#[test]
fn case32_b_13() {
assert_eq!(f(1e33).cmp(&f(std::f32::NEG_INFINITY)), Greater)
}
#[test]
fn case32_c1() {
assert_eq!(f(-0.0).cmp(&f(0.0)), Less)
}
#[test]
fn case32_c2() {
assert_eq!(f(0.0).cmp(&f(-0.0)), Greater)
}
#[test]
fn case32_c3_1() {
assert_eq!(f(-0.0).cmp(&f(-0.0)), Equal)
}
#[test]
fn case32_c3_2() {
assert_eq!(f(0.0).cmp(&f(0.0)), Equal)
}
#[test]
fn case32_c3_3() {
assert_eq!(f(1.0).cmp(&f(1.0)), Equal)
}
#[test]
fn case32_c3_4() {
assert_eq!(f(-1.0).cmp(&f(-1.0)), Equal)
}
#[test]
fn case32_c3_5() {
assert_eq!(f(-1e32).cmp(&f(-1e32)), Equal)
}
#[test]
fn case32_c3_6() {
assert_eq!(f(1e33).cmp(&f(1e33)), Equal)
}
#[test]
fn case64_a_1() {
assert_eq!(d(1.0).cmp(&d(2.0)), Less)
@ -390,18 +245,6 @@ mod value_tests {
assert_eq!(b, VV::Boolean(false));
}
#[test]
fn float_mut() {
let mut f = VV::from(1.0f32);
assert!(f.is_f32());
*(f.as_f32_mut().unwrap()) = 123.45;
assert_eq!(f, VV::from(123.45f32));
assert_eq!(
(f.as_f32().unwrap() - 123.45f32).abs() < std::f32::EPSILON,
true
);
}
#[test]
fn double_mut() {
let mut f = VV::from(1.0);
@ -904,7 +747,7 @@ mod serde_tests {
12345,
Value::from("hi").wrap(),
colours,
12.345,
12.345f32,
12.3456789,
);
println!("== v: {:#?}", v);
@ -942,7 +785,8 @@ mod serde_tests {
0xb4, 0xb3, 0x06, 0x43, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0xb0, 0x00, 0xb0, 0x00, 0xb0, 0x02, 0x00, 0xff,
0x84, 0xb1, 0x05, 0x67, 0x72, 0x65, 0x65, 0x6e, // "green"
0xb4, 0xb3, 0x06, 0x43, 0x6f, 0x6c, 0x6f, 0x75, 0x72, 0xb0, 0x00, 0xb0, 0x02, 0x00, 0xff, 0xb0, 0x00,
0x84, 0x84, 0x87, 0x04, 0x41, 0x45, 0x85, 0x1f, // 12.345,
0x84, 0x84,
0x87, 0x08, 0x40, 0x28, 0xb0, 0xa3, 0xe0, 0x00, 0x00, 0x00, // 12.345f32
0x87, 0x08, 0x40, 0x28, 0xb0, 0xfc, 0xd3, 0x24, 0xd5, 0xa2, // 12.3456789
0x84,
];

View File

@ -92,7 +92,7 @@ impl<'a, 'w, W: Writer> serde::Serializer for &'a mut Serializer<'w, W> {
}
fn serialize_f32(self, v: f32) -> Result<Self::Ok> {
Ok(self.write.write_f32(v)?)
Ok(self.write.write_f64(v as f64)?)
}
fn serialize_f64(self, v: f64) -> Result<Self::Ok> {

View File

@ -1,7 +1,7 @@
//! Support Serde deserialization of Rust data types from Preserves *values* (not syntax).
use crate::error::{Error, ExpectedKind, Received};
use crate::value::repr::{Double, Float};
use crate::value::repr::Double;
use crate::value::{IOValue, Map, NestedValue, UnwrappedIOValue, Value};
use serde::de::{DeserializeSeed, EnumAccess, MapAccess, SeqAccess, VariantAccess, Visitor};
use serde::Deserialize;
@ -52,7 +52,6 @@ impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut Deserializer<'de> {
let v = self.input.value();
match v {
Value::Boolean(b) => visitor.visit_bool(*b),
Value::Float(Float(f)) => visitor.visit_f32(*f),
Value::Double(Double(d)) => visitor.visit_f64(*d),
Value::String(ref s) => visitor.visit_str(&s),
Value::ByteString(_) => self.deserialize_bytes(visitor),
@ -155,20 +154,14 @@ impl<'de, 'a> serde::de::Deserializer<'de> for &'a mut Deserializer<'de> {
where
V: Visitor<'de>,
{
match self.input.value().as_f64() {
Some(d) => visitor.visit_f32(d as f32),
None => visitor.visit_f32(self.input.value().to_f32()?),
}
visitor.visit_f32(self.input.value().to_f64()? as f32)
}
fn deserialize_f64<V>(self, visitor: V) -> Result<V::Value>
where
V: Visitor<'de>,
{
match self.input.value().as_f32() {
Some(f) => visitor.visit_f64(f as f64),
None => visitor.visit_f64(self.input.value().to_f64()?),
}
visitor.visit_f64(self.input.value().to_f64()?)
}
fn deserialize_char<V>(self, visitor: V) -> Result<V::Value>

View File

@ -89,7 +89,6 @@ pub use repr::Domain;
pub use repr::Double;
pub use repr::DummyValue;
pub use repr::Embeddable;
pub use repr::Float;
pub use repr::IOValue;
pub use repr::Map;
pub use repr::NestedValue;

View File

@ -308,11 +308,6 @@ impl<'de, 'src, N: NestedValue, Dec: DomainDecode<N::Embedded>, S: BinarySource<
.decode_embedded(self.source, read_annotations)?,
).wrap(),
Tag::Ieee754 => match self.varint()? {
4 => {
let mut bs = [0; 4];
self.readbytes_into(&mut bs)?;
Value::from(f32::from_bits(u32::from_be_bytes(bs))).wrap()
}
8 => {
let mut bs = [0; 8];
self.readbytes_into(&mut bs)?;
@ -573,39 +568,11 @@ impl<'de, 'src, N: NestedValue, Dec: DomainDecode<N::Embedded>, S: BinarySource<
self.next_unsigned(|n| n.to_u128())
}
fn next_f32(&mut self) -> ReaderResult<f32> {
self.try_next_nonannotation(|r, tag| {
if tag == Tag::Ieee754 {
r.skip()?;
match r.varint()? {
4 => {
let mut bs = [0; 4];
r.readbytes_into(&mut bs)?;
Ok(f32::from_bits(u32::from_be_bytes(bs)))
}
8 => {
let mut bs = [0; 8];
r.readbytes_into(&mut bs)?;
Ok(f64::from_bits(u64::from_be_bytes(bs)) as f32)
}
_ => Err(io_syntax_error("Invalid IEEE754 size"))?,
}
} else {
Err(r.expected(ExpectedKind::Float))
}
})
}
fn next_f64(&mut self) -> ReaderResult<f64> {
self.try_next_nonannotation(|r, tag| {
if tag == Tag::Ieee754 {
r.skip()?;
match r.varint()? {
4 => {
let mut bs = [0; 4];
r.readbytes_into(&mut bs)?;
Ok(f32::from_bits(u32::from_be_bytes(bs)) as f64)
}
8 => {
let mut bs = [0; 8];
r.readbytes_into(&mut bs)?;

View File

@ -208,7 +208,6 @@ impl Writer for BinaryOrderWriter {
binary_order_writer_method!(mut write_bool(v: bool) -> io::Result<()>);
binary_order_writer_method!(mut write_f32(v: f32) -> io::Result<()>);
binary_order_writer_method!(mut write_f64(v: f64) -> io::Result<()>);
binary_order_writer_method!(mut write_i8(v: i8) -> io::Result<()>);
@ -317,13 +316,6 @@ impl<W: io::Write> Writer for PackedWriter<W> {
self.write_tag(if v { Tag::True } else { Tag::False })
}
#[inline(always)]
fn write_f32(&mut self, v: f32) -> io::Result<()> {
self.write_tag(Tag::Ieee754)?;
self.write_byte(4)?;
self.write_raw_bytes(&u32::to_be_bytes(f32::to_bits(v)))
}
#[inline(always)]
fn write_f64(&mut self, v: f64) -> io::Result<()> {
self.write_tag(Tag::Ieee754)?;

View File

@ -13,7 +13,6 @@ use super::CompoundClass;
use super::DomainDecode;
use super::DomainParse;
use super::Double;
use super::Float;
use super::IOValue;
use super::IOValueDomainCodec;
use super::NestedValue;
@ -108,11 +107,6 @@ pub trait Reader<'de, N: NestedValue> {
self.demand_next(false)?.value().to_boolean()
}
/// Yields the next value, if it is a `Float`, or an error otherwise.
fn next_float(&mut self) -> ReaderResult<Float> {
Ok(self.demand_next(false)?.value().to_float()?.to_owned())
}
/// Yields the next value, if it is a `Double`, or an error otherwise.
fn next_double(&mut self) -> ReaderResult<Double> {
Ok(self.demand_next(false)?.value().to_double()?.to_owned())
@ -177,10 +171,6 @@ pub trait Reader<'de, N: NestedValue> {
fn next_u128(&mut self) -> ReaderResult<u128> {
self.demand_next(false)?.value().to_u128()
}
/// Yields the next value as an [f32], if it is a `Float`, or an error otherwise.
fn next_f32(&mut self) -> ReaderResult<f32> {
self.demand_next(false)?.value().to_f32()
}
/// Yields the next value as an [f64], if it is a `Double`, or an error otherwise.
fn next_f64(&mut self) -> ReaderResult<f64> {
self.demand_next(false)?.value().to_f64()

View File

@ -153,7 +153,6 @@ pub trait NestedValue: Sized + Debug + Clone + Eq + Hash + Ord {
#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum Value<N: NestedValue> {
Boolean(bool),
Float(Float),
Double(Double),
SignedInteger(SignedInteger),
String(String),
@ -178,7 +177,6 @@ pub enum ValueClass {
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub enum AtomClass {
Boolean,
Float,
Double,
SignedInteger,
String,
@ -195,10 +193,6 @@ pub enum CompoundClass {
Dictionary,
}
/// Single-precision IEEE 754 Value
#[derive(Clone, Copy, Debug)]
pub struct Float(pub f32);
/// Double-precision IEEE 754 Value
#[derive(Clone, Copy, Debug)]
pub struct Double(pub f64);
@ -262,52 +256,6 @@ impl<N> Record<N> {
}
}
impl From<f32> for Float {
fn from(v: f32) -> Self {
Float(v)
}
}
impl From<Float> for f32 {
fn from(v: Float) -> Self {
v.0
}
}
impl Hash for Float {
fn hash<H: Hasher>(&self, state: &mut H) {
self.0.to_bits().hash(state);
}
}
impl PartialEq for Float {
fn eq(&self, other: &Self) -> bool {
self.0.to_bits() == other.0.to_bits()
}
}
impl Ord for Float {
fn cmp(&self, other: &Self) -> Ordering {
let mut a: u32 = self.0.to_bits();
let mut b: u32 = other.0.to_bits();
if a & 0x8000_0000 != 0 {
a ^= 0x7fff_ffff;
}
if b & 0x8000_0000 != 0 {
b ^= 0x7fff_ffff;
}
(a as i32).cmp(&(b as i32))
}
}
impl PartialOrd for Float {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Eq for Float {}
impl From<f64> for Double {
fn from(v: f64) -> Self {
Double(v)
@ -365,21 +313,6 @@ impl<N: NestedValue> From<&bool> for Value<N> {
}
}
impl<N: NestedValue> From<f32> for Value<N> {
fn from(v: f32) -> Self {
Value::Float(Float::from(v))
}
}
impl<N: NestedValue> From<&f32> for Value<N> {
fn from(v: &f32) -> Self {
Value::Float(Float::from(*v))
}
}
impl<N: NestedValue> From<&Float> for Value<N> {
fn from(v: &Float) -> Self {
Value::Float(v.clone())
}
}
impl<N: NestedValue> From<f64> for Value<N> {
fn from(v: f64) -> Self {
Value::Double(Double::from(v))
@ -542,7 +475,6 @@ impl<N: NestedValue> Value<N> {
fn value_class(&self) -> ValueClass {
match self {
Value::Boolean(_) => ValueClass::Atomic(AtomClass::Boolean),
Value::Float(_) => ValueClass::Atomic(AtomClass::Float),
Value::Double(_) => ValueClass::Atomic(AtomClass::Double),
Value::SignedInteger(_) => ValueClass::Atomic(AtomClass::SignedInteger),
Value::String(_) => ValueClass::Atomic(AtomClass::String),
@ -564,7 +496,6 @@ impl<N: NestedValue> Value<N> {
pub fn children(&self) -> Vec<N> {
match self {
Value::Boolean(_)
| Value::Float(_)
| Value::Double(_)
| Value::SignedInteger(_)
| Value::String(_)
@ -619,63 +550,6 @@ impl<N: NestedValue> Value<N> {
.ok_or_else(|| self.expected(ExpectedKind::Boolean))
}
/// True iff this is a [Value::Float].
#[inline(always)]
pub fn is_float(&self) -> bool {
self.as_float().is_some()
}
/// Yields `Some` iff this is a [Value::Float].
#[inline(always)]
pub fn as_float(&self) -> Option<&Float> {
if let Value::Float(f) = self {
Some(f)
} else {
None
}
}
/// Retrieve a mutable reference to the contained [Float] value iff this is a [Value::Float].
#[inline(always)]
pub fn as_float_mut(&mut self) -> Option<&mut Float> {
if let Value::Float(f) = self {
Some(f)
} else {
None
}
}
/// Yields `Ok` iff this is a [Value::Float]; else [Error::Expected].
#[inline(always)]
pub fn to_float(&self) -> Result<&Float, Error> {
self.as_float()
.ok_or_else(|| self.expected(ExpectedKind::Float))
}
/// As [Self::is_float].
#[inline(always)]
pub fn is_f32(&self) -> bool {
self.is_float()
}
/// As [Self::as_float], but yields [f32] instead of [Float].
#[inline(always)]
pub fn as_f32(&self) -> Option<f32> {
self.as_float().map(|f| f.0)
}
/// As [Self::as_float_mut], but [f32] instead of [Float].
#[inline(always)]
pub fn as_f32_mut(&mut self) -> Option<&mut f32> {
self.as_float_mut().map(|f| &mut f.0)
}
/// As [Self::to_float], but with [f32] instead of [Float].
#[inline(always)]
pub fn to_f32(&self) -> Result<f32, Error> {
self.to_float().map(|f| f.0)
}
/// True iff this is a [Value::Double].
#[inline(always)]
pub fn is_double(&self) -> bool {
@ -1428,7 +1302,6 @@ impl<N: NestedValue> Value<N> {
pub fn strip_annotations<M: NestedValue<Embedded = N::Embedded>>(&self) -> Value<M> {
match self {
Value::Boolean(b) => Value::Boolean(*b),
Value::Float(f) => Value::Float(f.clone()),
Value::Double(d) => Value::Double(d.clone()),
Value::SignedInteger(n) => Value::SignedInteger(n.clone()),
Value::String(s) => Value::String(s.clone()),
@ -1460,7 +1333,6 @@ impl<N: NestedValue> Value<N> {
{
Ok(match self {
Value::Boolean(b) => Value::Boolean(*b),
Value::Float(f) => Value::Float(f.clone()),
Value::Double(d) => Value::Double(d.clone()),
Value::SignedInteger(n) => Value::SignedInteger(n.clone()),
Value::String(s) => Value::String(s.clone()),
@ -1498,7 +1370,6 @@ impl<N: NestedValue> Value<N> {
{
match self {
Value::Boolean(_)
| Value::Float(_)
| Value::Double(_)
| Value::SignedInteger(_)
| Value::String(_)

View File

@ -92,7 +92,7 @@ impl serde::Serializer for Serializer {
}
fn serialize_f32(self, v: f32) -> Result<Self::Ok> {
Ok(Value::from(v).wrap())
Ok(Value::from(v as f64).wrap())
}
fn serialize_f64(self, v: f64) -> Result<Self::Ok> {

View File

@ -206,25 +206,19 @@ impl<'de, 'src, N: NestedValue, Dec: DomainParse<N::Embedded>, S: BinarySource<'
}
}
fn read_hex_float(&mut self, bytecount: usize) -> io::Result<N> {
fn read_hex_float(&mut self) -> io::Result<N> {
if self.next_byte()? != b'"' {
return Err(io_syntax_error(
"Missing open-double-quote in hex-encoded floating-point number",
));
}
let bs = self.read_hex_binary()?;
if bs.len() != bytecount {
if bs.len() != 8 {
return Err(io_syntax_error(
"Incorrect number of bytes in hex-encoded floating-point number",
));
}
match bytecount {
4 => Ok(Value::from(f32::from_bits(u32::from_be_bytes(bs.try_into().unwrap()))).wrap()),
8 => Ok(Value::from(f64::from_bits(u64::from_be_bytes(bs.try_into().unwrap()))).wrap()),
_ => Err(io_syntax_error(
"Unsupported byte count in hex-encoded floating-point number",
)),
}
Ok(Value::from(f64::from_bits(u64::from_be_bytes(bs.try_into().unwrap()))).wrap())
}
fn read_stringlike<X, H, R>(
@ -421,7 +415,7 @@ impl<'de, 'src, N: NestedValue, Dec: DomainParse<N::Embedded>, S: BinarySource<'
fn read_raw_symbol_or_number(&mut self, mut bs: Vec<u8>) -> io::Result<N> {
lazy_static! {
static ref NUMBER_RE: regex::Regex =
regex::Regex::new(r"^([-+]?\d+)(((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+))([fF]?))?$")
regex::Regex::new(r"^([-+]?\d+)((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+))?$")
.unwrap();
}
while !self.delimiter_follows()? {
@ -432,30 +426,9 @@ impl<'de, 'src, N: NestedValue, Dec: DomainParse<N::Embedded>, S: BinarySource<'
None => Ok(N::symbol(&s)),
Some(m) => match m.get(2) {
None => Ok(N::new(s.parse::<BigInt>().map_err(|_| {
io_syntax_error(&format!("Invalid signed-integer number: {:?}", s))
})?)),
Some(_) => {
if let Some(maybe_f) = m.get(7) {
let s = m[1].to_owned() + &m[3];
if maybe_f.range().is_empty() {
Ok(N::new(s.parse::<f64>().map_err(|_| {
io_syntax_error(&format!(
"Invalid double-precision number: {:?}",
s
))
})?))
} else {
Ok(N::new(s.parse::<f32>().map_err(|_| {
io_syntax_error(&format!(
"Invalid single-precision number: {:?}",
s
))
})?))
}
} else {
panic!("Internal error: cannot analyze number {:?}", s)
}
}
io_syntax_error(&format!("Invalid signed-integer number: {:?}", s))})?)),
Some(_) => Ok(N::new(s.parse::<f64>().map_err(|_| {
io_syntax_error(&format!("Invalid double-precision number: {:?}", s))})?)),
},
}
}
@ -535,8 +508,7 @@ impl<'de, 'src, N: NestedValue, Dec: DomainParse<N::Embedded>, S: BinarySource<'
b'"' => self.read_literal_binary()?,
b'x' => match self.next_byte()? {
b'"' => N::new(&self.read_hex_binary()?[..]),
b'f' => self.read_hex_float(4)?,
b'd' => self.read_hex_float(8)?,
b'd' => self.read_hex_float()?,
_ => return Err(io_syntax_error("Invalid #x syntax")),
},
b'[' => self.read_base64_binary()?,

View File

@ -257,19 +257,6 @@ impl<W: io::Write> Writer for TextWriter<W> {
write!(self.w, "{}", if v { "#t" } else { "#f" })
}
fn write_f32(&mut self, v: f32) -> io::Result<()> {
if v.is_nan() || v.is_infinite() {
write!(
self.w,
"#xf\"{}\"",
HexFormatter::Packed.encode(&u32::to_be_bytes(f32::to_bits(v)))
)
} else {
dtoa::write(&mut *self.w, v)?;
write!(self.w, "f")
}
}
fn write_f64(&mut self, v: f64) -> io::Result<()> {
if v.is_nan() || v.is_infinite() {
write!(

View File

@ -2,7 +2,7 @@
//! each specific transfer syntax.
use super::boundary as B;
use super::repr::{Double, Float, NestedValue, Value};
use super::repr::{Double, NestedValue, Value};
use super::signed_integer::SignedIntegerRepr;
use super::DomainEncode;
use num::bigint::BigInt;
@ -39,8 +39,6 @@ pub trait Writer: Sized {
#[doc(hidden)]
fn write_bool(&mut self, v: bool) -> io::Result<()>;
#[doc(hidden)]
fn write_f32(&mut self, v: f32) -> io::Result<()>;
#[doc(hidden)]
fn write_f64(&mut self, v: f64) -> io::Result<()>;
@ -141,7 +139,6 @@ pub trait Writer: Sized {
) -> io::Result<()> {
match v {
Value::Boolean(b) => self.write_bool(*b),
Value::Float(Float(f)) => self.write_f32(*f),
Value::Double(Double(d)) => self.write_f64(*d),
Value::SignedInteger(n) => match n.repr() {
SignedIntegerRepr::I128(i) => self.write_i128(*i),

View File

@ -1,5 +1,5 @@
´³schema·³version°³ definitions·³Axis´³orµµ±values´³rec´³lit³values„´³tupleµ„„„„µ± descendants´³rec´³lit³ descendants„´³tupleµ„„„„µ±at´³rec´³lit³at„´³tupleµ´³named³key³any„„„„„µ±label´³rec´³lit³label„´³tupleµ„„„„µ±keys´³rec´³lit³keys„´³tupleµ„„„„µ±length´³rec´³lit³length„´³tupleµ„„„„µ± annotations´³rec´³lit³ annotations„´³tupleµ„„„„µ±embedded´³rec´³lit³embedded„´³tupleµ„„„„µ±parse´³rec´³lit³parse„´³tupleµ´³named³module´³seqof´³atom³Symbol„„„´³named³name´³atom³Symbol„„„„„„µ±unparse´³rec´³lit³unparse„´³tupleµ´³named³module´³seqof´³atom³Symbol„„„´³named³name´³atom³Symbol„„„„„„„„³Step´³orµµ±Axis´³refµ„³Axis„„µ±Filter´³refµ„³Filter„„µ±Function´³refµ„³Function„„„„³Filter´³orµµ±nop´³rec´³lit³nop„´³tupleµ„„„„µ±compare´³rec´³lit³compare„´³tupleµ´³named³op´³refµ„³
Comparison„„´³named³literal³any„„„„„µ±regex´³rec´³lit³regex„´³tupleµ´³named³regex´³atom³String„„„„„„µ±test´³rec´³lit³test„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±real´³rec´³lit³real„´³tupleµ„„„„µ±int´³rec´³lit³int„´³tupleµ„„„„µ±kind´³rec´³lit³kind„´³tupleµ´³named³kind´³refµ„³ ValueKind„„„„„„„„³Function´³rec´³lit³count„´³tupleµ´³named³selector´³refµ„³Selector„„„„„³Selector´³seqof´³refµ„³Step„„³ Predicate´³orµµ±Selector´³refµ„³Selector„„µ±not´³rec´³lit³not„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±or´³rec´³lit³or„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„µ±and´³rec´³lit³and„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„„„³ ValueKind´³orµµ±Boolean´³lit³Boolean„„µ±Float´³lit³Float„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
Comparison„„´³named³literal³any„„„„„µ±regex´³rec´³lit³regex„´³tupleµ´³named³regex´³atom³String„„„„„„µ±test´³rec´³lit³test„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±real´³rec´³lit³real„´³tupleµ„„„„µ±int´³rec´³lit³int„´³tupleµ„„„„µ±kind´³rec´³lit³kind„´³tupleµ´³named³kind´³refµ„³ ValueKind„„„„„„„„³Function´³rec´³lit³count„´³tupleµ´³named³selector´³refµ„³Selector„„„„„³Selector´³seqof´³refµ„³Step„„³ Predicate´³orµµ±Selector´³refµ„³Selector„„µ±not´³rec´³lit³not„´³tupleµ´³named³pred´³refµ„³ Predicate„„„„„„µ±or´³rec´³lit³or„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„µ±and´³rec´³lit³and„´³tupleµ´³named³preds´³seqof´³refµ„³ Predicate„„„„„„„„„³ ValueKind´³orµµ±Boolean´³lit³Boolean„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
ByteString´³lit³
ByteString„„µ±Symbol´³lit³Symbol„„µ±Record´³lit³Record„„µ±Sequence´³lit³Sequence„„µ±Set´³lit³Set„„µ±
Dictionary´³lit³

View File

@ -37,7 +37,7 @@ Filter =
Comparison = =eq / =ne / =lt / =ge / =gt / =le .
ValueKind =
/ =Boolean / =Float / =Double / =SignedInteger / =String / =ByteString / =Symbol
/ =Boolean / =Double / =SignedInteger / =String / =ByteString / =Symbol
/ =Record / =Sequence / =Set / =Dictionary
/ =Embedded
.

View File

@ -333,8 +333,8 @@ number; use `Double` and `SignedInteger` to disambiguate. If it
matches `SymbolOrNumber` but not `Number`, it's a "bare" `Symbol`.
SymbolOrNumber: ^[-a-zA-Z0-9~!$%^&*?_=+/.]+$
Number: ^([-+]?\d+)(((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+)))?$
Double: ^([-+]?\d+)(((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+)))$
Number: ^([-+]?\d+)((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+))?$
Double: ^([-+]?\d+)((\.\d+([eE][-+]?\d+)?)|([eE][-+]?\d+))$
SignedInteger: ^([-+]?\d+)$
When printing, if a symbol matches both `SymbolOrNumber` and `Number` or

View File

@ -1,6 +1,6 @@
´³schema·³version°³ definitions·³Ref´³rec´³lit³ref„´³tupleµ´³named³module´³refµ„³
ModulePath„„´³named³name´³atom³Symbol„„„„„³Bundle´³rec´³lit³bundle„´³tupleµ´³named³modules´³refµ„³Modules„„„„„³Schema´³rec´³lit³schema„´³tupleµ´³dict·³version´³named³version´³refµ„³Version„„³ definitions´³named³ definitions´³refµ„³ Definitions„„³ embeddedType´³named³ embeddedType´³refµ„³EmbeddedTypeName„„„„„„„³Binding´³rec´³lit³named„´³tupleµ´³named³name´³atom³Symbol„„´³named³pattern´³refµ„³ SimplePattern„„„„„³Modules´³dictof´³refµ„³
ModulePath„´³refµ„³Schema„„³Pattern´³orµµ± SimplePattern´³refµ„³ SimplePattern„„µ±CompoundPattern´³refµ„³CompoundPattern„„„„³Version´³lit°„³AtomKind´³orµµ±Boolean´³lit³Boolean„„µ±Float´³lit³Float„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
ModulePath„´³refµ„³Schema„„³Pattern´³orµµ± SimplePattern´³refµ„³ SimplePattern„„µ±CompoundPattern´³refµ„³CompoundPattern„„„„³Version´³lit°„³AtomKind´³orµµ±Boolean´³lit³Boolean„„µ±Double´³lit³Double„„µ± SignedInteger´³lit³ SignedInteger„„µ±String´³lit³String„„µ±
ByteString´³lit³
ByteString„„µ±Symbol´³lit³Symbol„„„„³
Definition´³orµµ±or´³rec´³lit³or„´³tupleµ´³ tuplePrefixµ´³named³pattern0´³refµ„³NamedAlternative„„´³named³pattern1´³refµ„³NamedAlternative„„„´³named³patternN´³seqof´³refµ„³NamedAlternative„„„„„„„„µ±and´³rec´³lit³and„´³tupleµ´³ tuplePrefixµ´³named³pattern0´³refµ„³ NamedPattern„„´³named³pattern1´³refµ„³ NamedPattern„„„´³named³patternN´³seqof´³refµ„³ NamedPattern„„„„„„„„µ±Pattern´³refµ„³Pattern„„„„³

View File

@ -38,7 +38,7 @@ SimplePattern =
# any
/ =any
# special builtins: bool, float, double, int, string, bytes, symbol
# special builtins: bool, double, int, string, bytes, symbol
/ <atom @atomKind AtomKind>
# matches an embedded value in the input: #!p
@ -79,7 +79,7 @@ CompoundPattern =
DictionaryEntries = { any: NamedSimplePattern ...:... }.
AtomKind = =Boolean / =Float / =Double / =SignedInteger / =String / =ByteString / =Symbol .
AtomKind = =Boolean / =Double / =SignedInteger / =String / =ByteString / =Symbol .
NamedAlternative = [@variantLabel string @pattern Pattern].

Binary file not shown.

View File

@ -119,32 +119,6 @@
double15: @"-sNaN" <Test #x"8708fff8000000000111" #xd"fff8000000000111">
double16: @"+sNaN" <Test #x"87087ff8000000000001" #xd"7ff8000000000001">
double17: @"+sNaN" <Test #x"87087ff8000000000111" #xd"7ff8000000000111">
float0: <Test #x"870400000000" 0.0f>
float+0: <Test #x"870400000000" +0.0f>
float-0: <Test #x"870480000000" -0.0f>
float1: <Test #x"87043f800000" 1.0f>
float1u: <Test #x"87043f800000" 1.0F>
float1a: <Test #x"87043f800000" 1e0f>
float1b: <Test #x"87043f800000" 1.0e0f>
float1c: <Test #x"87043f800000" 1e-0f>
float1d: <Test #x"87043f800000" 1.0e-0f>
float1e: <Test #x"87043f800000" 1e+0f>
float1f: <Test #x"87043f800000" 1.0e+0f>
float2: <Test #x"870412345678" #xf"12 34 56 78">
float3: @"Fewer than 8 digits" <ParseError "#xf\"123456\"">
float4: @"More than 8 digits" <ParseError "#xf\"123456789a\"">
float5: @"Invalid chars" <ParseError "#xf\"12zz5678\"">
float6: @"Positive infinity" <Test #x"87047f800000" #xf"7f800000">
float7: @"Negative infinity" <Test #x"8704ff800000" #xf"ff800000">
float8: @"+sNaN" <Test #x"87047f800001" #xf"7f800001">
float9: @"+sNaN" <Test #x"87047f800111" #xf"7f800111">
float10: @"-sNaN" <Test #x"8704ff800001" #xf"ff800001">
float11: @"-sNaN" <Test #x"8704ff800111" #xf"ff800111">
float12: @"Bad spacing" <ParseError "#xf\"12345 678\"">
float13: @"+qNaN" <Test #x"87047fc00001" #xf"7fc00001">
float14: @"+qNaN" <Test #x"87047fc00111" #xf"7fc00111">
float15: @"-qNaN" <Test #x"8704ffc00001" #xf"ffc00001">
float16: @"-qNaN" <Test #x"8704ffc00111" #xf"ffc00111">
int-98765432109876543210987654321098765432109: <Test #x"b012feddc125aed4226c770369269596ce3f0ad3" -98765432109876543210987654321098765432109>
int-12345678123456781234567812345678: <Test #x"b00eff642cf6684f11d1dad08c4a10b2" -12345678123456781234567812345678>
int-1234567812345678123456781234567: <Test #x"b00df06ae570d4b4fb62ae746dce79" -1234567812345678123456781234567>