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 pub(crate) fn dummy(span: Span) -> Self {
28 Type::Single(SingleType {
29 span,
30 name: CompactString::default(),
31 })
32 }
33}
34
35#[derive(Debug, PartialEq)]
37#[allow(missing_docs)]
38pub struct SingleType {
39 pub span: Span,
40 pub name: CompactString,
41}
42
43#[derive(Debug, PartialEq)]
45#[allow(missing_docs)]
46pub struct ArrayType {
47 pub span: Span,
48 pub inner: Box<Type>,
49}
50
51#[derive(Debug, PartialEq)]
53#[allow(missing_docs)]
54pub struct TupleType {
55 pub span: Span,
56 pub inner: Vec<(Option<Identifier>, Type)>,
57}