sway_core/language/lexed/
mod.rs

1mod program;
2
3use crate::language::ModName;
4pub use program::LexedProgram;
5use sway_ast::{attribute::Annotated, Module};
6
7use super::{HasModule, HasSubmodules};
8
9/// A module and its submodules in the form of a tree.
10#[derive(Debug, Clone)]
11pub struct LexedModule {
12    /// The content of this module in the form of a [Module].
13    pub tree: Annotated<Module>,
14    /// Submodules introduced within this module using the `mod` syntax in order of declaration.
15    pub submodules: Vec<(ModName, LexedSubmodule)>,
16}
17
18/// A library module that was declared as a `mod` of another module.
19///
20/// Only submodules are guaranteed to be a `library`.
21#[derive(Debug, Clone)]
22pub struct LexedSubmodule {
23    pub module: LexedModule,
24}
25
26impl HasModule<LexedModule> for LexedSubmodule {
27    fn module(&self) -> &LexedModule {
28        &self.module
29    }
30}
31
32impl HasSubmodules<LexedSubmodule> for LexedModule {
33    fn submodules(&self) -> &[(ModName, LexedSubmodule)] {
34        &self.submodules
35    }
36}