galvan_ast/item/
toplevel.rs1use derive_more::From;
2use galvan_ast_macro::AstNode;
3
4use super::{Body, FnDecl, Ident, StringLiteral, TypeDecl};
5use crate::{AstNode, PrintAst, Span};
6
7#[derive(Debug, PartialEq, Eq, From)]
8pub enum RootItem {
9 Fn(FnDecl),
10 Type(TypeDecl),
11 Main(MainDecl),
12 Test(TestDecl),
13 }
15
16#[derive(Debug, PartialEq, Eq, AstNode)]
17pub struct MainDecl {
18 pub body: Body,
19 pub span: Span,
20}
21
22#[derive(Debug, PartialEq, Eq)]
23pub struct TestDecl {
24 pub name: Option<StringLiteral>,
25 pub body: Body,
26}
27
28#[derive(Debug, PartialEq, Eq)]
29pub struct TaskDecl {
30 pub ident: Ident,
31 pub body: Body,
33}
34
35mod private {
36 pub trait Seal {}
37}
38
39pub trait RootItemMarker: private::Seal {}
40
41impl private::Seal for FnDecl {}
42
43impl RootItemMarker for FnDecl {}
44
45impl private::Seal for TypeDecl {}
46
47impl RootItemMarker for TypeDecl {}
48
49impl private::Seal for MainDecl {}
50
51impl RootItemMarker for MainDecl {}
52
53impl private::Seal for TestDecl {}
54
55impl RootItemMarker for TestDecl {}
56