1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::Name;

use super::entity_definition::EntityDefinition;

#[derive(Clone, Debug, PartialEq, Eq)]
pub enum EntityDecl {
    General(GeneralEntityDeclaration),
    Parameter(ParameterEntityDeclaration),
}

#[derive(Clone, PartialEq, Eq)]
pub struct EntityDeclaration {
    pub name: Name,
    pub entity_def: EntityDefinition,
}
pub type GeneralEntityDeclaration = EntityDeclaration;
pub type ParameterEntityDeclaration = EntityDeclaration;

impl EntityDeclaration {
    pub fn find_name(&self, name: Name) -> Option<&GeneralEntityDeclaration> {
        if self.name == name {
            Some(self)
        } else {
            None
        }
    }

    pub fn get_name(&self) -> &Name {
        &self.name
    }

    pub fn get_entity_def(&self) -> &EntityDefinition {
        &self.entity_def
    }
}