From 9ab2ce2be547b1b416207e80cefda4419cce88aa Mon Sep 17 00:00:00 2001 From: Jeremy Wall Date: Mon, 21 Aug 2023 16:08:40 -0400 Subject: [PATCH] maint: The macro usage for shapes was confusing --- src/ast/mod.rs | 55 +++++++++++++++++++++----------------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/src/ast/mod.rs b/src/ast/mod.rs index e568a8f..06398f0 100644 --- a/src/ast/mod.rs +++ b/src/ast/mod.rs @@ -236,42 +236,33 @@ pub struct ModuleShapeDef { ret: Box, } -macro_rules! value_enum { - ($doc:meta $i:tt, $t:ty, $l:ty, $($extra:tt)*) => { - #[$doc] - #[derive(PartialEq, Debug, Clone)] - pub enum $i { - // Simple Values - Empty(Position), - Boolean(PositionedItem), - Int(PositionedItem), - Float(PositionedItem), - Str(PositionedItem), - Symbol(PositionedItem), - // Complex Values - Tuple(PositionedItem<$t>), - List($l), - // Extra items - $( $extra )* - } - } +#[doc = "Value types represent the Values that UCG can have."] +#[derive(PartialEq, Debug, Clone)] +pub enum Value { + Empty(Position), + Boolean(PositionedItem), + Int(PositionedItem), + Float(PositionedItem), + Str(PositionedItem), + Symbol(PositionedItem), + Tuple(PositionedItem), + List(ListDef), } -value_enum!( - doc="Value types represent the Values that UCG can have." - Value, - FieldList, - ListDef, -); - -value_enum!( - doc="Shapes represent the types that UCG values or expressions can have." - Shape, - ShapeTuple, - PositionedItem, +#[doc = "Shapes represent the types that UCG values or expressions can have."] +#[derive(PartialEq, Debug, Clone)] +pub enum Shape { + Empty(Position), + Boolean(PositionedItem), + Int(PositionedItem), + Float(PositionedItem), + Str(PositionedItem), + Symbol(PositionedItem), + Tuple(PositionedItem), + List(PositionedItem), Func(FuncShapeDef), Module(ModuleShapeDef), -); +} impl Shape { pub fn merge(&self, right: &Shape) -> Option {