Better name

This commit is contained in:
Tony Garnock-Jones 2021-09-15 15:14:36 +02:00
parent 28249b19f7
commit 997bea2836
9 changed files with 139 additions and 142 deletions

View File

@ -184,11 +184,11 @@ impl<'m, 'b> ModuleContext<'m, 'b> {
// ^ TODO: should the "false" be configurable?
}
pub fn literals_generic_decls(&self) -> Item {
pub fn generic_decls(&self) -> Item {
item(anglebrackets!["_Value: preserves::value::NestedValue"])
}
pub fn literals_generic_decls_with_defaults(&self) -> Item {
pub fn generic_decls_with_defaults(&self) -> Item {
item(anglebrackets![
seq!["_Value: preserves::value::NestedValue = ",
if self.schema.embedded_type == EmbeddedTypeName::False {
@ -198,16 +198,16 @@ impl<'m, 'b> ModuleContext<'m, 'b> {
}]])
}
pub fn literals_generic_arg(&self) -> Item {
pub fn generic_arg(&self) -> Item {
item("<_Value>")
}
pub fn literals_type(&self) -> Item {
item(seq![self.literals_base_type(), self.literals_generic_arg()])
pub fn language_type(&self) -> Item {
item(seq![self.language_base_type(), self.generic_arg()])
}
pub fn literals_base_type(&self) -> Item {
item(format!("{}::Literals", self.bundle.config.fully_qualified_module_prefix))
pub fn language_base_type(&self) -> Item {
item(format!("{}::Language", self.bundle.config.fully_qualified_module_prefix))
}
pub fn extract(&mut self) -> Vec<Item> {

View File

@ -7,7 +7,7 @@ pub mod unparsers;
use crate::*;
use crate::compiler::context::*;
use crate::gen::Literals;
use crate::gen::Language;
use crate::gen::schema;
use crate::gen::schema::*;
use crate::syntax::block::{Formatter, Item};
@ -75,9 +75,9 @@ impl CompilerConfig {
let mut src = IOBinarySource::new(&mut f);
let mut reader = src.packed_iovalues();
let blob = reader.demand_next(false)?;
let literals = Literals::default();
let language = Language::default();
if let Ok(s) = literals.parse(&blob) {
if let Ok(s) = language.parse(&blob) {
let prefix = i.file_stem().ok_or_else(
|| io::Error::new(io::ErrorKind::InvalidData,
format!("Bad schema file stem: {:?}", i)))?
@ -88,7 +88,7 @@ impl CompilerConfig {
continue;
}
if let Ok(Bundle { modules }) = literals.parse(&blob) {
if let Ok(Bundle { modules }) = language.parse(&blob) {
for (ModulePath(k), v) in modules.0 {
self.bundle.insert(k, v);
}
@ -257,16 +257,16 @@ pub fn compile(config: &CompilerConfig) -> io::Result<()> {
lines.push("#[allow(non_snake_case)]".to_owned());
lines.push(Formatter::to_string(item(seq![
"pub struct Literals", anglebrackets!["N: preserves::value::NestedValue"], " ",
"pub struct Language", anglebrackets!["N: preserves::value::NestedValue"], " ",
vertical(false, braces(b.literals.iter().map(
|(value, name)| item(format!("pub {}: N /* {:?} */", name, value))).collect()))
])));
lines.push("".to_owned());
lines.push(Formatter::to_string(item(seq![
"impl", anglebrackets!["N: preserves::value::NestedValue"],
" Default for Literals<N> ", block![
" Default for Language<N> ", block![
seq!["fn default() -> Self ", block![
seq!["Literals ", vertical(false, braces(b.literals.iter().map(|(value, name)| {
seq!["Language ", vertical(false, braces(b.literals.iter().map(|(value, name)| {
let bs = preserves::value::PackedWriter::encode_iovalue(&value).unwrap();
item(format!("{}: /* {:?} */ _support::decode_lit(&vec!{:?}).unwrap()",
name,

View File

@ -43,8 +43,8 @@ pub fn gen_definition_parser(m: &mut ModuleContext, n: &str, d: &Definition) {
let dest = pattern_parser(&mut ctxt, pat, "value", None, &mut body);
let dest = dest.as_ref().map(String::as_str);
construct(&ctxt, ctorname, false, &pattern_type(pat), dest, &mut body);
item(seq!["fn ", fname.clone(), ctxt.m.literals_generic_decls(),
"(_ctxt: &", ctxt.m.literals_type(), ", value: &", ctxt.m.any_type(), ") -> ",
item(seq!["fn ", fname.clone(), ctxt.m.generic_decls(),
"(_ctxt: &", ctxt.m.language_type(), ", value: &", ctxt.m.any_type(), ") -> ",
"std::result::Result<",
names::render_constructor(n), ty.generic_arg(ctxt.m),
", _support::ParseError> ",
@ -69,15 +69,15 @@ pub fn gen_definition_parser(m: &mut ModuleContext, n: &str, d: &Definition) {
}
}
item(seq!["impl", ctxt.m.literals_generic_decls(),
" _support::Parse", anglebrackets![ctxt.m.literals_type(),
item(seq!["impl", ctxt.m.generic_decls(),
" _support::Parse", anglebrackets![ctxt.m.language_type(),
ctxt.m.any_type()], " for ",
names::render_constructor(n), ty.generic_arg(ctxt.m), " ",
block![
seq!["fn parse<'a, _LL: Into<&'a ", ctxt.m.literals_type(), ">>",
seq!["fn parse<'a, _LL: Into<&'a ", ctxt.m.language_type(), ">>",
"(_ctxt: _LL, value: &", ctxt.m.any_type(), ") ",
" -> std::result::Result<Self, _support::ParseError>",
" where ", ctxt.m.literals_type(), ": 'a ",
" where ", ctxt.m.language_type(), ": 'a ",
codeblock(body)]]])
});
}

View File

@ -267,7 +267,7 @@ impl TSimple {
impl TDefinition {
pub fn generic_decl(&self, ctxt: &ModuleContext) -> Item {
if self.has_embedded(ctxt.bundle) {
ctxt.literals_generic_decls()
ctxt.generic_decls()
} else {
item("")
}
@ -275,7 +275,7 @@ impl TDefinition {
pub fn generic_decl_with_defaults(&self, ctxt: &ModuleContext) -> Item {
if self.has_embedded(ctxt.bundle) {
ctxt.literals_generic_decls_with_defaults()
ctxt.generic_decls_with_defaults()
} else {
item("")
}
@ -283,7 +283,7 @@ impl TDefinition {
pub fn generic_arg(&self, ctxt: &ModuleContext) -> Item {
if self.has_embedded(ctxt.bundle) {
ctxt.literals_generic_arg()
ctxt.generic_arg()
} else {
item("")
}

View File

@ -97,14 +97,14 @@ pub fn gen_definition_unparser(m: &mut ModuleContext, n: &str, d: &Definition) {
}
}
item(seq!["impl", ctxt.m.literals_generic_decls(),
" _support::Unparse", anglebrackets![ctxt.m.literals_type(),
item(seq!["impl", ctxt.m.generic_decls(),
" _support::Unparse", anglebrackets![ctxt.m.language_type(),
ctxt.m.any_type()], " for ",
names::render_constructor(n), ty.generic_arg(ctxt.m), " ",
block![
seq!["fn unparse<'a, _LL: Into<&'a ", ctxt.m.literals_type(), ">>",
seq!["fn unparse<'a, _LL: Into<&'a ", ctxt.m.language_type(), ">>",
"(&self, _ctxt: _LL) -> ", ctxt.m.any_type(),
" where ", ctxt.m.literals_type(), ": 'a ",
" where ", ctxt.m.language_type(), ": 'a ",
block(body)]]])
});
}

View File

@ -4,7 +4,7 @@ use crate::support as _support;
use _support::preserves;
#[allow(non_snake_case)]
pub struct Literals<N: preserves::value::NestedValue> {
pub struct Language<N: preserves::value::NestedValue> {
pub LIT_15_FALSE: N /* #f */,
pub LIT_28_1: N /* 1 */,
pub LIT_0_BOOLEAN: N /* Boolean */,
@ -36,9 +36,9 @@ pub struct Literals<N: preserves::value::NestedValue> {
pub LIT_20_VERSION: N /* version */
}
impl<N: preserves::value::NestedValue> Default for Literals<N> {
impl<N: preserves::value::NestedValue> Default for Language<N> {
fn default() -> Self {
Literals {
Language {
LIT_15_FALSE: /* #f */ _support::decode_lit(&vec![128]).unwrap(),
LIT_28_1: /* 1 */ _support::decode_lit(&vec![145]).unwrap(),
LIT_0_BOOLEAN: /* Boolean */ _support::decode_lit(&vec![179, 7, 66, 111, 111, 108, 101, 97, 110]).unwrap(),

View File

@ -121,50 +121,50 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_atom_kind_boolean<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_boolean<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_0_BOOLEAN { return Err(_support::ParseError::conformance_error("schema.AtomKind::Boolean")); }
let _tmp0 = ();
Ok(AtomKind::Boolean)
}
fn parse_atom_kind_float<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_float<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_1_FLOAT { return Err(_support::ParseError::conformance_error("schema.AtomKind::Float")); }
let _tmp0 = ();
Ok(AtomKind::Float)
}
fn parse_atom_kind_double<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_double<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_2_DOUBLE { return Err(_support::ParseError::conformance_error("schema.AtomKind::Double")); }
let _tmp0 = ();
Ok(AtomKind::Double)
}
fn parse_atom_kind_signed_integer<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_signed_integer<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_3_SIGNED_INTEGER { return Err(_support::ParseError::conformance_error("schema.AtomKind::SignedInteger")); }
let _tmp0 = ();
Ok(AtomKind::SignedInteger)
}
fn parse_atom_kind_string<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_string<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_4_STRING { return Err(_support::ParseError::conformance_error("schema.AtomKind::String")); }
let _tmp0 = ();
Ok(AtomKind::String)
}
fn parse_atom_kind_byte_string<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_byte_string<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_5_BYTE_STRING { return Err(_support::ParseError::conformance_error("schema.AtomKind::ByteString")); }
let _tmp0 = ();
Ok(AtomKind::ByteString)
}
fn parse_atom_kind_symbol<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
fn parse_atom_kind_symbol<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<AtomKind, _support::ParseError> {
if value != &_ctxt.LIT_6_SYMBOL { return Err(_support::ParseError::conformance_error("schema.AtomKind::Symbol")); }
let _tmp0 = ();
Ok(AtomKind::Symbol)
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for AtomKind {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for AtomKind {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
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); }
@ -177,8 +177,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for AtomKind {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for AtomKind {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
match self {
AtomKind::Boolean => (&_ctxt.LIT_0_BOOLEAN).clone(),
@ -225,8 +225,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Binding<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Binding<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_7_NAMED { return Err(_support::ParseError::conformance_error("schema.Binding")); }
@ -238,8 +238,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Binding<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Binding<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let Binding {name: _tmp0, pattern: _tmp1} = self;
{
@ -280,8 +280,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Bundle<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Bundle<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_8_BUNDLE { return Err(_support::ParseError::conformance_error("schema.Bundle")); }
@ -292,8 +292,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Bundle<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Bundle<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let Bundle {modules: _tmp0} = self;
{
@ -439,7 +439,7 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_compound_pattern_rec<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
fn parse_compound_pattern_rec<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_9_REC { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::rec")); }
let _tmp1 = ();
@ -449,7 +449,7 @@ fn parse_compound_pattern_rec<_Value: preserves::value::NestedValue>(_ctxt: &cra
Ok(CompoundPattern::Rec {label: std::boxed::Box::new(_tmp2), fields: std::boxed::Box::new(_tmp3)})
}
fn parse_compound_pattern_tuple<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
fn parse_compound_pattern_tuple<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_10_TUPLE { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuple")); }
let _tmp1 = ();
@ -460,7 +460,7 @@ fn parse_compound_pattern_tuple<_Value: preserves::value::NestedValue>(_ctxt: &c
Ok(CompoundPattern::Tuple {patterns: _tmp2})
}
fn parse_compound_pattern_tuple_prefix<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
fn parse_compound_pattern_tuple_prefix<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_11_TUPLE_PREFIX { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::tuplePrefix")); }
let _tmp1 = ();
@ -472,7 +472,7 @@ fn parse_compound_pattern_tuple_prefix<_Value: preserves::value::NestedValue>(_c
Ok(CompoundPattern::TuplePrefix {fixed: _tmp2, variable: std::boxed::Box::new(_tmp6)})
}
fn parse_compound_pattern_dict<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
fn parse_compound_pattern_dict<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<CompoundPattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_12_DICT { return Err(_support::ParseError::conformance_error("schema.CompoundPattern::dict")); }
let _tmp1 = ();
@ -481,8 +481,8 @@ fn parse_compound_pattern_dict<_Value: preserves::value::NestedValue>(_ctxt: &cr
Ok(CompoundPattern::Dict {entries: std::boxed::Box::new(_tmp2)})
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for CompoundPattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for CompoundPattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_compound_pattern_rec(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_compound_pattern_tuple(_ctxt, value) { return Ok(r); }
@ -492,8 +492,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for CompoundPattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for CompoundPattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
match self {
CompoundPattern::Rec {label: _tmp0, fields: _tmp1} => {
@ -644,7 +644,7 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_definition_or<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
fn parse_definition_or<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_13_OR { return Err(_support::ParseError::conformance_error("schema.Definition::or")); }
let _tmp1 = ();
@ -662,7 +662,7 @@ fn parse_definition_or<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen
})
}
fn parse_definition_and<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
fn parse_definition_and<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_14_AND { return Err(_support::ParseError::conformance_error("schema.Definition::and")); }
let _tmp1 = ();
@ -680,13 +680,13 @@ fn parse_definition_and<_Value: preserves::value::NestedValue>(_ctxt: &crate::ge
})
}
fn parse_definition_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
fn parse_definition_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Definition<_Value>, _support::ParseError> {
let _tmp0 = Pattern::parse(_ctxt, value)?;
Ok(Definition::Pattern(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Definition<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Definition<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_definition_or(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_definition_and(_ctxt, value) { return Ok(r); }
@ -695,8 +695,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Definition<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Definition<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
match self {
Definition::Or {pattern_0: _tmp0, pattern_1: _tmp1, pattern_n: _tmp2} => {
@ -754,8 +754,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Definitions<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Definitions<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -767,8 +767,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Definitions<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Definitions<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let Definitions(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (preserves::value::Value::symbol(_tmp1).wrap(), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -799,8 +799,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for DictionaryEntries<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for DictionaryEntries<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -812,8 +812,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for DictionaryEntries<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for DictionaryEntries<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let DictionaryEntries(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (_tmp1.clone(), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -854,19 +854,19 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_embedded_type_name_ref<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
fn parse_embedded_type_name_ref<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
let _tmp0 = Ref::parse(_ctxt, value)?;
Ok(EmbeddedTypeName::Ref(std::boxed::Box::new(_tmp0)))
}
fn parse_embedded_type_name_false<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
fn parse_embedded_type_name_false<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<EmbeddedTypeName, _support::ParseError> {
if value != &_ctxt.LIT_15_FALSE { return Err(_support::ParseError::conformance_error("schema.EmbeddedTypeName::false")); }
let _tmp0 = ();
Ok(EmbeddedTypeName::False)
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for EmbeddedTypeName {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for EmbeddedTypeName {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_embedded_type_name_ref(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_embedded_type_name_false(_ctxt, value) { return Ok(r); }
@ -874,8 +874,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for EmbeddedTypeName {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for EmbeddedTypeName {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
match self {
EmbeddedTypeName::Ref(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -905,8 +905,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for ModulePath {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for ModulePath {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let _tmp1 = value.value().to_sequence()?;
let mut _tmp0 = std::vec::Vec::new();
@ -915,8 +915,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for ModulePath {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for ModulePath {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let ModulePath(_tmp0) = self;
{
@ -951,8 +951,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Modules<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Modules<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let mut _tmp0 = preserves::value::Map::new();
for (_tmp1, _tmp2) in value.value().to_dictionary()? {
@ -964,8 +964,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Modules<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Modules<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let Modules(_tmp0) = self;
preserves::value::Value::Dictionary(_tmp0.iter().map(|(_tmp1, _tmp2)| (_tmp1.unparse(_ctxt), _tmp2.unparse(_ctxt))).collect()).wrap()
@ -995,8 +995,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for NamedAlternative<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for NamedAlternative<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_sequence()?;
if _tmp0.len() < 2 { return Err(_support::ParseError::conformance_error("schema.NamedAlternative")); }
@ -1006,8 +1006,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for NamedAlternative<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for NamedAlternative<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let NamedAlternative {variant_label: _tmp0, pattern: _tmp1} = self;
{
@ -1046,18 +1046,18 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_named_pattern_named<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<NamedPattern<_Value>, _support::ParseError> {
fn parse_named_pattern_named<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedPattern<_Value>, _support::ParseError> {
let _tmp0 = Binding::parse(_ctxt, value)?;
Ok(NamedPattern::Named(std::boxed::Box::new(_tmp0)))
}
fn parse_named_pattern_anonymous<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<NamedPattern<_Value>, _support::ParseError> {
fn parse_named_pattern_anonymous<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedPattern<_Value>, _support::ParseError> {
let _tmp0 = Pattern::parse(_ctxt, value)?;
Ok(NamedPattern::Anonymous(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for NamedPattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for NamedPattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_named_pattern_named(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_named_pattern_anonymous(_ctxt, value) { return Ok(r); }
@ -1065,8 +1065,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for NamedPattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for NamedPattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
match self {
NamedPattern::Named(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1102,18 +1102,18 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_named_simple_pattern_named<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<NamedSimplePattern<_Value>, _support::ParseError> {
fn parse_named_simple_pattern_named<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedSimplePattern<_Value>, _support::ParseError> {
let _tmp0 = Binding::parse(_ctxt, value)?;
Ok(NamedSimplePattern::Named(std::boxed::Box::new(_tmp0)))
}
fn parse_named_simple_pattern_anonymous<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<NamedSimplePattern<_Value>, _support::ParseError> {
fn parse_named_simple_pattern_anonymous<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<NamedSimplePattern<_Value>, _support::ParseError> {
let _tmp0 = SimplePattern::parse(_ctxt, value)?;
Ok(NamedSimplePattern::Anonymous(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for NamedSimplePattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for NamedSimplePattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_named_simple_pattern_named(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_named_simple_pattern_anonymous(_ctxt, value) { return Ok(r); }
@ -1121,8 +1121,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for NamedSimplePattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for NamedSimplePattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
match self {
NamedSimplePattern::Named(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1158,18 +1158,18 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_pattern_simple_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<Pattern<_Value>, _support::ParseError> {
fn parse_pattern_simple_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Pattern<_Value>, _support::ParseError> {
let _tmp0 = SimplePattern::parse(_ctxt, value)?;
Ok(Pattern::SimplePattern(std::boxed::Box::new(_tmp0)))
}
fn parse_pattern_compound_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<Pattern<_Value>, _support::ParseError> {
fn parse_pattern_compound_pattern<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<Pattern<_Value>, _support::ParseError> {
let _tmp0 = CompoundPattern::parse(_ctxt, value)?;
Ok(Pattern::CompoundPattern(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Pattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Pattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_pattern_simple_pattern(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_pattern_compound_pattern(_ctxt, value) { return Ok(r); }
@ -1177,8 +1177,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Pattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Pattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
match self {
Pattern::SimplePattern(_tmp0) => _tmp0.as_ref().unparse(_ctxt),
@ -1220,8 +1220,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Ref {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Ref {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_16_REF { return Err(_support::ParseError::conformance_error("schema.Ref")); }
@ -1233,8 +1233,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Ref {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Ref {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let Ref {module: _tmp0, name: _tmp1} = self;
{
@ -1313,8 +1313,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Schema<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Schema<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_17_SCHEMA { return Err(_support::ParseError::conformance_error("schema.Schema")); }
@ -1331,8 +1331,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Schema<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Schema<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
let Schema {definitions: _tmp0, embedded_type: _tmp1, version: _tmp2} = self;
{
@ -1533,13 +1533,13 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
fn parse_simple_pattern_any<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_any<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
if value != &_ctxt.LIT_21_ANY { return Err(_support::ParseError::conformance_error("schema.SimplePattern::any")); }
let _tmp0 = ();
Ok(SimplePattern::Any)
}
fn parse_simple_pattern_atom<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_atom<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_22_ATOM { return Err(_support::ParseError::conformance_error("schema.SimplePattern::atom")); }
let _tmp1 = ();
@ -1548,7 +1548,7 @@ fn parse_simple_pattern_atom<_Value: preserves::value::NestedValue>(_ctxt: &crat
Ok(SimplePattern::Atom {atom_kind: std::boxed::Box::new(_tmp2)})
}
fn parse_simple_pattern_embedded<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_embedded<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_23_EMBEDDED { return Err(_support::ParseError::conformance_error("schema.SimplePattern::embedded")); }
let _tmp1 = ();
@ -1557,7 +1557,7 @@ fn parse_simple_pattern_embedded<_Value: preserves::value::NestedValue>(_ctxt: &
Ok(SimplePattern::Embedded {interface: std::boxed::Box::new(_tmp2)})
}
fn parse_simple_pattern_lit<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_lit<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_24_LIT { return Err(_support::ParseError::conformance_error("schema.SimplePattern::lit")); }
let _tmp1 = ();
@ -1566,7 +1566,7 @@ fn parse_simple_pattern_lit<_Value: preserves::value::NestedValue>(_ctxt: &crate
Ok(SimplePattern::Lit {value: _tmp2.clone()})
}
fn parse_simple_pattern_seqof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_seqof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_25_SEQOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::seqof")); }
let _tmp1 = ();
@ -1575,7 +1575,7 @@ fn parse_simple_pattern_seqof<_Value: preserves::value::NestedValue>(_ctxt: &cra
Ok(SimplePattern::Seqof {pattern: std::boxed::Box::new(_tmp2)})
}
fn parse_simple_pattern_setof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_setof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_26_SETOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::setof")); }
let _tmp1 = ();
@ -1584,7 +1584,7 @@ fn parse_simple_pattern_setof<_Value: preserves::value::NestedValue>(_ctxt: &cra
Ok(SimplePattern::Setof {pattern: std::boxed::Box::new(_tmp2)})
}
fn parse_simple_pattern_dictof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_dictof<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = value.value().to_record(None)?;
if _tmp0.label() != &_ctxt.LIT_27_DICTOF { return Err(_support::ParseError::conformance_error("schema.SimplePattern::dictof")); }
let _tmp1 = ();
@ -1594,13 +1594,13 @@ fn parse_simple_pattern_dictof<_Value: preserves::value::NestedValue>(_ctxt: &cr
Ok(SimplePattern::Dictof {key: std::boxed::Box::new(_tmp2), value: std::boxed::Box::new(_tmp3)})
}
fn parse_simple_pattern_ref<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Literals<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
fn parse_simple_pattern_ref<_Value: preserves::value::NestedValue>(_ctxt: &crate::gen::Language<_Value>, value: &_Value) -> std::result::Result<SimplePattern<_Value>, _support::ParseError> {
let _tmp0 = Ref::parse(_ctxt, value)?;
Ok(SimplePattern::Ref(std::boxed::Box::new(_tmp0)))
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for SimplePattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for SimplePattern<_Value> {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
if let Ok(r) = parse_simple_pattern_any(_ctxt, value) { return Ok(r); }
if let Ok(r) = parse_simple_pattern_atom(_ctxt, value) { return Ok(r); }
@ -1614,8 +1614,8 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for SimplePattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for SimplePattern<_Value> {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
match self {
SimplePattern::Any => (&_ctxt.LIT_21_ANY).clone(),
@ -1674,8 +1674,8 @@ impl<'de, _Value: preserves::value::NestedValue, R: _support::Reader<'de, _Value
}
}
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals<_Value>, _Value> for Version {
fn parse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Literals<_Value>: 'a {
impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Language<_Value>, _Value> for Version {
fn parse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(_ctxt: _LL, value: &_Value) -> std::result::Result<Self, _support::ParseError> where crate::gen::Language<_Value>: 'a {
let _ctxt = _ctxt.into();
if value != &_ctxt.LIT_28_1 { return Err(_support::ParseError::conformance_error("schema.Version")); }
let _tmp0 = ();
@ -1683,6 +1683,6 @@ impl<_Value: preserves::value::NestedValue> _support::Parse<crate::gen::Literals
}
}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Literals<_Value>, _Value> for Version {
fn unparse<'a, _LL: Into<&'a crate::gen::Literals<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Literals<_Value>: 'a {let _ctxt = _ctxt.into(); let Version = self; (&_ctxt.LIT_28_1).clone()}
impl<_Value: preserves::value::NestedValue> _support::Unparse<crate::gen::Language<_Value>, _Value> for Version {
fn unparse<'a, _LL: Into<&'a crate::gen::Language<_Value>>>(&self, _ctxt: _LL) -> _Value where crate::gen::Language<_Value>: 'a {let _ctxt = _ctxt.into(); let Version = self; (&_ctxt.LIT_28_1).clone()}
}

View File

@ -44,9 +44,9 @@ mod tests {
let mut src = IOBinarySource::new(&mut f);
let mut reader = src.packed_iovalues();
let schema = reader.demand_next(false)?;
let literals = crate::gen::Literals::default();
let parsed = Schema::parse(&literals, &schema).expect("successful parse");
assert_eq!(schema, parsed.unparse(&literals));
let language = crate::gen::Language::default();
let parsed = Schema::parse(&language, &schema).expect("successful parse");
assert_eq!(schema, parsed.unparse(&language));
Ok(())
}
}

View File

@ -15,29 +15,26 @@ use std::convert::From;
use std::convert::Into;
use std::convert::TryFrom;
use std::io;
// use std::marker::PhantomData;
use std::sync::Arc;
use thiserror::Error;
pub trait Parse<L, Value: NestedValue>: Sized {
// fn parse(literals: &L, value: &Value) -> Result<Self, ParseError>;
fn parse<'a, LL: Into<&'a L>>(literals: LL, value: &Value) -> Result<Self, ParseError> where L: 'a;
fn parse<'a, LL: Into<&'a L>>(language: LL, value: &Value) -> Result<Self, ParseError> where L: 'a;
}
impl<L, Value: NestedValue> Parse<L, Value> for Value {
fn parse<'a, LL: Into<&'a L>>(_literals: LL, value: &Value) -> Result<Self, ParseError> where L: 'a {
fn parse<'a, LL: Into<&'a L>>(_language: LL, value: &Value) -> Result<Self, ParseError> where L: 'a {
Ok(value.clone())
}
}
pub trait Unparse<L, Value: NestedValue> {
// fn unparse(&self, literals: &L) -> Value;
fn unparse<'a, LL: Into<&'a L>>(&self, literals: LL) -> Value where L: 'a;
fn unparse<'a, LL: Into<&'a L>>(&self, language: LL) -> Value where L: 'a;
}
impl<L, Value: NestedValue> Unparse<L, Value> for Value {
fn unparse<'a, LL: Into<&'a L>>(&self, _literals: LL) -> Value where L: 'a {
fn unparse<'a, LL: Into<&'a L>>(&self, _language: LL) -> Value where L: 'a {
self.clone()
}
}