1pub mod expr;
13pub mod item;
14pub mod pattern;
15pub mod ty;
16
17pub use expr::{BinOp, Expr, FieldInit, Literal, MatchArm, StringPart, UnOp};
18pub use item::{
19 AssignOp, AssocTypeBinding, ConstDecl, ExternBlock, Function, ImplBlock, Import,
20 Module as ModuleDecl, Param, Record, RecordField, TraitDecl, TraitItem, TypeDecl, Visibility,
21 WhereBound,
22};
23pub use pattern::Pattern;
24pub use ty::{Type, TypeParam};
25
26use nova_diagnostics::Spanned;
27
28#[derive(Debug, Clone)]
30pub struct File {
31 pub items: Vec<Spanned<Item>>,
32}
33
34#[derive(Debug, Clone)]
36pub enum Item {
37 Function(Function),
38 Record(Record),
39 Type(TypeDecl),
40 Trait(TraitDecl),
41 Impl(ImplBlock),
42 Const(ConstDecl),
43 Import(Import),
44 Module(ModuleDecl),
45 Extern(ExternBlock),
46}
47
48#[derive(Debug, Clone)]
50pub enum Stmt {
51 Let {
52 is_mut: bool,
53 pattern: Spanned<Pattern>,
54 ty: Option<Spanned<Type>>,
55 init: Option<Spanned<Expr>>,
56 },
57 Expr(Spanned<Expr>),
58 Item(Box<Item>),
59}
60
61#[derive(Debug, Clone)]
63pub struct Block {
64 pub stmts: Vec<Spanned<Stmt>>,
65 pub trailing: Option<Box<Spanned<Expr>>>,
67}
68
69#[derive(Debug, Clone)]
71pub struct Path {
72 pub segments: Vec<Spanned<String>>,
73}
74
75impl Path {
76 pub fn single(name: Spanned<String>) -> Self {
77 Self {
78 segments: vec![name],
79 }
80 }
81}