use crate::{
ast::{algorithm::*, expression::*},
derive_ast_component,
parser::*,
};
#[derive(Debug, Clone, PartialEq)]
pub struct TypeDecl {
pub type_id: String,
pub underlying_type: Type,
pub where_clause: Option<WhereClause>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum Type {
Simple(SimpleType),
Named(String),
Set {
base: Box<Type>,
bound: Option<Bound>,
},
Bag {
base: Box<Type>,
bound: Option<Bound>,
},
List {
base: Box<Type>,
bound: Option<Bound>,
unique: bool,
},
Array {
base: Box<Type>,
bound: Option<Bound>,
unique: bool,
optional: bool,
},
Enumeration {
extensibility: Extensibility,
items: Vec<String>,
},
Select {
extensibility: Extensibility,
types: Vec<String>,
},
Aggregate {
base: Box<Type>,
label: Option<String>,
},
GenericEntity(Option<String>),
Generic(Option<String>),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum SimpleType {
Number,
Real,
Integer,
Logical,
Boolen,
String_ { width_spec: Option<WidthSpec> },
Binary { width_spec: Option<WidthSpec> },
}
derive_ast_component!(SimpleType, simple_types);
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct WidthSpec {
pub width: usize,
pub fixed: bool,
}
#[derive(Debug, Clone, PartialEq)]
pub struct Bound {
pub lower: Expression,
pub upper: Expression,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Extensibility {
None,
Extensible,
GenericEntity,
}