Skip to main content

sysml_v2_parser/ast/
package.rs

1use super::behavior::{
2    ActionDef, ActionUsage, AllocationDef, AllocationUsage, FlowDef, FlowUsage, StateDef,
3    StateUsage,
4};
5use super::common::FilterMember;
6use super::common::{
7    CommentAnnotation, DocComment, Identification, Import, ParseErrorNode, TextualRepresentation,
8};
9use super::kerml_fallback::{
10    ClassifierDecl, ExtendedLibraryDecl, FeatureDecl, KermlFeatureDecl, KermlSemanticDecl,
11};
12use super::requirement::{
13    ActorDecl, AnalysisCaseDef, AnalysisCaseUsage, CaseDef, CaseUsage, ConcernUsage, Dependency,
14    RequirementDef, RequirementUsage, Satisfy, UseCaseDef, UseCaseUsage, VerificationCaseDef,
15    VerificationCaseUsage,
16};
17use super::structure::{
18    AliasDef, AttributeDef, ConnectionDef, EnumDef, IndividualDef, InterfaceDef, ItemDef,
19    MetadataDef, MetadataUsage, OccurrenceDef, OccurrenceUsage, PartDef, PartUsage, PortDef,
20};
21use super::view::{
22    CalcDef, ConstraintDef, RenderingDef, RenderingUsage, ViewDef, ViewUsage, ViewpointDef,
23    ViewpointUsage,
24};
25use crate::ast::core::Node;
26
27/// A package declaration: `package` Identification PackageBody
28#[derive(Debug, Clone, PartialEq, Eq)]
29pub struct Package {
30    pub identification: Identification,
31    pub body: PackageBody,
32}
33/// Package body: either `;` or `{` PackageBodyElement* `}`
34#[derive(Debug, Clone, PartialEq, Eq)]
35pub enum PackageBody {
36    /// Semicolon form: no body elements.
37    Semicolon,
38    /// Brace form: list of body elements (may be empty).
39    Brace {
40        elements: Vec<Node<PackageBodyElement>>,
41    },
42}
43/// Library package: `library` (optional `standard`) `package` Identification PackageBody (BNF LibraryPackage).
44#[derive(Debug, Clone, PartialEq, Eq)]
45pub struct LibraryPackage {
46    pub is_standard: bool,
47    pub identification: Identification,
48    pub body: PackageBody,
49}
50/// Top-level element inside a namespace or package body.
51#[derive(Debug, Clone, PartialEq, Eq)]
52pub enum PackageBodyElement {
53    Error(Node<ParseErrorNode>),
54    Doc(Node<DocComment>),
55    Comment(Node<CommentAnnotation>),
56    TextualRep(Node<TextualRepresentation>),
57    Filter(Node<FilterMember>),
58    Package(Node<Package>),
59    LibraryPackage(Node<LibraryPackage>),
60    Import(Node<Import>),
61    PartDef(Node<PartDef>),
62    PartUsage(Node<PartUsage>),
63    PortDef(Node<PortDef>),
64    InterfaceDef(Node<InterfaceDef>),
65    AliasDef(Node<AliasDef>),
66    AttributeDef(Node<AttributeDef>),
67    ActionDef(Node<ActionDef>),
68    ActionUsage(Node<ActionUsage>),
69    RequirementDef(Node<RequirementDef>),
70    RequirementUsage(Node<RequirementUsage>),
71    Satisfy(Node<Satisfy>),
72    UseCaseDef(Node<UseCaseDef>),
73    Actor(Node<ActorDecl>),
74    StateDef(Node<StateDef>),
75    StateUsage(Node<StateUsage>),
76    ItemDef(Node<ItemDef>),
77    IndividualDef(Node<IndividualDef>),
78    ConstraintDef(Node<ConstraintDef>),
79    CalcDef(Node<CalcDef>),
80    ViewDef(Node<ViewDef>),
81    ViewpointDef(Node<ViewpointDef>),
82    RenderingDef(Node<RenderingDef>),
83    ViewUsage(Node<ViewUsage>),
84    ViewpointUsage(Node<ViewpointUsage>),
85    RenderingUsage(Node<RenderingUsage>),
86    ConnectionDef(Node<ConnectionDef>),
87    MetadataDef(Node<MetadataDef>),
88    MetadataUsage(Node<MetadataUsage>),
89    EnumDef(Node<EnumDef>),
90    OccurrenceDef(Node<OccurrenceDef>),
91    OccurrenceUsage(Node<OccurrenceUsage>),
92    Dependency(Node<Dependency>),
93    AllocationDef(Node<AllocationDef>),
94    AllocationUsage(Node<AllocationUsage>),
95    FlowDef(Node<FlowDef>),
96    FlowUsage(Node<FlowUsage>),
97    ConcernUsage(Node<ConcernUsage>),
98    CaseDef(Node<CaseDef>),
99    CaseUsage(Node<CaseUsage>),
100    AnalysisCaseDef(Node<AnalysisCaseDef>),
101    AnalysisCaseUsage(Node<AnalysisCaseUsage>),
102    VerificationCaseDef(Node<VerificationCaseDef>),
103    VerificationCaseUsage(Node<VerificationCaseUsage>),
104    UseCaseUsage(Node<UseCaseUsage>),
105    FeatureDecl(Node<FeatureDecl>),
106    ClassifierDecl(Node<ClassifierDecl>),
107    KermlSemanticDecl(Node<KermlSemanticDecl>),
108    KermlFeatureDecl(Node<KermlFeatureDecl>),
109    ExtendedLibraryDecl(Node<ExtendedLibraryDecl>),
110}