1pub use link::LinkName;
2use uuid::Uuid;
3
4use crate::{
5 span::Spanned,
6 ty::{CommentPosition, Type},
7};
8
9#[derive(Clone, Debug, PartialEq)]
10pub enum Literal {
11 String(String),
12 Int(i64),
13 Rational(i64, i64),
14 Float(f64),
15}
16
17#[derive(Clone, Debug, PartialEq)]
18pub struct Handler {
19 pub input: Spanned<Type>,
20 pub output: Spanned<Type>,
21 pub handler: Spanned<Expr>,
22}
23
24#[derive(Clone, Debug, PartialEq)]
25pub enum Expr {
26 Literal(Literal),
27 Let {
28 ty: Spanned<Type>,
29 definition: Box<Spanned<Self>>,
30 body: Box<Spanned<Self>>,
31 },
32 Perform {
33 input: Box<Spanned<Self>>,
34 output: Spanned<Type>,
35 },
36 Continue {
37 input: Box<Spanned<Self>>,
38 output: Option<Spanned<Type>>,
39 },
40 Handle {
41 expr: Box<Spanned<Self>>,
42 handlers: Vec<Handler>,
43 },
44 Apply {
45 function: Spanned<Type>,
46 link_name: Option<LinkName>,
47 arguments: Vec<Spanned<Self>>,
48 },
49 Product(Vec<Spanned<Self>>),
50 Match {
51 of: Box<Spanned<Self>>,
52 cases: Vec<MatchCase>,
53 },
54 Typed {
55 ty: Spanned<Type>,
56 item: Box<Spanned<Self>>,
57 },
58 Hole,
59 Function {
60 parameters: Vec<Spanned<Type>>,
61 body: Box<Spanned<Self>>,
62 },
63 Array(Vec<Spanned<Self>>),
64 Set(Vec<Spanned<Self>>),
65 Include(String),
66 Import {
67 ty: Spanned<Type>,
68 uuid: Option<Uuid>,
69 },
70 Export {
71 ty: Spanned<Type>,
72 },
73 Attribute {
74 attr: Box<Spanned<Self>>,
75 item: Box<Spanned<Self>>,
76 },
77 Brand {
78 brands: Vec<String>,
79 item: Box<Spanned<Self>>,
80 },
81 Label {
82 label: String,
83 item: Box<Spanned<Self>>,
84 },
85 NewType {
86 ident: String,
87 ty: Spanned<Type>,
88 expr: Box<Spanned<Self>>,
89 },
90 Comment {
91 position: CommentPosition,
92 text: String,
93 item: Box<Spanned<Self>>,
94 },
95 Card {
96 uuid: Uuid,
97 item: Box<Spanned<Self>>,
98 next: Option<Box<Spanned<Self>>>,
99 },
100}
101
102#[derive(Clone, Debug, PartialEq)]
103pub struct MatchCase {
104 pub ty: Spanned<Type>,
105 pub expr: Spanned<Expr>,
106}