yog_script_analyze/ast/
pattern.rs1use super::{BinOp, Expr, Name};
4use crate::source::token::Span;
5
6#[derive(Debug, Clone, PartialEq)]
7pub enum Pattern {
8 Wild(Span),
9 Value(Expr),
12 Let(Name),
14 Type {
16 ty: Type,
17 bind: Option<Name>,
18 },
19 Variant {
21 path: Vec<Name>,
22 args: Vec<Pattern>,
23 },
24 Relational {
26 op: BinOp,
27 value: Expr,
28 },
29 Range {
30 from: Expr,
31 to: Expr,
32 },
33 Tuple(Vec<Pattern>),
34 Property {
36 ty: Option<Type>,
37 fields: Vec<(Name, Pattern)>,
38 },
39 Or(Box<Pattern>, Box<Pattern>),
40 And(Box<Pattern>, Box<Pattern>),
41 Not(Box<Pattern>),
42}
43
44#[derive(Debug, Clone, PartialEq)]
45pub struct Type {
46 pub kind: TypeKind,
47 pub span: Span,
48}
49
50#[derive(Debug, Clone, PartialEq)]
51pub enum TypeKind {
52 Path {
54 path: Vec<Name>,
55 args: Vec<Type>,
56 },
57 Tuple(Vec<(Type, Option<Name>)>),
59 Nullable(Box<Type>),
60 Both(Vec<Type>),
62 Borrow {
64 mutable: bool,
65 lifetime: Option<Name>,
66 ty: Box<Type>,
67 },
68 Lifetime(Name),
70}