From d0e6ec1f095be22f98786a84debfeb6f29ec0b01 Mon Sep 17 00:00:00 2001 From: Dominik Nakamura Date: Tue, 20 Feb 2024 11:17:41 +0900 Subject: [PATCH] refactor: switch generic types from unnamed to named As the amount of values contained in generic built-in types grows, it's better to convert these to named structs so the values have a clearer meaning. Also, the `hash_map` type is now split into individual fields for the key and value type. --- crates/mabo-compiler/src/resolve/mod.rs | 18 +- crates/mabo-compiler/src/simplify.rs | 18 +- crates/mabo-compiler/src/validate/generics.rs | 18 +- crates/mabo-compiler/src/validate/tuples.rs | 18 +- .../mabo-lsp/src/handlers/semantic_tokens.rs | 29 +++- crates/mabo-parser/src/lib.rs | 81 +++++++-- crates/mabo-parser/src/parser/types.rs | 104 ++++++++---- .../snapshots/parser__parse@mixed.mabo.snap | 24 +-- .../parser__parse@types_basic.mabo.snap | 20 +-- .../parser__parse@types_generic.mabo.snap | 108 ++++++------ .../parser__parse@types_nested.mabo.snap | 46 +++-- .../parser__parse@types_non_zero.mabo.snap | 158 +++++++++--------- 12 files changed, 366 insertions(+), 276 deletions(-) diff --git a/crates/mabo-compiler/src/resolve/mod.rs b/crates/mabo-compiler/src/resolve/mod.rs index 6f850a9..7043d51 100644 --- a/crates/mabo-compiler/src/resolve/mod.rs +++ b/crates/mabo-compiler/src/resolve/mod.rs @@ -470,20 +470,20 @@ fn visit_externals<'a>(value: &'a Type<'_>, visit: &mut impl FnMut(&'a ExternalT | DataType::StringRef | DataType::Bytes | DataType::BytesRef - | DataType::NonZero(_, _, _) + | DataType::NonZero { .. } | DataType::BoxString | DataType::BoxBytes => {} - DataType::Vec(_, _, ty) - | DataType::HashSet(_, _, ty) - | DataType::Option(_, _, ty) - | DataType::Array(_, ty, _, _) => { + DataType::Vec { ty, .. } + | DataType::HashSet { ty, .. } + | DataType::Option { ty, .. } + | DataType::Array { ty, .. } => { visit_externals(ty, visit); } - DataType::HashMap(_, _, _, kv) => { - visit_externals(&kv.0, visit); - visit_externals(&kv.1, visit); + DataType::HashMap { key, value, .. } => { + visit_externals(key, visit); + visit_externals(value, visit); } - DataType::Tuple(_, types) => { + DataType::Tuple { types, .. } => { for ty in types { visit_externals(ty, visit); } diff --git a/crates/mabo-compiler/src/simplify.rs b/crates/mabo-compiler/src/simplify.rs index b8a05a9..f6d27c9 100644 --- a/crates/mabo-compiler/src/simplify.rs +++ b/crates/mabo-compiler/src/simplify.rs @@ -439,19 +439,19 @@ fn simplify_type<'a>(item: &'a mabo_parser::Type<'_>) -> Type<'a> { mabo_parser::DataType::StringRef => Type::StringRef, mabo_parser::DataType::Bytes => Type::Bytes, mabo_parser::DataType::BytesRef => Type::BytesRef, - mabo_parser::DataType::Vec(_, _, ref ty) => Type::Vec(simplify_type(ty).into()), - mabo_parser::DataType::HashMap(_, _, _, ref kv) => { - Type::HashMap((simplify_type(&kv.0), simplify_type(&kv.1)).into()) - } - mabo_parser::DataType::HashSet(_, _, ref ty) => Type::HashSet(simplify_type(ty).into()), - mabo_parser::DataType::Option(_, _, ref ty) => Type::Option(simplify_type(ty).into()), - mabo_parser::DataType::NonZero(_, _, ref ty) => Type::NonZero(simplify_type(ty).into()), + mabo_parser::DataType::Vec { ref ty, .. } => Type::Vec(simplify_type(ty).into()), + mabo_parser::DataType::HashMap { + ref key, ref value, .. + } => Type::HashMap((simplify_type(key), simplify_type(value)).into()), + mabo_parser::DataType::HashSet { ref ty, .. } => Type::HashSet(simplify_type(ty).into()), + mabo_parser::DataType::Option { ref ty, .. } => Type::Option(simplify_type(ty).into()), + mabo_parser::DataType::NonZero { ref ty, .. } => Type::NonZero(simplify_type(ty).into()), mabo_parser::DataType::BoxString => Type::BoxString, mabo_parser::DataType::BoxBytes => Type::BoxBytes, - mabo_parser::DataType::Tuple(_, ref types) => { + mabo_parser::DataType::Tuple { ref types, .. } => { Type::Tuple(types.iter().map(|ty| simplify_type(ty)).collect()) } - mabo_parser::DataType::Array(_, ref ty, _, size) => { + mabo_parser::DataType::Array { ref ty, size, .. } => { Type::Array(simplify_type(ty).into(), size) } mabo_parser::DataType::External(ref ty) => Type::External(ExternalType { diff --git a/crates/mabo-compiler/src/validate/generics.rs b/crates/mabo-compiler/src/validate/generics.rs index 07da0b6..ac07516 100644 --- a/crates/mabo-compiler/src/validate/generics.rs +++ b/crates/mabo-compiler/src/validate/generics.rs @@ -157,18 +157,18 @@ fn visit_externals(value: &Type<'_>, visit: &mut impl FnMut(&ExternalType<'_>)) | DataType::StringRef | DataType::Bytes | DataType::BytesRef - | DataType::NonZero(_, _, _) + | DataType::NonZero { .. } | DataType::BoxString | DataType::BoxBytes => {} - DataType::Vec(_, _, ty) - | DataType::HashSet(_, _, ty) - | DataType::Option(_, _, ty) - | DataType::Array(_, ty, _, _) => visit_externals(ty, visit), - DataType::HashMap(_, _, _, kv) => { - visit_externals(&kv.0, visit); - visit_externals(&kv.1, visit); + DataType::Vec { ty, .. } + | DataType::HashSet { ty, .. } + | DataType::Option { ty, .. } + | DataType::Array { ty, .. } => visit_externals(ty, visit), + DataType::HashMap { key, value, .. } => { + visit_externals(key, visit); + visit_externals(value, visit); } - DataType::Tuple(_, types) => { + DataType::Tuple { types, .. } => { for ty in types { visit_externals(ty, visit); } diff --git a/crates/mabo-compiler/src/validate/tuples.rs b/crates/mabo-compiler/src/validate/tuples.rs index e0f521a..6f8e913 100644 --- a/crates/mabo-compiler/src/validate/tuples.rs +++ b/crates/mabo-compiler/src/validate/tuples.rs @@ -106,18 +106,18 @@ fn visit_tuples( | DataType::StringRef | DataType::Bytes | DataType::BytesRef - | DataType::NonZero(_, _, _) + | DataType::NonZero { .. } | DataType::BoxString | DataType::BoxBytes => Ok(()), - DataType::Vec(_, _, ty) - | DataType::HashSet(_, _, ty) - | DataType::Option(_, _, ty) - | DataType::Array(_, ty, _, _) => visit_tuples(ty, visit), - DataType::HashMap(_, _, _, kv) => { - visit_tuples(&kv.0, visit)?; - visit_tuples(&kv.1, visit) + DataType::Vec { ty, .. } + | DataType::HashSet { ty, .. } + | DataType::Option { ty, .. } + | DataType::Array { ty, .. } => visit_tuples(ty, visit), + DataType::HashMap { key, value, .. } => { + visit_tuples(key, visit)?; + visit_tuples(value, visit) } - DataType::Tuple(_, types) => { + DataType::Tuple { types, .. } => { visit(types)?; types.iter().try_for_each(|ty| visit_tuples(ty, visit)) } diff --git a/crates/mabo-lsp/src/handlers/semantic_tokens.rs b/crates/mabo-lsp/src/handlers/semantic_tokens.rs index 51ed740..3909a29 100644 --- a/crates/mabo-lsp/src/handlers/semantic_tokens.rs +++ b/crates/mabo-lsp/src/handlers/semantic_tokens.rs @@ -364,31 +364,42 @@ impl<'a> Visitor<'a> { | DataType::Bytes | DataType::BytesRef | DataType::BoxBytes => self.add_span(item, &types::BUILTIN_TYPE, &[]), - DataType::Vec(span, angle, ty) - | DataType::HashSet(span, angle, ty) - | DataType::Option(span, angle, ty) - | DataType::NonZero(span, angle, ty) => { + DataType::Vec { span, angle, ty } + | DataType::HashSet { span, angle, ty } + | DataType::Option { span, angle, ty } + | DataType::NonZero { span, angle, ty } => { self.add_span(span, &types::BUILTIN_TYPE, &[])?; self.add_span(&angle.open(), &types::ANGLE, &[])?; self.visit_type(ty)?; self.add_span(&angle.close(), &types::ANGLE, &[]) } - DataType::HashMap(span, angle, comma, kv) => { + DataType::HashMap { + span, + angle, + key, + comma, + value, + } => { self.add_span(span, &types::BUILTIN_TYPE, &[])?; self.add_span(&angle.open(), &types::ANGLE, &[])?; - self.visit_type(&kv.0)?; + self.visit_type(key)?; self.add_span(comma, &types::COMMA, &[])?; - self.visit_type(&kv.1)?; + self.visit_type(value)?; self.add_span(&angle.close(), &types::ANGLE, &[]) } - DataType::Tuple(paren, types) => { + DataType::Tuple { paren, types } => { self.add_span(&paren.open(), &types::PARENTHESIS, &[])?; for ty in types { self.visit_type(ty)?; } self.add_span(&paren.close(), &types::PARENTHESIS, &[]) } - DataType::Array(bracket, ty, semicolon, _) => { + DataType::Array { + bracket, + ty, + semicolon, + size: _, + } => { self.add_span(&bracket.open(), &types::BRACKET, &[])?; self.visit_type(ty)?; self.add_span(semicolon, &types::SEMICOLON, &[])?; diff --git a/crates/mabo-parser/src/lib.rs b/crates/mabo-parser/src/lib.rs index 223c8f8..55fc406 100644 --- a/crates/mabo-parser/src/lib.rs +++ b/crates/mabo-parser/src/lib.rs @@ -907,25 +907,78 @@ pub enum DataType<'a> { /// Reference version (slice) of `u8` bytes. BytesRef, /// Vector of another data type. - Vec(Span, token::Angle, Box>), + Vec { + /// Source code location of the `vec` type name. + span: Span, + /// Angles `<`...`>` that delimit the type parameter. + angle: token::Angle, + /// Type parameter. + ty: Box>, + }, /// Key-value hash map of data types. - HashMap(Span, token::Angle, token::Comma, Box<(Type<'a>, Type<'a>)>), + HashMap { + /// Source code location of the `hash_map` type name. + span: Span, + /// Angles `<`...`>` that delimit the type parameters. + angle: token::Angle, + /// First type parameter. + key: Box>, + /// Separator between first and second type parameter. + comma: token::Comma, + /// Second type parameter. + value: Box>, + }, /// Hash set of data types (each entry is unique). - HashSet(Span, token::Angle, Box>), + HashSet { + /// Source code location of the `hash_set` type name. + span: Span, + /// Angles `<`...`>` that delimit the type parameter. + angle: token::Angle, + /// Type parameter. + ty: Box>, + }, /// Optional value. - Option(Span, token::Angle, Box>), + Option { + /// Source code location of the `option` type name. + span: Span, + /// Angles `<`...`>` that delimit the type parameter. + angle: token::Angle, + /// Type parameter. + ty: Box>, + }, /// Non-zero value. /// - Integers: `n > 0` /// - Collections: `len() > 0` - NonZero(Span, token::Angle, Box>), + NonZero { + /// Source code location of the `non_zero` type name. + span: Span, + /// Angles `<`...`>` that delimit the type parameter. + angle: token::Angle, + /// Type parameter. + ty: Box>, + }, /// Boxed version of a string that is immutable. BoxString, /// Boxed version of a byte vector that is immutable. BoxBytes, /// Fixed size list of up to 12 types. - Tuple(token::Parenthesis, Vec>), + Tuple { + /// Parenthesis `(`...`)` that delimits the tuple. + paren: token::Parenthesis, + /// List of types that make up the tuple. + types: Vec>, + }, /// Continuous list of values with a single time and known length. - Array(token::Bracket, Box>, token::Semicolon, u32), + Array { + /// Brackets `[`...`]` that delimit the array. + bracket: token::Bracket, + /// The singular repeated type. + ty: Box>, + /// Separator between type and array size. + semicolon: token::Semicolon, + /// Size, as in count of elements. + size: u32, + }, /// Any external, non-standard data type (like a user defined struct or enum). External(ExternalType<'a>), } @@ -950,15 +1003,15 @@ impl Display for DataType<'_> { Self::StringRef => f.write_str("&string"), Self::Bytes => f.write_str("bytes"), Self::BytesRef => f.write_str("&bytes"), - Self::Vec(_, _, t) => write!(f, "vec<{t}>"), - Self::HashMap(_, _, _, kv) => write!(f, "hash_map<{}, {}>", kv.0, kv.1), - Self::HashSet(_, _, t) => write!(f, "hash_set<{t}>"), - Self::Option(_, _, t) => write!(f, "option<{t}>"), - Self::NonZero(_, _, t) => write!(f, "non_zero<{t}>"), + Self::Vec { ty, .. } => write!(f, "vec<{ty}>"), + Self::HashMap { key, value, .. } => write!(f, "hash_map<{key}, {value}>"), + Self::HashSet { ty, .. } => write!(f, "hash_set<{ty}>"), + Self::Option { ty, .. } => write!(f, "option<{ty}>"), + Self::NonZero { ty, .. } => write!(f, "non_zero<{ty}>"), Self::BoxString => f.write_str("box"), Self::BoxBytes => f.write_str("box"), - Self::Tuple(_, l) => concat::(f, l, ", "), - Self::Array(_, t, _, size) => write!(f, "[{t}; {size}]"), + Self::Tuple { types, .. } => concat::(f, types, ", "), + Self::Array { ty, size, .. } => write!(f, "[{ty}; {size}]"), Self::External(t) => t.fmt(f), } } diff --git a/crates/mabo-parser/src/parser/types.rs b/crates/mabo-parser/src/parser/types.rs index eb6a368..67d66a4 100644 --- a/crates/mabo-parser/src/parser/types.rs +++ b/crates/mabo-parser/src/parser/types.rs @@ -102,40 +102,73 @@ fn parse_basic<'i>(input: &mut Input<'i>) -> Result, Cause> { } fn parse_generic<'i>(input: &mut Input<'i>) -> Result, Cause> { - dispatch! { - (take_while(3.., ('a'..='z', '_')).with_span(), token::Angle::OPEN.span()); - (("vec", ref span), ref open) => cut_err(( + /// Create a parser for a single generic parameter like ``. + #[allow(clippy::inline_always)] + #[inline(always)] + fn parse_single<'i>( + convert: impl Fn(token::Angle, Type<'i>) -> DataType<'i>, + ) -> impl Fn(&mut Input<'i>) -> Result, Cause> { + move |input| { + cut_err(( + token::Angle::OPEN.span(), parse.map_err(Cause::from), token::Angle::CLOSE.span(), )) - .map(|(ty, close)| DataType::Vec(span.into(), (open, &close).into(), Box::new(ty))), - (("hash_map", ref span), ref open) => cut_err(( + .parse_next(input) + .map(|(open, ty, close)| convert((open, close).into(), ty)) + } + } + + /// Create a parser for two generic parameters like ``. + #[allow(clippy::inline_always)] + #[inline(always)] + fn parse_pair<'i>( + convert: impl Fn(token::Angle, Type<'i>, token::Comma, Type<'i>) -> DataType<'i>, + ) -> impl Fn(&mut Input<'i>) -> Result, Cause> { + move |input| { + cut_err(( + token::Angle::OPEN.span(), parse.map_err(Cause::from), preceded(space0, token::Comma::VALUE.span()), preceded(space0, parse.map_err(Cause::from)), token::Angle::CLOSE.span(), )) - .map(|(key, comma, value, close)| DataType::HashMap( - span.into(), - (open, &close).into(), - comma.into(), - Box::new((key, value)), - )), - (("hash_set", ref span), ref open) => cut_err(( - parse.map_err(Cause::from), - token::Angle::CLOSE.span(), - )) - .map(|(ty, close)| DataType::HashSet(span.into(), (open, &close).into(), Box::new(ty))), - (("option", ref span), ref open) => cut_err(( - parse.map_err(Cause::from), - token::Angle::CLOSE.span(), - )) - .map(|(ty, close)| DataType::Option(span.into(), (open, &close).into(), Box::new(ty))), - (("non_zero", ref span), ref open) => cut_err(( - parse.map_err(Cause::from), - token::Angle::CLOSE.span(), - )) - .map(|(ty, close)| DataType::NonZero(span.into(), (open, &close).into(), Box::new(ty))), + .parse_next(input) + .map(|(open, ty1, comma, ty2, close)| { + convert((open, close).into(), ty1, comma.into(), ty2) + }) + } + } + + dispatch! { + take_while(3.., ('a'..='z', '_')).with_span(); + ("vec", ref span) => parse_single(|angle, ty| DataType::Vec { + span: span.into(), + angle, + ty: Box::new(ty), + }), + ("hash_map", ref span) => parse_pair(|angle, key, comma, value| DataType::HashMap { + span: span.into(), + angle, + key: Box::new(key), + comma, + value: Box::new(value), + }), + ("hash_set", ref span) => parse_single(|angle, ty| DataType::HashSet { + span: span.into(), + angle, + ty: Box::new(ty), + }), + ("option", ref span) => parse_single(|angle, ty| DataType::Option { + span: span.into(), + angle, + ty: Box::new(ty), + }), + ("non_zero", ref span) => parse_single(|angle, ty| DataType::NonZero { + span: span.into(), + angle, + ty: Box::new(ty), + }), _ => fail, } .parse_next(input) @@ -154,8 +187,9 @@ fn parse_tuple<'i>(input: &mut Input<'i>) -> Result, Cause> { )), ) .parse_next(input) - .map(|(paren_open, (ty, paren_close))| { - DataType::Tuple((paren_open, paren_close).into(), ty) + .map(|(paren_open, (types, paren_close))| DataType::Tuple { + paren: (paren_open, paren_close).into(), + types, }) } @@ -170,14 +204,14 @@ fn parse_array<'i>(input: &mut Input<'i>) -> Result, Cause> { )), ) .parse_next(input) - .map(|(bracket_open, (ty, semicolon, size, bracket_close))| { - DataType::Array( - (bracket_open, bracket_close).into(), - Box::new(ty), - semicolon.into(), + .map( + |(bracket_open, (ty, semicolon, size, bracket_close))| DataType::Array { + bracket: (bracket_open, bracket_close).into(), + ty: Box::new(ty), + semicolon: semicolon.into(), size, - ) - }) + }, + ) } fn parse_external<'i>(input: &mut Input<'i>) -> Result, Cause> { diff --git a/crates/mabo-parser/tests/snapshots/parser__parse@mixed.mabo.snap b/crates/mabo-parser/tests/snapshots/parser__parse@mixed.mabo.snap index 3d77fee..d7634c6 100644 --- a/crates/mabo-parser/tests/snapshots/parser__parse@mixed.mabo.snap +++ b/crates/mabo-parser/tests/snapshots/parser__parse@mixed.mabo.snap @@ -89,9 +89,9 @@ Schema { }, colon: Colon, ty: Type { - value: Option( - Angle, - Type { + value: Option { + angle: Angle, + ty: Type { value: External( ExternalType { path: [], @@ -103,7 +103,7 @@ Schema { }, ), }, - ), + }, }, id: Some( Id { @@ -222,12 +222,12 @@ Schema { }, colon: Colon, ty: Type { - value: Option( - Angle, - Type { + value: Option { + angle: Angle, + ty: Type { value: String, }, - ), + }, }, id: Some( Id { @@ -686,12 +686,12 @@ Schema { }, colon: Colon, ty: Type { - value: Option( - Angle, - Type { + value: Option { + angle: Angle, + ty: Type { value: String, }, - ), + }, }, id: Some( Id { diff --git a/crates/mabo-parser/tests/snapshots/parser__parse@types_basic.mabo.snap b/crates/mabo-parser/tests/snapshots/parser__parse@types_basic.mabo.snap index 38e6664..e59f047 100644 --- a/crates/mabo-parser/tests/snapshots/parser__parse@types_basic.mabo.snap +++ b/crates/mabo-parser/tests/snapshots/parser__parse@types_basic.mabo.snap @@ -419,9 +419,9 @@ Schema { }, colon: Colon, ty: Type { - value: Tuple( - Parenthesis, - [ + value: Tuple { + paren: Parenthesis, + types: [ Type { value: U32, }, @@ -432,7 +432,7 @@ Schema { value: U32, }, ], - ), + }, }, id: Some( Id { @@ -452,14 +452,14 @@ Schema { }, colon: Colon, ty: Type { - value: Array( - Bracket, - Type { + value: Array { + bracket: Bracket, + ty: Type { value: U32, }, - Semicolon, - 12, - ), + semicolon: Semicolon, + size: 12, + }, }, id: Some( Id { diff --git a/crates/mabo-parser/tests/snapshots/parser__parse@types_generic.mabo.snap b/crates/mabo-parser/tests/snapshots/parser__parse@types_generic.mabo.snap index 94800f6..4527079 100644 --- a/crates/mabo-parser/tests/snapshots/parser__parse@types_generic.mabo.snap +++ b/crates/mabo-parser/tests/snapshots/parser__parse@types_generic.mabo.snap @@ -39,12 +39,12 @@ Schema { }, colon: Colon, ty: Type { - value: Vec( - Angle, - Type { + value: Vec { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { @@ -64,18 +64,16 @@ Schema { }, colon: Colon, ty: Type { - value: HashMap( - Angle, - Comma, - ( - Type { - value: U32, - }, - Type { - value: String, - }, - ), - ), + value: HashMap { + angle: Angle, + key: Type { + value: U32, + }, + comma: Comma, + value: Type { + value: String, + }, + }, }, id: Some( Id { @@ -95,12 +93,12 @@ Schema { }, colon: Colon, ty: Type { - value: HashSet( - Angle, - Type { + value: HashSet { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { @@ -120,12 +118,12 @@ Schema { }, colon: Colon, ty: Type { - value: Option( - Angle, - Type { + value: Option { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { @@ -145,12 +143,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { @@ -185,12 +183,12 @@ Schema { [ UnnamedField { ty: Type { - value: Vec( - Angle, - Type { + value: Vec { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { @@ -203,18 +201,16 @@ Schema { }, UnnamedField { ty: Type { - value: HashMap( - Angle, - Comma, - ( - Type { - value: U32, - }, - Type { - value: String, - }, - ), - ), + value: HashMap { + angle: Angle, + key: Type { + value: U32, + }, + comma: Comma, + value: Type { + value: String, + }, + }, }, id: Some( Id { @@ -227,12 +223,12 @@ Schema { }, UnnamedField { ty: Type { - value: HashSet( - Angle, - Type { + value: HashSet { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { @@ -245,12 +241,12 @@ Schema { }, UnnamedField { ty: Type { - value: Option( - Angle, - Type { + value: Option { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { @@ -263,12 +259,12 @@ Schema { }, UnnamedField { ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { diff --git a/crates/mabo-parser/tests/snapshots/parser__parse@types_nested.mabo.snap b/crates/mabo-parser/tests/snapshots/parser__parse@types_nested.mabo.snap index 5dc02ef..5311c26 100644 --- a/crates/mabo-parser/tests/snapshots/parser__parse@types_nested.mabo.snap +++ b/crates/mabo-parser/tests/snapshots/parser__parse@types_nested.mabo.snap @@ -39,33 +39,31 @@ Schema { }, colon: Colon, ty: Type { - value: Vec( - Angle, - Type { - value: Option( - Angle, - Type { - value: NonZero( - Angle, - Type { - value: HashMap( - Angle, - Comma, - ( - Type { - value: I64, - }, - Type { - value: BoxString, - }, - ), - ), + value: Vec { + angle: Angle, + ty: Type { + value: Option { + angle: Angle, + ty: Type { + value: NonZero { + angle: Angle, + ty: Type { + value: HashMap { + angle: Angle, + key: Type { + value: I64, + }, + comma: Comma, + value: Type { + value: BoxString, + }, + }, }, - ), + }, }, - ), + }, }, - ), + }, }, id: Some( Id { diff --git a/crates/mabo-parser/tests/snapshots/parser__parse@types_non_zero.mabo.snap b/crates/mabo-parser/tests/snapshots/parser__parse@types_non_zero.mabo.snap index a787c05..1f52a26 100644 --- a/crates/mabo-parser/tests/snapshots/parser__parse@types_non_zero.mabo.snap +++ b/crates/mabo-parser/tests/snapshots/parser__parse@types_non_zero.mabo.snap @@ -39,12 +39,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: U8, }, - ), + }, }, id: Some( Id { @@ -64,12 +64,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: U16, }, - ), + }, }, id: Some( Id { @@ -89,12 +89,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: U32, }, - ), + }, }, id: Some( Id { @@ -114,12 +114,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: U64, }, - ), + }, }, id: Some( Id { @@ -139,12 +139,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: U128, }, - ), + }, }, id: Some( Id { @@ -164,12 +164,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: I8, }, - ), + }, }, id: Some( Id { @@ -189,12 +189,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: I16, }, - ), + }, }, id: Some( Id { @@ -214,12 +214,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: I32, }, - ), + }, }, id: Some( Id { @@ -239,12 +239,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: I64, }, - ), + }, }, id: Some( Id { @@ -264,12 +264,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: I128, }, - ), + }, }, id: Some( Id { @@ -289,12 +289,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: String, }, - ), + }, }, id: Some( Id { @@ -314,12 +314,12 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { value: Bytes, }, - ), + }, }, id: Some( Id { @@ -339,17 +339,17 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { - value: Vec( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { + value: Vec { + angle: Angle, + ty: Type { value: String, }, - ), + }, }, - ), + }, }, id: Some( Id { @@ -369,23 +369,21 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { - value: HashMap( - Angle, - Comma, - ( - Type { - value: String, - }, - Type { - value: Bytes, - }, - ), - ), + value: NonZero { + angle: Angle, + ty: Type { + value: HashMap { + angle: Angle, + key: Type { + value: String, + }, + comma: Comma, + value: Type { + value: Bytes, + }, + }, }, - ), + }, }, id: Some( Id { @@ -405,17 +403,17 @@ Schema { }, colon: Colon, ty: Type { - value: NonZero( - Angle, - Type { - value: HashSet( - Angle, - Type { + value: NonZero { + angle: Angle, + ty: Type { + value: HashSet { + angle: Angle, + ty: Type { value: String, }, - ), + }, }, - ), + }, }, id: Some( Id {