microcad_syntax/ast/
ty.rs1use crate::Span;
5use crate::ast::Identifier;
6use compact_str::CompactString;
7
8#[derive(Debug, PartialEq)]
10#[allow(missing_docs)]
11pub enum Type {
12 Single(SingleType),
13 Array(ArrayType),
14 Tuple(TupleType),
15}
16
17impl Type {
18 pub fn span(&self) -> Span {
20 match self {
21 Type::Single(ty) => ty.span.clone(),
22 Type::Array(ty) => ty.span.clone(),
23 Type::Tuple(ty) => ty.span.clone(),
24 }
25 }
26}
27
28#[derive(Debug, PartialEq)]
30#[allow(missing_docs)]
31pub struct SingleType {
32 pub span: Span,
33 pub name: CompactString,
34}
35
36#[derive(Debug, PartialEq)]
38#[allow(missing_docs)]
39pub struct ArrayType {
40 pub span: Span,
41 pub inner: Box<Type>,
42}
43
44#[derive(Debug, PartialEq)]
46#[allow(missing_docs)]
47pub struct TupleType {
48 pub span: Span,
49 pub inner: Vec<(Option<Identifier>, Type)>,
50}