Skip to main content

microcad_syntax/ast/
mod.rs

1// Copyright © 2026 The µcad authors <info@microcad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4mod expression;
5mod literal;
6mod statement;
7mod ty;
8
9use crate::Span;
10use compact_str::CompactString;
11
12pub use expression::*;
13pub use literal::*;
14pub use statement::*;
15pub use ty::*;
16
17/// A µcad identifier
18#[derive(Debug, PartialEq, Hash, Eq)]
19#[allow(missing_docs)]
20pub struct Identifier {
21    pub span: Span,
22    pub name: CompactString,
23}
24
25impl Identifier {
26    pub(crate) fn dummy(span: Span) -> Self {
27        Identifier {
28            span,
29            name: CompactString::default(),
30        }
31    }
32}
33
34/// A µcad source file
35#[derive(Debug)]
36#[allow(missing_docs)]
37pub struct SourceFile {
38    pub span: Span,
39    pub statements: StatementList,
40}
41
42/// Non-syntactic extras that can be attached to many ast nodes
43#[derive(Debug, PartialEq, Default)]
44#[allow(missing_docs)]
45pub struct ItemExtras {
46    pub leading: Vec<ItemExtra>,
47    pub trailing: Vec<ItemExtra>,
48}
49
50#[derive(Debug, PartialEq)]
51#[allow(missing_docs)]
52#[non_exhaustive]
53pub enum ItemExtra {
54    Comment(Comment),
55}