1#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct Span {
7 pub offset: usize,
8 pub line: u32,
9 pub column: usize,
10 pub len: usize,
11}
12
13impl Span {
14 pub fn dummy() -> Self {
16 Self {
17 offset: 0,
18 line: 1,
19 column: 1,
20 len: 0,
21 }
22 }
23
24 pub fn to_lsp_range(&self) -> (u32, u32, u32, u32) {
26 let start_line = self.line.saturating_sub(1);
27 let start_char = self.column.saturating_sub(1);
28 let end_char = start_char.saturating_add(self.len);
29 (start_line, start_char as u32, start_line, end_char as u32)
30 }
31}
32
33#[cfg(test)]
34mod tests {
35 use super::Span;
36
37 #[test]
38 fn span_dummy() {
39 let s = Span::dummy();
40 assert_eq!(s.offset, 0);
41 assert_eq!(s.line, 1);
42 assert_eq!(s.column, 1);
43 assert_eq!(s.len, 0);
44 }
45}
46
47#[derive(Debug, Clone)]
48pub struct Node<T> {
49 pub span: Span,
50 pub value: T,
51}
52
53impl<T: PartialEq> PartialEq for Node<T> {
54 fn eq(&self, other: &Self) -> bool {
55 self.value == other.value
56 }
57}
58
59impl<T: Eq> Eq for Node<T> {}
60
61impl<T> Node<T> {
62 pub fn new(span: Span, value: T) -> Self {
63 Self { span, value }
64 }
65}
66
67impl<T> std::ops::Deref for Node<T> {
68 type Target = T;
69 fn deref(&self) -> &T {
70 &self.value
71 }
72}
73
74pub trait AstNode {
76 fn span(&self) -> Span;
77}
78
79impl<T> AstNode for Node<T> {
80 fn span(&self) -> Span {
81 self.span.clone()
82 }
83}
84
85#[derive(Debug, Clone, PartialEq, Eq)]
87pub enum Expression {
88 LiteralInteger(i64),
89 LiteralReal(String),
90 LiteralString(String),
91 LiteralBoolean(bool),
92 FeatureRef(String),
94 MemberAccess(Box<Node<Expression>>, String),
96 Index {
98 base: Box<Node<Expression>>,
99 index: Box<Node<Expression>>,
100 },
101 Bracket(Box<Node<Expression>>),
103 LiteralWithUnit {
105 value: Box<Node<Expression>>,
106 unit: Box<Node<Expression>>,
107 },
108 BinaryOp {
110 op: String,
111 left: Box<Node<Expression>>,
112 right: Box<Node<Expression>>,
113 },
114 UnaryOp {
116 op: String,
117 operand: Box<Node<Expression>>,
118 },
119 Invocation {
121 callee: Box<Node<Expression>>,
122 args: Vec<Node<Expression>>,
123 },
124 Tuple(Vec<Node<Expression>>),
126 Null,
128}
129
130#[derive(Debug, Clone, PartialEq, Eq)]
132pub enum RootElement {
133 Package(Node<Package>),
134 LibraryPackage(Node<LibraryPackage>),
135 Namespace(Node<NamespaceDecl>),
136 Import(Node<Import>),
137}
138
139#[derive(Debug, Clone, PartialEq, Eq)]
141pub struct NamespaceDecl {
142 pub identification: Identification,
143 pub body: PackageBody,
144}
145
146#[derive(Debug, Clone, PartialEq, Eq)]
148pub struct RootNamespace {
149 pub elements: Vec<Node<RootElement>>,
150}
151
152#[derive(Debug, Clone, PartialEq, Eq)]
154pub struct FilterMember {
155 pub visibility: Option<Visibility>,
156 pub condition: Node<Expression>,
157}
158
159#[derive(Debug, Clone, PartialEq, Eq)]
161pub struct ParseErrorNode {
162 pub message: String,
163 pub code: String,
164 pub expected: Option<String>,
165 pub found: Option<String>,
166 pub suggestion: Option<String>,
167 pub category: Option<crate::error::DiagnosticCategory>,
168}
169
170#[derive(Debug, Clone, PartialEq, Eq)]
172pub struct KermlSemanticDecl {
173 pub bnf_production: String,
174 pub text: String,
175}
176
177#[derive(Debug, Clone, PartialEq, Eq)]
179pub struct KermlFeatureDecl {
180 pub bnf_production: String,
181 pub text: String,
182}
183
184#[derive(Debug, Clone, PartialEq, Eq)]
186pub struct FeatureDecl {
187 pub keyword: String,
188 pub text: String,
189}
190
191#[derive(Debug, Clone, PartialEq, Eq)]
193pub struct ClassifierDecl {
194 pub keyword: String,
195 pub text: String,
196}
197
198#[derive(Debug, Clone, PartialEq, Eq)]
201pub struct ExtendedLibraryDecl {
202 pub bnf_production: String,
203 pub text: String,
204}
205
206#[derive(Debug, Clone, PartialEq, Eq)]
208pub enum PackageBodyElement {
209 Error(Node<ParseErrorNode>),
210 Doc(Node<DocComment>),
211 Comment(Node<CommentAnnotation>),
212 TextualRep(Node<TextualRepresentation>),
213 Filter(Node<FilterMember>),
214 Package(Node<Package>),
215 LibraryPackage(Node<LibraryPackage>),
216 Import(Node<Import>),
217 PartDef(Node<PartDef>),
218 PartUsage(Node<PartUsage>),
219 PortDef(Node<PortDef>),
220 InterfaceDef(Node<InterfaceDef>),
221 AliasDef(Node<AliasDef>),
222 AttributeDef(Node<AttributeDef>),
223 ActionDef(Node<ActionDef>),
224 ActionUsage(Node<ActionUsage>),
225 RequirementDef(Node<RequirementDef>),
226 RequirementUsage(Node<RequirementUsage>),
227 Satisfy(Node<Satisfy>),
228 UseCaseDef(Node<UseCaseDef>),
229 Actor(Node<ActorDecl>),
230 StateDef(Node<StateDef>),
231 StateUsage(Node<StateUsage>),
232 ItemDef(Node<ItemDef>),
233 IndividualDef(Node<IndividualDef>),
234 ConstraintDef(Node<ConstraintDef>),
235 CalcDef(Node<CalcDef>),
236 ViewDef(Node<ViewDef>),
237 ViewpointDef(Node<ViewpointDef>),
238 RenderingDef(Node<RenderingDef>),
239 ViewUsage(Node<ViewUsage>),
240 ViewpointUsage(Node<ViewpointUsage>),
241 RenderingUsage(Node<RenderingUsage>),
242 ConnectionDef(Node<ConnectionDef>),
243 MetadataDef(Node<MetadataDef>),
244 EnumDef(Node<EnumDef>),
245 OccurrenceDef(Node<OccurrenceDef>),
246 OccurrenceUsage(Node<OccurrenceUsage>),
247 Dependency(Node<Dependency>),
248 AllocationDef(Node<AllocationDef>),
249 AllocationUsage(Node<AllocationUsage>),
250 FlowDef(Node<FlowDef>),
251 FlowUsage(Node<FlowUsage>),
252 ConcernUsage(Node<ConcernUsage>),
253 CaseDef(Node<CaseDef>),
254 CaseUsage(Node<CaseUsage>),
255 AnalysisCaseDef(Node<AnalysisCaseDef>),
256 AnalysisCaseUsage(Node<AnalysisCaseUsage>),
257 VerificationCaseDef(Node<VerificationCaseDef>),
258 VerificationCaseUsage(Node<VerificationCaseUsage>),
259 UseCaseUsage(Node<UseCaseUsage>),
260 FeatureDecl(Node<FeatureDecl>),
261 ClassifierDecl(Node<ClassifierDecl>),
262 KermlSemanticDecl(Node<KermlSemanticDecl>),
263 KermlFeatureDecl(Node<KermlFeatureDecl>),
264 ExtendedLibraryDecl(Node<ExtendedLibraryDecl>),
265}
266
267#[derive(Debug, Clone, PartialEq, Eq)]
269pub struct Package {
270 pub identification: Identification,
271 pub body: PackageBody,
272}
273
274#[derive(Debug, Clone, PartialEq, Eq)]
277pub struct Identification {
278 pub short_name: Option<String>,
280 pub name: Option<String>,
282}
283
284#[derive(Debug, Clone, PartialEq, Eq)]
286pub enum PackageBody {
287 Semicolon,
289 Brace {
291 elements: Vec<Node<PackageBodyElement>>,
292 },
293}
294
295#[derive(Debug, Clone, Copy, PartialEq, Eq)]
297pub enum Visibility {
298 Public,
299 Private,
300 Protected,
301}
302
303#[derive(Debug, Clone, PartialEq, Eq)]
305pub struct FilterPackageMember {
306 pub expression: Node<Expression>,
307}
308
309#[derive(Debug, Clone, PartialEq, Eq)]
311pub struct Import {
312 pub visibility: Option<Visibility>,
313 pub is_import_all: bool,
315 pub target: String,
317 pub is_recursive: bool,
319 pub filter_members: Option<Vec<Node<FilterPackageMember>>>,
321}
322
323#[derive(Debug, Clone, PartialEq, Eq)]
325pub struct PartDef {
326 pub definition_prefix: Option<DefinitionPrefix>,
328 pub is_individual: bool,
330 pub identification: Identification,
331 pub specializes: Option<String>,
333 pub specializes_span: Option<Span>,
335 pub body: PartDefBody,
336}
337
338#[derive(Debug, Clone, PartialEq, Eq)]
340pub enum DefinitionPrefix {
341 Abstract,
342 Variation,
343}
344
345#[derive(Debug, Clone, PartialEq, Eq)]
347pub enum PartDefBody {
348 Semicolon,
349 Brace {
350 elements: Vec<Node<PartDefBodyElement>>,
351 },
352}
353
354#[derive(Debug, Clone, PartialEq, Eq)]
356pub enum PartDefBodyElement {
357 Error(Node<ParseErrorNode>),
358 Doc(Node<DocComment>),
359 Comment(Node<CommentAnnotation>),
360 Annotation(Node<Annotation>),
361 Other(String),
362 AttributeDef(Node<AttributeDef>),
363 AttributeUsage(Node<AttributeUsage>),
364 RequirementUsage(Node<RequirementUsage>),
365 Ref(Node<RefDecl>),
366 PortUsage(Node<PortUsage>),
367 PartUsage(Box<Node<PartUsage>>),
368 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
369 InterfaceDef(Node<InterfaceDef>),
370 InterfaceUsage(Node<InterfaceUsage>),
371 Connect(Node<Connect>),
372 Connection(Node<ConnectionUsageMember>),
374 Perform(Node<Perform>),
375 Allocate(Node<Allocate>),
376 OpaqueMember(Node<OpaqueMemberDecl>),
377 ExhibitState(Node<ExhibitState>),
379}
380
381#[derive(Debug, Clone, PartialEq, Eq)]
383pub struct OpaqueMemberDecl {
384 pub keyword: String,
385 pub name: String,
386 pub text: String,
387 pub body: AttributeBody,
388}
389
390#[derive(Debug, Clone, PartialEq, Eq)]
392pub struct ConnectionUsageMember {
393 pub name: Option<String>,
394 pub type_name: Option<String>,
395 pub body: ConnectionDefBody,
396 pub subsets: Option<String>,
397 pub redefines: Option<String>,
398}
399
400#[derive(Debug, Clone, PartialEq, Eq)]
402pub struct ExhibitState {
403 pub name: String,
404 pub type_name: Option<String>,
405 pub redefines: Option<String>,
406 pub body: StateDefBody,
407}
408
409#[derive(Debug, Clone, PartialEq, Eq)]
411pub struct AttributeDef {
412 pub name: String,
413 pub typing: Option<String>,
415 pub value: Option<Node<Expression>>,
417 pub body: AttributeBody,
418 pub name_span: Option<Span>,
420 pub typing_span: Option<Span>,
422}
423
424#[derive(Debug, Clone, PartialEq, Eq)]
426pub enum AttributeBody {
427 Semicolon,
428 Brace,
429}
430
431#[derive(Debug, Clone, PartialEq, Eq)]
433pub struct ItemDef {
434 pub identification: Identification,
435 pub body: AttributeBody,
436}
437
438#[derive(Debug, Clone, PartialEq, Eq)]
440pub struct IndividualDef {
441 pub identification: Identification,
442 pub specializes: Option<String>,
443 pub body: AttributeBody,
444}
445
446#[derive(Debug, Clone, PartialEq, Eq)]
448pub struct PartUsage {
449 pub is_individual: bool,
450 pub name: String,
451 pub type_name: String,
453 pub multiplicity: Option<String>,
455 pub ordered: bool,
456 pub subsets: Option<(String, Option<Node<Expression>>)>,
458 pub redefines: Option<String>,
460 pub value: Option<Node<Expression>>,
462 pub body: PartUsageBody,
463 pub name_span: Option<Span>,
465 pub type_ref_span: Option<Span>,
467}
468
469#[derive(Debug, Clone, PartialEq, Eq)]
471pub enum PartUsageBody {
472 Semicolon,
473 Brace {
474 elements: Vec<Node<PartUsageBodyElement>>,
475 },
476}
477
478#[derive(Debug, Clone, PartialEq, Eq)]
480pub struct MetadataAnnotation {
481 pub name: String,
482 pub type_name: Option<String>,
483 pub body: ConnectBody,
484}
485
486#[derive(Debug, Clone, PartialEq, Eq)]
488pub struct Annotation {
489 pub sigil: String,
490 pub head: String,
491 pub type_name: Option<String>,
492 pub body: ConnectBody,
493}
494
495#[derive(Debug, Clone, PartialEq, Eq)]
497pub enum PartUsageBodyElement {
498 Error(Node<ParseErrorNode>),
499 Doc(Node<DocComment>),
500 Annotation(Node<Annotation>),
501 AttributeUsage(Node<AttributeUsage>),
502 PartUsage(Box<Node<PartUsage>>),
503 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
504 PortUsage(Node<PortUsage>),
505 Bind(Node<Bind>),
506 Ref(Node<RefDecl>),
508 InterfaceUsage(Node<InterfaceUsage>),
509 Connect(Node<Connect>),
510 Perform(Node<Perform>),
511 Allocate(Node<Allocate>),
512 Satisfy(Node<Satisfy>),
513 StateUsage(Node<StateUsage>),
514 MetadataAnnotation(Node<MetadataAnnotation>),
515}
516
517#[derive(Debug, Clone, PartialEq, Eq)]
519pub struct Perform {
520 pub action_name: String,
522 pub type_name: Option<String>,
524 pub body: PerformBody,
525}
526
527#[derive(Debug, Clone, PartialEq, Eq)]
529pub enum PerformBody {
530 Semicolon,
531 Brace {
532 elements: Vec<Node<PerformBodyElement>>,
533 },
534}
535
536#[derive(Debug, Clone, PartialEq, Eq)]
538pub enum PerformBodyElement {
539 Doc(Node<DocComment>),
540 InOut(Node<PerformInOutBinding>),
541}
542
543#[derive(Debug, Clone, PartialEq, Eq)]
545pub struct PerformInOutBinding {
546 pub direction: InOut,
547 pub name: String,
548 pub value: Node<Expression>,
549}
550
551#[derive(Debug, Clone, PartialEq, Eq)]
553pub struct AttributeUsage {
554 pub name: String,
555 pub typing: Option<String>,
557 pub redefines: Option<String>,
559 pub value: Option<Node<Expression>>,
561 pub body: AttributeBody,
562 pub name_span: Option<Span>,
564 pub typing_span: Option<Span>,
566 pub redefines_span: Option<Span>,
568}
569
570#[derive(Debug, Clone, PartialEq, Eq)]
576pub struct PortDef {
577 pub identification: Identification,
578 pub specializes: Option<String>,
580 pub body: PortDefBody,
581}
582
583#[derive(Debug, Clone, PartialEq, Eq)]
585pub enum PortDefBody {
586 Semicolon,
587 Brace {
588 elements: Vec<Node<PortDefBodyElement>>,
589 },
590}
591
592#[derive(Debug, Clone, PartialEq, Eq)]
594pub enum PortDefBodyElement {
595 InOutDecl(Node<InOutDecl>),
596 Doc(Node<DocComment>),
597 AttributeDef(Node<AttributeDef>),
598 AttributeUsage(Node<AttributeUsage>),
599 PortUsage(Node<PortUsage>),
600}
601
602#[derive(Debug, Clone, PartialEq, Eq)]
604pub struct PortUsage {
605 pub name: String,
606 pub type_name: Option<String>,
607 pub multiplicity: Option<String>,
608 pub subsets: Option<(String, Option<Node<Expression>>)>,
610 pub redefines: Option<String>,
611 pub body: PortBody,
612 pub name_span: Option<Span>,
614 pub type_ref_span: Option<Span>,
616}
617
618#[derive(Debug, Clone, PartialEq, Eq)]
620pub enum PortBody {
621 Semicolon,
622 Brace,
623 BraceWithPorts {
625 elements: Vec<Node<PortUsage>>,
626 },
627}
628
629#[derive(Debug, Clone, PartialEq, Eq)]
635pub struct InterfaceDef {
636 pub identification: Identification,
637 pub body: InterfaceDefBody,
638}
639
640#[derive(Debug, Clone, PartialEq, Eq)]
642pub enum InterfaceDefBody {
643 Semicolon,
644 Brace {
645 elements: Vec<Node<InterfaceDefBodyElement>>,
646 },
647}
648
649#[derive(Debug, Clone, PartialEq, Eq)]
651pub enum InterfaceDefBodyElement {
652 Doc(Node<DocComment>),
653 EndDecl(Node<EndDecl>),
654 RefDecl(Node<RefDecl>),
655 ConnectStmt(Node<ConnectStmt>),
656}
657
658#[derive(Debug, Clone, PartialEq, Eq)]
660pub struct EndDecl {
661 pub name: String,
662 pub type_name: String,
663 pub uses_derived_syntax: bool,
664 pub name_span: Option<Span>,
666 pub type_ref_span: Option<Span>,
668}
669
670#[derive(Debug, Clone, PartialEq, Eq)]
672pub struct RefDecl {
673 pub name: String,
674 pub type_name: String,
675 pub value: Option<Node<Expression>>,
677 pub body: RefBody,
678 pub name_span: Option<Span>,
680 pub type_ref_span: Option<Span>,
682}
683
684#[derive(Debug, Clone, PartialEq, Eq)]
686pub enum RefBody {
687 Semicolon,
688 Brace,
689}
690
691#[derive(Debug, Clone, PartialEq, Eq)]
697pub struct ConnectionDef {
698 pub annotation: Option<String>,
699 pub identification: Identification,
700 pub body: ConnectionDefBody,
701}
702
703#[derive(Debug, Clone, PartialEq, Eq)]
705pub enum ConnectionDefBody {
706 Semicolon,
707 Brace {
708 elements: Vec<Node<ConnectionDefBodyElement>>,
709 },
710}
711
712#[derive(Debug, Clone, PartialEq, Eq)]
713pub enum ConnectionDefBodyElement {
714 EndDecl(Node<EndDecl>),
715 RefDecl(Node<RefDecl>),
716 ConnectStmt(Node<ConnectStmt>),
717}
718
719#[derive(Debug, Clone, PartialEq, Eq)]
725pub struct MetadataDef {
726 pub is_abstract: bool,
727 pub identification: Identification,
728 pub body: DefinitionBody,
729}
730
731#[derive(Debug, Clone, PartialEq, Eq)]
737pub struct EnumDef {
738 pub identification: Identification,
739 pub body: EnumerationBody,
740}
741
742#[derive(Debug, Clone, PartialEq, Eq)]
743pub enum EnumerationBody {
744 Semicolon,
745 Brace { values: Vec<String> },
746}
747
748#[derive(Debug, Clone, PartialEq, Eq)]
754pub struct OccurrenceDef {
755 pub is_abstract: bool,
756 pub identification: Identification,
757 pub body: DefinitionBody,
758}
759
760#[derive(Debug, Clone, PartialEq, Eq)]
762pub struct OccurrenceUsage {
763 pub is_individual: bool,
764 pub is_then: bool,
765 pub portion_kind: Option<String>,
766 pub name: String,
767 pub type_name: Option<String>,
768 pub subsets: Option<String>,
769 pub redefines: Option<String>,
770 pub body: OccurrenceUsageBody,
771}
772
773#[derive(Debug, Clone, PartialEq, Eq)]
774pub enum OccurrenceUsageBody {
775 Semicolon,
776 Brace {
777 elements: Vec<Node<OccurrenceBodyElement>>,
778 },
779}
780
781#[derive(Debug, Clone, PartialEq, Eq)]
783pub struct AssertConstraintMember {
784 pub body: ConstraintDefBody,
785}
786
787#[derive(Debug, Clone, PartialEq, Eq)]
788pub enum OccurrenceBodyElement {
789 Error(Node<ParseErrorNode>),
790 Doc(Node<DocComment>),
791 Annotation(Node<Annotation>),
792 AssertConstraint(Node<AssertConstraintMember>),
793 Other(String),
794 AttributeUsage(Node<AttributeUsage>),
795 PartUsage(Box<Node<PartUsage>>),
796 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
797}
798
799#[derive(Debug, Clone, PartialEq, Eq)]
805pub struct LibraryPackage {
806 pub is_standard: bool,
807 pub identification: Identification,
808 pub body: PackageBody,
809}
810
811#[derive(Debug, Clone, PartialEq, Eq)]
813pub enum DefinitionBody {
814 Semicolon,
815 Brace,
816}
817
818#[derive(Debug, Clone, PartialEq, Eq)]
820pub struct ConnectStmt {
821 pub from: Node<Expression>,
822 pub to: Node<Expression>,
823 pub body: ConnectBody,
824}
825
826#[derive(Debug, Clone, PartialEq, Eq)]
828pub enum ConnectBody {
829 Semicolon,
830 Brace,
831}
832
833#[derive(Debug, Clone, PartialEq, Eq)]
839pub struct Bind {
840 pub left: Node<Expression>,
841 pub right: Node<Expression>,
842 pub body: Option<ConnectBody>,
844}
845
846#[derive(Debug, Clone, PartialEq, Eq)]
848pub enum InterfaceUsage {
849 TypedConnect {
851 interface_type: Option<String>,
852 from: Node<Expression>,
853 to: Node<Expression>,
854 body: ConnectBody,
855 body_elements: Vec<Node<InterfaceUsageBodyElement>>,
856 },
857 Connection {
859 from: Node<Expression>,
860 to: Node<Expression>,
861 body_elements: Vec<Node<InterfaceUsageBodyElement>>,
862 },
863}
864
865#[derive(Debug, Clone, PartialEq, Eq)]
867pub enum InterfaceUsageBodyElement {
868 RefRedef {
870 name: String,
871 value: Node<Expression>,
872 body: RefBody,
873 },
874}
875
876#[derive(Debug, Clone, PartialEq, Eq)]
878pub struct Connect {
879 pub from: Node<Expression>,
880 pub to: Node<Expression>,
881 pub body: ConnectBody,
882}
883
884#[derive(Debug, Clone, PartialEq, Eq)]
890pub struct AliasDef {
891 pub identification: Identification,
892 pub target: String,
893 pub body: AliasBody,
894}
895
896#[derive(Debug, Clone, PartialEq, Eq)]
898pub enum AliasBody {
899 Semicolon,
900 Brace,
901}
902
903#[derive(Debug, Clone, PartialEq, Eq)]
909pub struct ActionDef {
910 pub identification: Identification,
911 pub body: ActionDefBody,
912}
913
914#[derive(Debug, Clone, PartialEq, Eq)]
916pub enum ActionDefBody {
917 Semicolon,
918 Brace {
919 elements: Vec<Node<ActionDefBodyElement>>,
920 },
921}
922
923#[derive(Debug, Clone, PartialEq, Eq)]
925pub enum ActionDefBodyElement {
926 Error(Node<ParseErrorNode>),
927 InOutDecl(Node<InOutDecl>),
928 Doc(Node<DocComment>),
929 Annotation(Node<Annotation>),
930 RefDecl(Node<RefDecl>),
931 Perform(Node<Perform>),
932 Bind(Node<Bind>),
933 Flow(Node<Flow>),
934 FirstStmt(Node<FirstStmt>),
935 MergeStmt(Node<MergeStmt>),
936 StateUsage(Node<StateUsage>),
937 ActionUsage(Box<Node<ActionUsage>>),
938 Assign(Node<AssignStmt>),
939 ForLoop(Node<ForLoop>),
940 ThenAction(Node<ThenAction>),
941 Decl(Node<ActionBodyDecl>),
942}
943
944#[derive(Debug, Clone, PartialEq, Eq)]
950pub struct AssignStmt {
951 pub is_then: bool,
952 pub lhs: String,
953 pub rhs: String,
954}
955
956#[derive(Debug, Clone, PartialEq, Eq)]
958pub struct ForLoop {
959 pub var: String,
960 pub range: String,
961 pub body: ActionDefBody,
962}
963
964#[derive(Debug, Clone, PartialEq, Eq)]
966pub struct ThenAction {
967 pub action: Node<ActionUsage>,
968}
969
970#[derive(Debug, Clone, PartialEq, Eq)]
972pub struct InOutDecl {
973 pub direction: InOut,
974 pub name: String,
975 pub type_name: String,
976}
977
978#[derive(Debug, Clone, Copy, PartialEq, Eq)]
979pub enum InOut {
980 In,
981 Out,
982 InOut,
983}
984
985#[derive(Debug, Clone, PartialEq, Eq)]
987pub struct ActionUsage {
988 pub name: String,
989 pub type_name: String,
990 pub accept: Option<(String, String)>,
992 pub body: ActionUsageBody,
993 pub name_span: Option<Span>,
995 pub type_ref_span: Option<Span>,
997}
998
999#[derive(Debug, Clone, PartialEq, Eq)]
1001pub enum ActionUsageBody {
1002 Semicolon,
1003 Brace {
1004 elements: Vec<Node<ActionUsageBodyElement>>,
1005 },
1006}
1007
1008#[derive(Debug, Clone, PartialEq, Eq)]
1010pub enum ActionUsageBodyElement {
1011 Error(Node<ParseErrorNode>),
1012 Doc(Node<DocComment>),
1013 Annotation(Node<Annotation>),
1014 InOutDecl(Node<InOutDecl>),
1015 RefDecl(Node<RefDecl>),
1016 Bind(Node<Bind>),
1017 Flow(Node<Flow>),
1018 FirstStmt(Node<FirstStmt>),
1019 MergeStmt(Node<MergeStmt>),
1020 StateUsage(Node<StateUsage>),
1021 ActionUsage(Box<Node<ActionUsage>>),
1022 Assign(Node<AssignStmt>),
1023 ForLoop(Node<ForLoop>),
1024 ThenAction(Node<ThenAction>),
1025 Decl(Node<ActionBodyDecl>),
1026}
1027
1028#[derive(Debug, Clone, PartialEq, Eq)]
1030pub struct ActionBodyDecl {
1031 pub keyword: String,
1032 pub text: String,
1033}
1034
1035#[derive(Debug, Clone, PartialEq, Eq)]
1037pub struct Flow {
1038 pub from: Node<Expression>,
1039 pub to: Node<Expression>,
1040 pub body: ConnectBody,
1041}
1042
1043#[derive(Debug, Clone, PartialEq, Eq)]
1045pub struct FlowDef {
1046 pub identification: Identification,
1047 pub body: DefinitionBody,
1048}
1049
1050#[derive(Debug, Clone, PartialEq, Eq)]
1052pub struct FlowUsage {
1053 pub name: String,
1054 pub type_name: Option<String>,
1055 pub from: Option<Node<Expression>>,
1056 pub to: Option<Node<Expression>>,
1057 pub body: DefinitionBody,
1058}
1059
1060#[derive(Debug, Clone, PartialEq, Eq)]
1062pub struct FirstStmt {
1063 pub first: Node<Expression>,
1064 pub then: Node<Expression>,
1065 pub body: FirstMergeBody,
1066}
1067
1068#[derive(Debug, Clone, PartialEq, Eq)]
1070pub struct MergeStmt {
1071 pub merge: Node<Expression>,
1072 pub body: FirstMergeBody,
1073}
1074
1075#[derive(Debug, Clone, PartialEq, Eq)]
1077pub enum FirstMergeBody {
1078 Semicolon,
1079 Brace,
1080}
1081
1082#[derive(Debug, Clone, PartialEq, Eq)]
1088pub struct Allocate {
1089 pub source: Node<Expression>,
1090 pub target: Node<Expression>,
1091 pub body: ConnectBody,
1092}
1093
1094#[derive(Debug, Clone, PartialEq, Eq)]
1096pub struct AllocationDef {
1097 pub identification: Identification,
1098 pub body: DefinitionBody,
1099}
1100
1101#[derive(Debug, Clone, PartialEq, Eq)]
1103pub struct AllocationUsage {
1104 pub name: String,
1105 pub type_name: Option<String>,
1106 pub source: Option<Node<Expression>>,
1107 pub target: Option<Node<Expression>>,
1108 pub body: DefinitionBody,
1109}
1110
1111#[derive(Debug, Clone, PartialEq, Eq)]
1117pub struct RequirementDef {
1118 pub identification: Identification,
1119 pub body: RequirementDefBody,
1120}
1121
1122#[derive(Debug, Clone, PartialEq, Eq)]
1124pub enum RequirementDefBody {
1125 Semicolon,
1126 Brace {
1127 elements: Vec<Node<RequirementDefBodyElement>>,
1128 },
1129}
1130
1131#[derive(Debug, Clone, PartialEq, Eq)]
1132pub enum RequirementDefBodyElement {
1133 Error(Node<ParseErrorNode>),
1134 Other(String),
1136 Annotation(Node<Annotation>),
1137 Import(Node<Import>),
1138 SubjectDecl(Node<SubjectDecl>),
1139 AttributeDef(Node<AttributeDef>),
1140 AttributeUsage(Node<AttributeUsage>),
1141 VerifyRequirement(Node<VerifyRequirementMember>),
1142 RequireConstraint(Node<RequireConstraint>),
1143 Frame(Node<FrameMember>),
1144 Doc(Node<DocComment>),
1145}
1146
1147#[derive(Debug, Clone, PartialEq, Eq)]
1149pub struct SubjectDecl {
1150 pub name: String,
1151 pub type_name: String,
1152}
1153
1154#[derive(Debug, Clone, PartialEq, Eq)]
1156pub struct RequireConstraint {
1157 pub body: RequireConstraintBody,
1158}
1159
1160#[derive(Debug, Clone, PartialEq, Eq)]
1163pub struct VerifyRequirementMember {
1164 pub explicit_requirement_keyword: bool,
1166 pub requirement: Option<Node<RequirementUsage>>,
1168 pub target: Option<String>,
1170}
1171
1172#[derive(Debug, Clone, PartialEq, Eq)]
1174pub enum RequireConstraintBody {
1175 Semicolon,
1176 Brace {
1177 elements: Vec<Node<ConstraintDefBodyElement>>,
1178 },
1179}
1180
1181#[derive(Debug, Clone, PartialEq, Eq)]
1183pub struct Satisfy {
1184 pub source: Node<Expression>,
1185 pub target: Node<Expression>,
1186 pub body: ConnectBody,
1187}
1188
1189#[derive(Debug, Clone, PartialEq, Eq)]
1191pub struct RequirementUsage {
1192 pub name: String,
1193 pub type_name: Option<String>,
1194 pub subsets: Option<String>,
1195 pub body: RequirementDefBody,
1196}
1197
1198#[derive(Debug, Clone, PartialEq, Eq)]
1200pub struct Dependency {
1201 pub identification: Option<Identification>,
1202 pub clients: Vec<String>,
1203 pub suppliers: Vec<String>,
1204 pub body: ConnectBody,
1205}
1206
1207#[derive(Debug, Clone, PartialEq, Eq)]
1209pub struct FrameMember {
1210 pub name: String,
1211 pub body: RequirementDefBody,
1212}
1213
1214#[derive(Debug, Clone, PartialEq, Eq)]
1216pub struct ConcernUsage {
1217 pub name: String,
1218 pub type_name: Option<String>,
1219 pub body: RequirementDefBody,
1220}
1221
1222#[derive(Debug, Clone, PartialEq, Eq)]
1224pub struct CaseDef {
1225 pub identification: Identification,
1226 pub body: UseCaseDefBody,
1227}
1228
1229#[derive(Debug, Clone, PartialEq, Eq)]
1231pub struct CaseUsage {
1232 pub name: String,
1233 pub type_name: Option<String>,
1234 pub body: UseCaseDefBody,
1235}
1236
1237#[derive(Debug, Clone, PartialEq, Eq)]
1239pub struct AnalysisCaseDef {
1240 pub identification: Identification,
1241 pub body: UseCaseDefBody,
1242}
1243
1244#[derive(Debug, Clone, PartialEq, Eq)]
1246pub struct AnalysisCaseUsage {
1247 pub name: String,
1248 pub type_name: Option<String>,
1249 pub body: UseCaseDefBody,
1250}
1251
1252#[derive(Debug, Clone, PartialEq, Eq)]
1254pub struct VerificationCaseDef {
1255 pub identification: Identification,
1256 pub body: UseCaseDefBody,
1257}
1258
1259#[derive(Debug, Clone, PartialEq, Eq)]
1261pub struct VerificationCaseUsage {
1262 pub name: String,
1263 pub type_name: Option<String>,
1264 pub body: UseCaseDefBody,
1265}
1266
1267#[derive(Debug, Clone, PartialEq, Eq)]
1269pub struct UseCaseUsage {
1270 pub name: String,
1271 pub type_name: Option<String>,
1272 pub body: UseCaseDefBody,
1273}
1274
1275#[derive(Debug, Clone, PartialEq, Eq)]
1281pub struct ActorDecl {
1282 pub identification: Identification,
1283}
1284
1285#[derive(Debug, Clone, PartialEq, Eq)]
1287pub struct UseCaseDef {
1288 pub identification: Identification,
1289 pub body: UseCaseDefBody,
1290}
1291
1292#[derive(Debug, Clone, PartialEq, Eq)]
1293pub enum UseCaseDefBody {
1294 Semicolon,
1295 Brace {
1296 elements: Vec<Node<UseCaseDefBodyElement>>,
1297 },
1298}
1299
1300#[derive(Debug, Clone, PartialEq, Eq)]
1302pub struct FirstSuccession {
1303 pub target: String,
1304}
1305
1306#[derive(Debug, Clone, PartialEq, Eq)]
1308pub struct ThenDone {}
1309
1310#[derive(Debug, Clone, PartialEq, Eq)]
1312pub struct IncludeUseCase {
1313 pub name: String,
1314 pub multiplicity: Option<String>,
1316 pub body: UseCaseDefBody,
1317}
1318
1319#[derive(Debug, Clone, PartialEq, Eq)]
1321pub struct ThenIncludeUseCase {
1322 pub include: Node<IncludeUseCase>,
1323}
1324
1325#[derive(Debug, Clone, PartialEq, Eq)]
1327pub struct ThenUseCaseUsage {
1328 pub use_case: Node<UseCaseUsage>,
1329}
1330
1331#[derive(Debug, Clone, PartialEq, Eq)]
1333pub struct SubjectRef {}
1334
1335#[derive(Debug, Clone, PartialEq, Eq)]
1337pub struct ActorRedefinitionAssignment {
1338 pub name: String,
1339 pub rhs: String,
1341}
1342
1343#[derive(Debug, Clone, PartialEq, Eq)]
1345pub struct RefRedefinition {
1346 pub name: String,
1347 pub body: String,
1349}
1350
1351#[derive(Debug, Clone, PartialEq, Eq)]
1353pub struct ReturnRef {
1354 pub name: String,
1355 pub multiplicity: Option<String>,
1356 pub body: String,
1358}
1359
1360#[derive(Debug, Clone, PartialEq, Eq)]
1361pub enum UseCaseDefBodyElement {
1362 Error(Node<ParseErrorNode>),
1363 Other(String),
1365 AttributeDef(Node<AttributeDef>),
1366 Doc(Node<DocComment>),
1367 SubjectDecl(Node<SubjectDecl>),
1368 SubjectRef(Node<SubjectRef>),
1370 ActorUsage(Node<ActorUsage>),
1371 ActorRedefinitionAssignment(Node<ActorRedefinitionAssignment>),
1372 Objective(Node<Objective>),
1373 FirstSuccession(Node<FirstSuccession>),
1374 ThenIncludeUseCase(Node<ThenIncludeUseCase>),
1375 ThenUseCaseUsage(Node<ThenUseCaseUsage>),
1376 ThenDone(Node<ThenDone>),
1377 IncludeUseCase(Node<IncludeUseCase>),
1378 RefRedefinition(Node<RefRedefinition>),
1379 ReturnRef(Node<ReturnRef>),
1380 Assign(Node<AssignStmt>),
1381 ForLoop(Node<ForLoop>),
1382 ThenAction(Node<ThenAction>),
1383}
1384
1385#[derive(Debug, Clone, PartialEq, Eq)]
1387pub struct ActorUsage {
1388 pub name: String,
1389 pub type_name: String,
1390}
1391
1392#[derive(Debug, Clone, PartialEq, Eq)]
1394pub struct Objective {
1395 pub visibility: Option<Visibility>,
1396 pub requirement: Node<RequirementUsage>,
1397}
1398
1399#[derive(Debug, Clone, PartialEq, Eq)]
1405pub struct StateDef {
1406 pub identification: Identification,
1407 pub body: StateDefBody,
1408}
1409
1410#[derive(Debug, Clone, PartialEq, Eq)]
1411pub enum StateDefBody {
1412 Semicolon,
1413 Brace {
1414 elements: Vec<Node<StateDefBodyElement>>,
1415 },
1416}
1417
1418#[derive(Debug, Clone, PartialEq, Eq)]
1419pub enum StateDefBodyElement {
1420 Error(Node<ParseErrorNode>),
1421 Doc(Node<DocComment>),
1422 Annotation(Node<Annotation>),
1423 Other(String),
1424 Entry(Node<EntryAction>),
1426 Then(Node<ThenStmt>),
1428 Ref(Node<RefDecl>),
1430 RequirementUsage(Node<RequirementUsage>),
1431 StateUsage(Node<StateUsage>),
1432 Transition(Node<Transition>),
1433}
1434
1435#[derive(Debug, Clone, PartialEq, Eq)]
1437pub struct EntryAction {
1438 pub action_name: Option<String>,
1440 pub body: StateDefBody,
1441}
1442
1443#[derive(Debug, Clone, PartialEq, Eq)]
1445pub struct ThenStmt {
1446 pub state_name: String,
1447}
1448
1449#[derive(Debug, Clone, PartialEq, Eq)]
1451pub struct StateUsage {
1452 pub name: String,
1453 pub type_name: Option<String>,
1454 pub body: StateDefBody,
1455}
1456
1457#[derive(Debug, Clone, PartialEq, Eq)]
1459pub struct Transition {
1460 pub name: Option<String>,
1461 pub source: Option<Node<Expression>>,
1463 pub guard: Option<Node<Expression>>,
1464 pub effect: Option<Node<Expression>>,
1465 pub target: Node<Expression>,
1466 pub body: ConnectBody,
1467}
1468
1469#[derive(Debug, Clone, PartialEq, Eq)]
1475pub struct ConstraintDef {
1476 pub identification: Identification,
1477 pub body: ConstraintDefBody,
1478}
1479
1480#[derive(Debug, Clone, PartialEq, Eq)]
1481pub enum ConstraintDefBody {
1482 Semicolon,
1483 Brace {
1484 elements: Vec<Node<ConstraintDefBodyElement>>,
1485 },
1486}
1487
1488#[derive(Debug, Clone, PartialEq, Eq)]
1489pub enum ConstraintDefBodyElement {
1490 Error(Node<ParseErrorNode>),
1491 Doc(Node<DocComment>),
1492 InOutDecl(Node<InOutDecl>),
1493 Expression(Node<Expression>), Other(String),
1496}
1497
1498#[derive(Debug, Clone, PartialEq, Eq)]
1500pub enum ConstraintBody {
1501 Semicolon,
1502 Brace, }
1504
1505#[derive(Debug, Clone, PartialEq, Eq)]
1507pub struct DocComment {
1508 pub identification: Option<Identification>,
1510 pub locale: Option<String>,
1512 pub text: String,
1514}
1515
1516#[derive(Debug, Clone, PartialEq, Eq)]
1518pub struct CommentAnnotation {
1519 pub identification: Option<Identification>,
1520 pub locale: Option<String>,
1521 pub text: String,
1522}
1523
1524#[derive(Debug, Clone, PartialEq, Eq)]
1526pub struct TextualRepresentation {
1527 pub rep_identification: Option<Identification>,
1528 pub language: String,
1529 pub text: String,
1530}
1531
1532#[derive(Debug, Clone, PartialEq, Eq)]
1534pub struct CalcDef {
1535 pub identification: Identification,
1536 pub body: CalcDefBody,
1537}
1538
1539#[derive(Debug, Clone, PartialEq, Eq)]
1540pub enum CalcDefBody {
1541 Semicolon,
1542 Brace {
1543 elements: Vec<Node<CalcDefBodyElement>>,
1544 },
1545}
1546
1547#[derive(Debug, Clone, PartialEq, Eq)]
1548pub enum CalcDefBodyElement {
1549 Error(Node<ParseErrorNode>),
1550 Doc(Node<DocComment>),
1551 InOutDecl(Node<InOutDecl>),
1552 ReturnDecl(Node<ReturnDecl>),
1553 Expression(Node<Expression>), Other(String),
1556}
1557
1558#[derive(Debug, Clone, PartialEq, Eq)]
1560pub struct ReturnDecl {
1561 pub name: String,
1562 pub type_name: String,
1563}
1564
1565#[derive(Debug, Clone, PartialEq, Eq)]
1571pub struct ViewDef {
1572 pub identification: Identification,
1573 pub body: ViewDefBody,
1574}
1575
1576#[derive(Debug, Clone, PartialEq, Eq)]
1577pub enum ViewDefBody {
1578 Semicolon,
1579 Brace {
1580 elements: Vec<Node<ViewDefBodyElement>>,
1581 },
1582}
1583
1584#[derive(Debug, Clone, PartialEq, Eq)]
1585pub enum ViewDefBodyElement {
1586 Error(Node<ParseErrorNode>),
1587 Other(String),
1589 Doc(Node<DocComment>),
1590 Filter(Node<FilterMember>),
1591 ViewRendering(Node<ViewRenderingUsage>),
1592}
1593
1594#[derive(Debug, Clone, PartialEq, Eq)]
1596pub struct ViewRenderingUsage {
1597 pub name: String,
1598 pub type_name: Option<String>,
1599 pub body: ConnectBody,
1600}
1601
1602#[derive(Debug, Clone, PartialEq, Eq)]
1604pub struct ViewpointDef {
1605 pub identification: Identification,
1606 pub body: RequirementDefBody,
1607}
1608
1609#[derive(Debug, Clone, PartialEq, Eq)]
1611pub struct RenderingDef {
1612 pub identification: Identification,
1613 pub body: RenderingDefBody,
1614}
1615
1616#[derive(Debug, Clone, PartialEq, Eq)]
1617pub enum RenderingDefBody {
1618 Semicolon,
1619 Brace,
1620}
1621
1622#[derive(Debug, Clone, PartialEq, Eq)]
1624pub struct ViewUsage {
1625 pub name: String,
1626 pub type_name: Option<String>,
1627 pub body: ViewBody,
1628}
1629
1630#[derive(Debug, Clone, PartialEq, Eq)]
1631pub enum ViewBody {
1632 Semicolon,
1633 Brace {
1634 elements: Vec<Node<ViewBodyElement>>,
1635 },
1636}
1637
1638#[derive(Debug, Clone, PartialEq, Eq)]
1639pub enum ViewBodyElement {
1640 Error(Node<ParseErrorNode>),
1641 Other(String),
1643 Doc(Node<DocComment>),
1644 Filter(Node<FilterMember>),
1645 ViewRendering(Node<ViewRenderingUsage>),
1646 Expose(Node<ExposeMember>),
1647 Satisfy(Node<SatisfyViewMember>),
1648}
1649
1650#[derive(Debug, Clone, PartialEq, Eq)]
1652pub struct ExposeMember {
1653 pub target: String,
1655 pub body: ConnectBody,
1656}
1657
1658#[derive(Debug, Clone, PartialEq, Eq)]
1660pub struct SatisfyViewMember {
1661 pub viewpoint_ref: String,
1662 pub body: ConnectBody,
1663}
1664
1665#[derive(Debug, Clone, PartialEq, Eq)]
1667pub struct ViewpointUsage {
1668 pub name: String,
1669 pub type_name: String,
1670 pub body: RequirementDefBody,
1671}
1672
1673#[derive(Debug, Clone, PartialEq, Eq)]
1675pub struct RenderingUsage {
1676 pub name: String,
1677 pub type_name: Option<String>,
1678 pub body: ConnectBody,
1679}
1680
1681impl RootNamespace {
1686 pub fn normalize_for_test_comparison(&self) -> Self {
1689 RootNamespace {
1690 elements: self
1691 .elements
1692 .iter()
1693 .map(normalize_root_element_node)
1694 .collect(),
1695 }
1696 }
1697}
1698
1699fn dummy_node<T: Clone>(_n: &Node<T>, value: T) -> Node<T> {
1700 Node::new(Span::dummy(), value)
1701}
1702
1703fn normalize_root_element_node(el: &Node<RootElement>) -> Node<RootElement> {
1704 let value = match &el.value {
1705 RootElement::Package(p) => RootElement::Package(dummy_node(p, normalize_package(&p.value))),
1706 RootElement::LibraryPackage(lp) => {
1707 RootElement::LibraryPackage(dummy_node(lp, normalize_library_package(&lp.value)))
1708 }
1709 RootElement::Namespace(n) => {
1710 RootElement::Namespace(dummy_node(n, normalize_namespace_decl(&n.value)))
1711 }
1712 RootElement::Import(n) => RootElement::Import(dummy_node(n, n.value.clone())),
1713 };
1714 dummy_node(el, value)
1715}
1716
1717fn normalize_library_package(lp: &LibraryPackage) -> LibraryPackage {
1718 LibraryPackage {
1719 is_standard: lp.is_standard,
1720 identification: lp.identification.clone(),
1721 body: normalize_package_body(&lp.body),
1722 }
1723}
1724
1725fn normalize_namespace_decl(n: &NamespaceDecl) -> NamespaceDecl {
1726 NamespaceDecl {
1727 identification: n.identification.clone(),
1728 body: normalize_package_body(&n.body),
1729 }
1730}
1731
1732fn normalize_package(p: &Package) -> Package {
1733 Package {
1734 identification: p.identification.clone(),
1735 body: normalize_package_body(&p.body),
1736 }
1737}
1738
1739fn normalize_package_body(b: &PackageBody) -> PackageBody {
1740 match b {
1741 PackageBody::Semicolon => PackageBody::Semicolon,
1742 PackageBody::Brace { elements } => PackageBody::Brace {
1743 elements: elements
1744 .iter()
1745 .map(normalize_package_body_element_node)
1746 .collect(),
1747 },
1748 }
1749}
1750
1751fn normalize_package_body_element_node(el: &Node<PackageBodyElement>) -> Node<PackageBodyElement> {
1752 let value = match &el.value {
1753 PackageBodyElement::Error(n) => PackageBodyElement::Error(dummy_node(n, n.value.clone())),
1754 PackageBodyElement::Doc(n) => PackageBodyElement::Doc(dummy_node(n, n.value.clone())),
1755 PackageBodyElement::Comment(n) => {
1756 PackageBodyElement::Comment(dummy_node(n, n.value.clone()))
1757 }
1758 PackageBodyElement::TextualRep(n) => {
1759 PackageBodyElement::TextualRep(dummy_node(n, n.value.clone()))
1760 }
1761 PackageBodyElement::Filter(n) => PackageBodyElement::Filter(dummy_node(n, n.value.clone())),
1762 PackageBodyElement::Package(n) => {
1763 PackageBodyElement::Package(dummy_node(n, normalize_package(&n.value)))
1764 }
1765 PackageBodyElement::LibraryPackage(n) => {
1766 PackageBodyElement::LibraryPackage(dummy_node(n, normalize_library_package(&n.value)))
1767 }
1768 PackageBodyElement::Import(n) => PackageBodyElement::Import(dummy_node(n, n.value.clone())),
1769 PackageBodyElement::PartDef(n) => {
1770 PackageBodyElement::PartDef(dummy_node(n, normalize_part_def(&n.value)))
1771 }
1772 PackageBodyElement::PartUsage(n) => {
1773 PackageBodyElement::PartUsage(dummy_node(n, normalize_part_usage(&n.value)))
1774 }
1775 PackageBodyElement::PortDef(n) => {
1776 PackageBodyElement::PortDef(dummy_node(n, normalize_port_def(&n.value)))
1777 }
1778 PackageBodyElement::InterfaceDef(n) => {
1779 PackageBodyElement::InterfaceDef(dummy_node(n, normalize_interface_def(&n.value)))
1780 }
1781 PackageBodyElement::ConnectionDef(n) => {
1782 PackageBodyElement::ConnectionDef(dummy_node(n, normalize_connection_def(&n.value)))
1783 }
1784 PackageBodyElement::MetadataDef(n) => {
1785 PackageBodyElement::MetadataDef(dummy_node(n, normalize_metadata_def(&n.value)))
1786 }
1787 PackageBodyElement::EnumDef(n) => {
1788 PackageBodyElement::EnumDef(dummy_node(n, normalize_enum_def(&n.value)))
1789 }
1790 PackageBodyElement::OccurrenceDef(n) => {
1791 PackageBodyElement::OccurrenceDef(dummy_node(n, normalize_occurrence_def(&n.value)))
1792 }
1793 PackageBodyElement::OccurrenceUsage(n) => {
1794 PackageBodyElement::OccurrenceUsage(dummy_node(n, n.value.clone()))
1795 }
1796 PackageBodyElement::AliasDef(n) => {
1797 PackageBodyElement::AliasDef(dummy_node(n, n.value.clone()))
1798 }
1799 PackageBodyElement::AttributeDef(n) => {
1800 PackageBodyElement::AttributeDef(dummy_node(n, normalize_attribute_def(&n.value)))
1801 }
1802 PackageBodyElement::ActionDef(n) => {
1803 PackageBodyElement::ActionDef(dummy_node(n, normalize_action_def(&n.value)))
1804 }
1805 PackageBodyElement::ActionUsage(n) => {
1806 PackageBodyElement::ActionUsage(dummy_node(n, normalize_action_usage(&n.value)))
1807 }
1808 PackageBodyElement::RequirementDef(n) => {
1809 PackageBodyElement::RequirementDef(dummy_node(n, n.value.clone()))
1810 }
1811 PackageBodyElement::RequirementUsage(n) => {
1812 PackageBodyElement::RequirementUsage(dummy_node(n, n.value.clone()))
1813 }
1814 PackageBodyElement::Satisfy(n) => {
1815 PackageBodyElement::Satisfy(dummy_node(n, n.value.clone()))
1816 }
1817 PackageBodyElement::UseCaseDef(n) => {
1818 PackageBodyElement::UseCaseDef(dummy_node(n, n.value.clone()))
1819 }
1820 PackageBodyElement::Actor(n) => PackageBodyElement::Actor(dummy_node(n, n.value.clone())),
1821 PackageBodyElement::StateDef(n) => {
1822 PackageBodyElement::StateDef(dummy_node(n, n.value.clone()))
1823 }
1824 PackageBodyElement::StateUsage(n) => {
1825 PackageBodyElement::StateUsage(dummy_node(n, n.value.clone()))
1826 }
1827 PackageBodyElement::ItemDef(n) => {
1828 PackageBodyElement::ItemDef(dummy_node(n, n.value.clone()))
1829 }
1830 PackageBodyElement::IndividualDef(n) => {
1831 PackageBodyElement::IndividualDef(dummy_node(n, n.value.clone()))
1832 }
1833 PackageBodyElement::ConstraintDef(n) => {
1834 PackageBodyElement::ConstraintDef(dummy_node(n, n.value.clone()))
1835 }
1836 PackageBodyElement::CalcDef(n) => {
1837 PackageBodyElement::CalcDef(dummy_node(n, n.value.clone()))
1838 }
1839 PackageBodyElement::ViewDef(n) => {
1840 PackageBodyElement::ViewDef(dummy_node(n, n.value.clone()))
1841 }
1842 PackageBodyElement::ViewpointDef(n) => {
1843 PackageBodyElement::ViewpointDef(dummy_node(n, n.value.clone()))
1844 }
1845 PackageBodyElement::RenderingDef(n) => {
1846 PackageBodyElement::RenderingDef(dummy_node(n, n.value.clone()))
1847 }
1848 PackageBodyElement::ViewUsage(n) => {
1849 PackageBodyElement::ViewUsage(dummy_node(n, n.value.clone()))
1850 }
1851 PackageBodyElement::ViewpointUsage(n) => {
1852 PackageBodyElement::ViewpointUsage(dummy_node(n, n.value.clone()))
1853 }
1854 PackageBodyElement::RenderingUsage(n) => {
1855 PackageBodyElement::RenderingUsage(dummy_node(n, n.value.clone()))
1856 }
1857 PackageBodyElement::Dependency(n) => {
1858 PackageBodyElement::Dependency(dummy_node(n, n.value.clone()))
1859 }
1860 PackageBodyElement::AllocationDef(n) => {
1861 PackageBodyElement::AllocationDef(dummy_node(n, n.value.clone()))
1862 }
1863 PackageBodyElement::AllocationUsage(n) => {
1864 PackageBodyElement::AllocationUsage(dummy_node(n, n.value.clone()))
1865 }
1866 PackageBodyElement::FlowDef(n) => {
1867 PackageBodyElement::FlowDef(dummy_node(n, n.value.clone()))
1868 }
1869 PackageBodyElement::FlowUsage(n) => {
1870 PackageBodyElement::FlowUsage(dummy_node(n, n.value.clone()))
1871 }
1872 PackageBodyElement::ConcernUsage(n) => {
1873 PackageBodyElement::ConcernUsage(dummy_node(n, n.value.clone()))
1874 }
1875 PackageBodyElement::CaseDef(n) => {
1876 PackageBodyElement::CaseDef(dummy_node(n, n.value.clone()))
1877 }
1878 PackageBodyElement::CaseUsage(n) => {
1879 PackageBodyElement::CaseUsage(dummy_node(n, n.value.clone()))
1880 }
1881 PackageBodyElement::AnalysisCaseDef(n) => {
1882 PackageBodyElement::AnalysisCaseDef(dummy_node(n, n.value.clone()))
1883 }
1884 PackageBodyElement::AnalysisCaseUsage(n) => {
1885 PackageBodyElement::AnalysisCaseUsage(dummy_node(n, n.value.clone()))
1886 }
1887 PackageBodyElement::VerificationCaseDef(n) => {
1888 PackageBodyElement::VerificationCaseDef(dummy_node(n, n.value.clone()))
1889 }
1890 PackageBodyElement::VerificationCaseUsage(n) => {
1891 PackageBodyElement::VerificationCaseUsage(dummy_node(n, n.value.clone()))
1892 }
1893 PackageBodyElement::UseCaseUsage(n) => {
1894 PackageBodyElement::UseCaseUsage(dummy_node(n, n.value.clone()))
1895 }
1896 PackageBodyElement::FeatureDecl(n) => {
1897 PackageBodyElement::FeatureDecl(dummy_node(n, n.value.clone()))
1898 }
1899 PackageBodyElement::ClassifierDecl(n) => {
1900 PackageBodyElement::ClassifierDecl(dummy_node(n, n.value.clone()))
1901 }
1902 PackageBodyElement::KermlSemanticDecl(n) => {
1903 PackageBodyElement::KermlSemanticDecl(dummy_node(n, n.value.clone()))
1904 }
1905 PackageBodyElement::KermlFeatureDecl(n) => {
1906 PackageBodyElement::KermlFeatureDecl(dummy_node(n, n.value.clone()))
1907 }
1908 PackageBodyElement::ExtendedLibraryDecl(n) => {
1909 PackageBodyElement::ExtendedLibraryDecl(dummy_node(n, n.value.clone()))
1910 }
1911 };
1912 dummy_node(el, value)
1913}
1914
1915fn normalize_attribute_def(a: &AttributeDef) -> AttributeDef {
1916 AttributeDef {
1917 name: a.name.clone(),
1918 typing: a.typing.clone(),
1919 value: a.value.clone(),
1920 body: a.body.clone(),
1921 name_span: None,
1922 typing_span: None,
1923 }
1924}
1925
1926fn normalize_part_def(p: &PartDef) -> PartDef {
1927 PartDef {
1928 definition_prefix: p.definition_prefix.clone(),
1929 is_individual: p.is_individual,
1930 identification: p.identification.clone(),
1931 specializes: p.specializes.clone(),
1932 specializes_span: None,
1933 body: normalize_part_def_body(&p.body),
1934 }
1935}
1936
1937fn normalize_part_def_body(b: &PartDefBody) -> PartDefBody {
1938 match b {
1939 PartDefBody::Semicolon => PartDefBody::Semicolon,
1940 PartDefBody::Brace { elements } => PartDefBody::Brace {
1941 elements: elements
1942 .iter()
1943 .map(normalize_part_def_body_element_node)
1944 .collect(),
1945 },
1946 }
1947}
1948
1949fn normalize_part_def_body_element_node(el: &Node<PartDefBodyElement>) -> Node<PartDefBodyElement> {
1950 let value = match &el.value {
1951 PartDefBodyElement::Error(n) => PartDefBodyElement::Error(dummy_node(n, n.value.clone())),
1952 PartDefBodyElement::Doc(n) => PartDefBodyElement::Doc(dummy_node(n, n.value.clone())),
1953 PartDefBodyElement::Comment(n) => {
1954 PartDefBodyElement::Comment(dummy_node(n, n.value.clone()))
1955 }
1956 PartDefBodyElement::Annotation(n) => {
1957 PartDefBodyElement::Annotation(dummy_node(n, n.value.clone()))
1958 }
1959 PartDefBodyElement::Other(text) => PartDefBodyElement::Other(text.clone()),
1960 PartDefBodyElement::AttributeDef(n) => {
1961 PartDefBodyElement::AttributeDef(dummy_node(n, normalize_attribute_def(&n.value)))
1962 }
1963 PartDefBodyElement::AttributeUsage(n) => {
1964 PartDefBodyElement::AttributeUsage(dummy_node(n, normalize_attribute_usage(&n.value)))
1965 }
1966 PartDefBodyElement::RequirementUsage(n) => {
1967 PartDefBodyElement::RequirementUsage(dummy_node(n, n.value.clone()))
1968 }
1969 PartDefBodyElement::Ref(n) => {
1970 PartDefBodyElement::Ref(dummy_node(n, normalize_ref_decl(&n.value)))
1971 }
1972 PartDefBodyElement::PortUsage(n) => {
1973 PartDefBodyElement::PortUsage(dummy_node(n, normalize_port_usage(&n.value)))
1974 }
1975 PartDefBodyElement::PartUsage(n) => {
1976 PartDefBodyElement::PartUsage(Box::new(dummy_node(n, normalize_part_usage(&n.value))))
1977 }
1978 PartDefBodyElement::OccurrenceUsage(n) => {
1979 PartDefBodyElement::OccurrenceUsage(Box::new(dummy_node(n, n.value.clone())))
1980 }
1981 PartDefBodyElement::InterfaceDef(n) => {
1982 PartDefBodyElement::InterfaceDef(dummy_node(n, normalize_interface_def(&n.value)))
1983 }
1984 PartDefBodyElement::InterfaceUsage(n) => {
1985 PartDefBodyElement::InterfaceUsage(dummy_node(n, n.value.clone()))
1986 }
1987 PartDefBodyElement::Connect(n) => {
1988 PartDefBodyElement::Connect(dummy_node(n, n.value.clone()))
1989 }
1990 PartDefBodyElement::Connection(n) => {
1991 PartDefBodyElement::Connection(dummy_node(n, n.value.clone()))
1992 }
1993 PartDefBodyElement::Perform(n) => {
1994 PartDefBodyElement::Perform(dummy_node(n, n.value.clone()))
1995 }
1996 PartDefBodyElement::Allocate(n) => {
1997 PartDefBodyElement::Allocate(dummy_node(n, n.value.clone()))
1998 }
1999 PartDefBodyElement::OpaqueMember(n) => {
2000 PartDefBodyElement::OpaqueMember(dummy_node(n, n.value.clone()))
2001 }
2002 PartDefBodyElement::ExhibitState(n) => {
2003 PartDefBodyElement::ExhibitState(dummy_node(n, n.value.clone()))
2004 }
2005 };
2006 dummy_node(el, value)
2007}
2008
2009fn normalize_attribute_usage(a: &AttributeUsage) -> AttributeUsage {
2010 AttributeUsage {
2011 name: a.name.clone(),
2012 typing: a.typing.clone(),
2013 redefines: a.redefines.clone(),
2014 value: a.value.clone(),
2015 body: a.body.clone(),
2016 name_span: None,
2017 typing_span: None,
2018 redefines_span: None,
2019 }
2020}
2021
2022fn normalize_part_usage(p: &PartUsage) -> PartUsage {
2023 PartUsage {
2024 is_individual: p.is_individual,
2025 name: p.name.clone(),
2026 type_name: p.type_name.clone(),
2027 multiplicity: p.multiplicity.clone(),
2028 ordered: p.ordered,
2029 subsets: p.subsets.clone(),
2030 redefines: p.redefines.clone(),
2031 value: p.value.clone(),
2032 body: normalize_part_usage_body(&p.body),
2033 name_span: None,
2034 type_ref_span: None,
2035 }
2036}
2037
2038fn normalize_part_usage_body(b: &PartUsageBody) -> PartUsageBody {
2039 match b {
2040 PartUsageBody::Semicolon => PartUsageBody::Semicolon,
2041 PartUsageBody::Brace { elements } => PartUsageBody::Brace {
2042 elements: elements
2043 .iter()
2044 .map(normalize_part_usage_body_element_node)
2045 .collect(),
2046 },
2047 }
2048}
2049
2050fn normalize_perform(p: &Perform) -> Perform {
2051 Perform {
2052 action_name: p.action_name.clone(),
2053 type_name: p.type_name.clone(),
2054 body: normalize_perform_body(&p.body),
2055 }
2056}
2057
2058fn normalize_perform_body(b: &PerformBody) -> PerformBody {
2059 match b {
2060 PerformBody::Semicolon => PerformBody::Semicolon,
2061 PerformBody::Brace { elements } => PerformBody::Brace {
2062 elements: elements
2063 .iter()
2064 .map(normalize_perform_body_element_node)
2065 .collect(),
2066 },
2067 }
2068}
2069
2070fn normalize_perform_body_element_node(el: &Node<PerformBodyElement>) -> Node<PerformBodyElement> {
2071 let value = match &el.value {
2072 PerformBodyElement::Doc(n) => PerformBodyElement::Doc(dummy_node(n, n.value.clone())),
2073 PerformBodyElement::InOut(n) => PerformBodyElement::InOut(dummy_node(
2074 n,
2075 PerformInOutBinding {
2076 direction: n.value.direction,
2077 name: n.value.name.clone(),
2078 value: normalize_expression_node(&n.value.value),
2079 },
2080 )),
2081 };
2082 dummy_node(el, value)
2083}
2084
2085fn normalize_expression_node(node: &Node<Expression>) -> Node<Expression> {
2086 let value = match &node.value {
2087 Expression::LiteralInteger(x) => Expression::LiteralInteger(*x),
2088 Expression::LiteralReal(s) => Expression::LiteralReal(s.clone()),
2089 Expression::LiteralString(s) => Expression::LiteralString(s.clone()),
2090 Expression::LiteralBoolean(b) => Expression::LiteralBoolean(*b),
2091 Expression::FeatureRef(s) => Expression::FeatureRef(s.clone()),
2092 Expression::MemberAccess(base, member) => {
2093 Expression::MemberAccess(Box::new(normalize_expression_node(base)), member.clone())
2094 }
2095 Expression::Index { base, index } => Expression::Index {
2096 base: Box::new(normalize_expression_node(base)),
2097 index: Box::new(normalize_expression_node(index)),
2098 },
2099 Expression::Bracket(inner) => {
2100 Expression::Bracket(Box::new(normalize_expression_node(inner)))
2101 }
2102 Expression::LiteralWithUnit { value: v, unit } => Expression::LiteralWithUnit {
2103 value: Box::new(normalize_expression_node(v)),
2104 unit: Box::new(normalize_expression_node(unit)),
2105 },
2106 Expression::BinaryOp { op, left, right } => Expression::BinaryOp {
2107 op: op.clone(),
2108 left: Box::new(normalize_expression_node(left)),
2109 right: Box::new(normalize_expression_node(right)),
2110 },
2111 Expression::UnaryOp { op, operand } => Expression::UnaryOp {
2112 op: op.clone(),
2113 operand: Box::new(normalize_expression_node(operand)),
2114 },
2115 Expression::Invocation { callee, args } => Expression::Invocation {
2116 callee: Box::new(normalize_expression_node(callee)),
2117 args: args.iter().map(normalize_expression_node).collect(),
2118 },
2119 Expression::Tuple(items) => {
2120 Expression::Tuple(items.iter().map(normalize_expression_node).collect())
2121 }
2122 Expression::Null => Expression::Null,
2123 };
2124 Node::new(Span::dummy(), value)
2125}
2126
2127fn normalize_part_usage_body_element_node(
2128 el: &Node<PartUsageBodyElement>,
2129) -> Node<PartUsageBodyElement> {
2130 let value = match &el.value {
2131 PartUsageBodyElement::Error(n) => {
2132 PartUsageBodyElement::Error(dummy_node(n, n.value.clone()))
2133 }
2134 PartUsageBodyElement::Doc(n) => PartUsageBodyElement::Doc(dummy_node(n, n.value.clone())),
2135 PartUsageBodyElement::Annotation(n) => {
2136 PartUsageBodyElement::Annotation(dummy_node(n, n.value.clone()))
2137 }
2138 PartUsageBodyElement::AttributeUsage(n) => {
2139 PartUsageBodyElement::AttributeUsage(dummy_node(n, normalize_attribute_usage(&n.value)))
2140 }
2141 PartUsageBodyElement::PartUsage(n) => {
2142 PartUsageBodyElement::PartUsage(Box::new(dummy_node(n, normalize_part_usage(&n.value))))
2143 }
2144 PartUsageBodyElement::OccurrenceUsage(n) => {
2145 PartUsageBodyElement::OccurrenceUsage(Box::new(dummy_node(n, n.value.clone())))
2146 }
2147 PartUsageBodyElement::PortUsage(n) => {
2148 PartUsageBodyElement::PortUsage(dummy_node(n, normalize_port_usage(&n.value)))
2149 }
2150 PartUsageBodyElement::Ref(n) => {
2151 PartUsageBodyElement::Ref(dummy_node(n, normalize_ref_decl(&n.value)))
2152 }
2153 PartUsageBodyElement::Bind(n) => PartUsageBodyElement::Bind(dummy_node(n, n.value.clone())),
2154 PartUsageBodyElement::InterfaceUsage(n) => {
2155 PartUsageBodyElement::InterfaceUsage(dummy_node(n, n.value.clone()))
2156 }
2157 PartUsageBodyElement::Connect(n) => {
2158 PartUsageBodyElement::Connect(dummy_node(n, n.value.clone()))
2159 }
2160 PartUsageBodyElement::Perform(n) => {
2161 PartUsageBodyElement::Perform(dummy_node(n, normalize_perform(&n.value)))
2162 }
2163 PartUsageBodyElement::Allocate(n) => {
2164 PartUsageBodyElement::Allocate(dummy_node(n, n.value.clone()))
2165 }
2166 PartUsageBodyElement::Satisfy(n) => {
2167 PartUsageBodyElement::Satisfy(dummy_node(n, n.value.clone()))
2168 }
2169 PartUsageBodyElement::StateUsage(n) => {
2170 PartUsageBodyElement::StateUsage(dummy_node(n, n.value.clone()))
2171 }
2172 PartUsageBodyElement::MetadataAnnotation(n) => {
2173 PartUsageBodyElement::MetadataAnnotation(dummy_node(n, n.value.clone()))
2174 }
2175 };
2176 dummy_node(el, value)
2177}
2178
2179fn normalize_port_usage(p: &PortUsage) -> PortUsage {
2180 PortUsage {
2181 name: p.name.clone(),
2182 type_name: p.type_name.clone(),
2183 multiplicity: p.multiplicity.clone(),
2184 subsets: p.subsets.clone(),
2185 redefines: p.redefines.clone(),
2186 body: normalize_port_body(&p.body),
2187 name_span: None,
2188 type_ref_span: None,
2189 }
2190}
2191
2192fn normalize_port_body(b: &PortBody) -> PortBody {
2193 match b {
2194 PortBody::Semicolon => PortBody::Semicolon,
2195 PortBody::Brace => PortBody::Brace,
2196 PortBody::BraceWithPorts { elements } => PortBody::BraceWithPorts {
2197 elements: elements
2198 .iter()
2199 .map(|n| dummy_node(n, normalize_port_usage(&n.value)))
2200 .collect(),
2201 },
2202 }
2203}
2204
2205fn normalize_port_def(p: &PortDef) -> PortDef {
2206 PortDef {
2207 identification: p.identification.clone(),
2208 specializes: p.specializes.clone(),
2209 body: normalize_port_def_body(&p.body),
2210 }
2211}
2212
2213fn normalize_port_def_body(b: &PortDefBody) -> PortDefBody {
2214 match b {
2215 PortDefBody::Semicolon => PortDefBody::Semicolon,
2216 PortDefBody::Brace { elements } => PortDefBody::Brace {
2217 elements: elements
2218 .iter()
2219 .map(normalize_port_def_body_element_node)
2220 .collect(),
2221 },
2222 }
2223}
2224
2225fn normalize_port_def_body_element_node(el: &Node<PortDefBodyElement>) -> Node<PortDefBodyElement> {
2226 let value = match &el.value {
2227 PortDefBodyElement::InOutDecl(n) => {
2228 PortDefBodyElement::InOutDecl(dummy_node(n, n.value.clone()))
2229 }
2230 PortDefBodyElement::Doc(n) => PortDefBodyElement::Doc(dummy_node(n, n.value.clone())),
2231 PortDefBodyElement::AttributeDef(n) => {
2232 PortDefBodyElement::AttributeDef(dummy_node(n, normalize_attribute_def(&n.value)))
2233 }
2234 PortDefBodyElement::AttributeUsage(n) => {
2235 PortDefBodyElement::AttributeUsage(dummy_node(n, normalize_attribute_usage(&n.value)))
2236 }
2237 PortDefBodyElement::PortUsage(n) => {
2238 PortDefBodyElement::PortUsage(dummy_node(n, normalize_port_usage(&n.value)))
2239 }
2240 };
2241 dummy_node(el, value)
2242}
2243
2244fn normalize_interface_def(i: &InterfaceDef) -> InterfaceDef {
2245 InterfaceDef {
2246 identification: i.identification.clone(),
2247 body: normalize_interface_def_body(&i.body),
2248 }
2249}
2250
2251fn normalize_connection_def(c: &ConnectionDef) -> ConnectionDef {
2252 ConnectionDef {
2253 annotation: c.annotation.clone(),
2254 identification: c.identification.clone(),
2255 body: normalize_connection_def_body(&c.body),
2256 }
2257}
2258
2259fn normalize_connection_def_body(b: &ConnectionDefBody) -> ConnectionDefBody {
2260 match b {
2261 ConnectionDefBody::Semicolon => ConnectionDefBody::Semicolon,
2262 ConnectionDefBody::Brace { elements } => ConnectionDefBody::Brace {
2263 elements: elements
2264 .iter()
2265 .map(normalize_connection_def_body_element_node)
2266 .collect(),
2267 },
2268 }
2269}
2270
2271fn normalize_connection_def_body_element_node(
2272 el: &Node<ConnectionDefBodyElement>,
2273) -> Node<ConnectionDefBodyElement> {
2274 let value = match &el.value {
2275 ConnectionDefBodyElement::EndDecl(n) => {
2276 ConnectionDefBodyElement::EndDecl(dummy_node(n, normalize_end_decl(&n.value)))
2277 }
2278 ConnectionDefBodyElement::RefDecl(n) => {
2279 ConnectionDefBodyElement::RefDecl(dummy_node(n, normalize_ref_decl(&n.value)))
2280 }
2281 ConnectionDefBodyElement::ConnectStmt(n) => {
2282 ConnectionDefBodyElement::ConnectStmt(dummy_node(n, n.value.clone()))
2283 }
2284 };
2285 dummy_node(el, value)
2286}
2287
2288fn normalize_metadata_def(m: &MetadataDef) -> MetadataDef {
2289 MetadataDef {
2290 is_abstract: m.is_abstract,
2291 identification: m.identification.clone(),
2292 body: m.body.clone(),
2293 }
2294}
2295
2296fn normalize_enum_def(e: &EnumDef) -> EnumDef {
2297 EnumDef {
2298 identification: e.identification.clone(),
2299 body: e.body.clone(),
2300 }
2301}
2302
2303fn normalize_occurrence_def(o: &OccurrenceDef) -> OccurrenceDef {
2304 OccurrenceDef {
2305 is_abstract: o.is_abstract,
2306 identification: o.identification.clone(),
2307 body: o.body.clone(),
2308 }
2309}
2310
2311fn normalize_interface_def_body(b: &InterfaceDefBody) -> InterfaceDefBody {
2312 match b {
2313 InterfaceDefBody::Semicolon => InterfaceDefBody::Semicolon,
2314 InterfaceDefBody::Brace { elements } => InterfaceDefBody::Brace {
2315 elements: elements
2316 .iter()
2317 .map(normalize_interface_def_body_element_node)
2318 .collect(),
2319 },
2320 }
2321}
2322
2323fn normalize_interface_def_body_element_node(
2324 el: &Node<InterfaceDefBodyElement>,
2325) -> Node<InterfaceDefBodyElement> {
2326 let value = match &el.value {
2327 InterfaceDefBodyElement::Doc(n) => {
2328 InterfaceDefBodyElement::Doc(dummy_node(n, n.value.clone()))
2329 }
2330 InterfaceDefBodyElement::EndDecl(n) => {
2331 InterfaceDefBodyElement::EndDecl(dummy_node(n, normalize_end_decl(&n.value)))
2332 }
2333 InterfaceDefBodyElement::RefDecl(n) => {
2334 InterfaceDefBodyElement::RefDecl(dummy_node(n, normalize_ref_decl(&n.value)))
2335 }
2336 InterfaceDefBodyElement::ConnectStmt(n) => {
2337 InterfaceDefBodyElement::ConnectStmt(dummy_node(n, n.value.clone()))
2338 }
2339 };
2340 dummy_node(el, value)
2341}
2342
2343fn normalize_end_decl(e: &EndDecl) -> EndDecl {
2344 EndDecl {
2345 name: e.name.clone(),
2346 type_name: e.type_name.clone(),
2347 uses_derived_syntax: e.uses_derived_syntax,
2348 name_span: None,
2349 type_ref_span: None,
2350 }
2351}
2352
2353fn normalize_ref_decl(r: &RefDecl) -> RefDecl {
2354 RefDecl {
2355 name: r.name.clone(),
2356 type_name: r.type_name.clone(),
2357 value: r.value.clone(),
2358 body: r.body.clone(),
2359 name_span: None,
2360 type_ref_span: None,
2361 }
2362}
2363
2364fn normalize_action_def(a: &ActionDef) -> ActionDef {
2365 ActionDef {
2366 identification: a.identification.clone(),
2367 body: normalize_action_def_body(&a.body),
2368 }
2369}
2370
2371fn normalize_action_def_body(b: &ActionDefBody) -> ActionDefBody {
2372 match b {
2373 ActionDefBody::Semicolon => ActionDefBody::Semicolon,
2374 ActionDefBody::Brace { elements } => ActionDefBody::Brace {
2375 elements: elements
2376 .iter()
2377 .map(normalize_action_def_body_element_node)
2378 .collect(),
2379 },
2380 }
2381}
2382
2383fn normalize_action_def_body_element_node(
2384 el: &Node<ActionDefBodyElement>,
2385) -> Node<ActionDefBodyElement> {
2386 let value = match &el.value {
2387 ActionDefBodyElement::Error(n) => {
2388 ActionDefBodyElement::Error(dummy_node(n, n.value.clone()))
2389 }
2390 ActionDefBodyElement::InOutDecl(n) => {
2391 ActionDefBodyElement::InOutDecl(dummy_node(n, n.value.clone()))
2392 }
2393 ActionDefBodyElement::Doc(n) => ActionDefBodyElement::Doc(dummy_node(n, n.value.clone())),
2394 ActionDefBodyElement::Annotation(n) => {
2395 ActionDefBodyElement::Annotation(dummy_node(n, n.value.clone()))
2396 }
2397 ActionDefBodyElement::RefDecl(n) => {
2398 ActionDefBodyElement::RefDecl(dummy_node(n, normalize_ref_decl(&n.value)))
2399 }
2400 ActionDefBodyElement::Perform(n) => {
2401 ActionDefBodyElement::Perform(dummy_node(n, normalize_perform(&n.value)))
2402 }
2403 ActionDefBodyElement::Bind(n) => ActionDefBodyElement::Bind(dummy_node(n, n.value.clone())),
2404 ActionDefBodyElement::Flow(n) => ActionDefBodyElement::Flow(dummy_node(n, n.value.clone())),
2405 ActionDefBodyElement::FirstStmt(n) => {
2406 ActionDefBodyElement::FirstStmt(dummy_node(n, n.value.clone()))
2407 }
2408 ActionDefBodyElement::MergeStmt(n) => {
2409 ActionDefBodyElement::MergeStmt(dummy_node(n, n.value.clone()))
2410 }
2411 ActionDefBodyElement::StateUsage(n) => {
2412 ActionDefBodyElement::StateUsage(dummy_node(n, n.value.clone()))
2413 }
2414 ActionDefBodyElement::ActionUsage(n) => ActionDefBodyElement::ActionUsage(Box::new(
2415 dummy_node(n, normalize_action_usage(&n.value)),
2416 )),
2417 ActionDefBodyElement::Assign(n) => {
2418 ActionDefBodyElement::Assign(dummy_node(n, n.value.clone()))
2419 }
2420 ActionDefBodyElement::ForLoop(n) => {
2421 ActionDefBodyElement::ForLoop(dummy_node(n, n.value.clone()))
2422 }
2423 ActionDefBodyElement::ThenAction(n) => {
2424 ActionDefBodyElement::ThenAction(dummy_node(n, n.value.clone()))
2425 }
2426 ActionDefBodyElement::Decl(n) => ActionDefBodyElement::Decl(dummy_node(n, n.value.clone())),
2427 };
2428 dummy_node(el, value)
2429}
2430
2431fn normalize_action_usage(a: &ActionUsage) -> ActionUsage {
2432 ActionUsage {
2433 name: a.name.clone(),
2434 type_name: a.type_name.clone(),
2435 accept: a.accept.clone(),
2436 body: normalize_action_usage_body(&a.body),
2437 name_span: None,
2438 type_ref_span: None,
2439 }
2440}
2441
2442fn normalize_action_usage_body(b: &ActionUsageBody) -> ActionUsageBody {
2443 match b {
2444 ActionUsageBody::Semicolon => ActionUsageBody::Semicolon,
2445 ActionUsageBody::Brace { elements } => ActionUsageBody::Brace {
2446 elements: elements
2447 .iter()
2448 .map(normalize_action_usage_body_element_node)
2449 .collect(),
2450 },
2451 }
2452}
2453
2454fn normalize_action_usage_body_element_node(
2455 el: &Node<ActionUsageBodyElement>,
2456) -> Node<ActionUsageBodyElement> {
2457 let value = match &el.value {
2458 ActionUsageBodyElement::Error(n) => {
2459 ActionUsageBodyElement::Error(dummy_node(n, n.value.clone()))
2460 }
2461 ActionUsageBodyElement::Doc(n) => {
2462 ActionUsageBodyElement::Doc(dummy_node(n, n.value.clone()))
2463 }
2464 ActionUsageBodyElement::Annotation(n) => {
2465 ActionUsageBodyElement::Annotation(dummy_node(n, n.value.clone()))
2466 }
2467 ActionUsageBodyElement::InOutDecl(n) => {
2468 ActionUsageBodyElement::InOutDecl(dummy_node(n, n.value.clone()))
2469 }
2470 ActionUsageBodyElement::RefDecl(n) => {
2471 ActionUsageBodyElement::RefDecl(dummy_node(n, normalize_ref_decl(&n.value)))
2472 }
2473 ActionUsageBodyElement::Bind(n) => {
2474 ActionUsageBodyElement::Bind(dummy_node(n, n.value.clone()))
2475 }
2476 ActionUsageBodyElement::Flow(n) => {
2477 ActionUsageBodyElement::Flow(dummy_node(n, n.value.clone()))
2478 }
2479 ActionUsageBodyElement::FirstStmt(n) => {
2480 ActionUsageBodyElement::FirstStmt(dummy_node(n, n.value.clone()))
2481 }
2482 ActionUsageBodyElement::MergeStmt(n) => {
2483 ActionUsageBodyElement::MergeStmt(dummy_node(n, n.value.clone()))
2484 }
2485 ActionUsageBodyElement::StateUsage(n) => {
2486 ActionUsageBodyElement::StateUsage(dummy_node(n, n.value.clone()))
2487 }
2488 ActionUsageBodyElement::ActionUsage(n) => ActionUsageBodyElement::ActionUsage(Box::new(
2489 dummy_node(n, normalize_action_usage(&n.value)),
2490 )),
2491 ActionUsageBodyElement::Assign(n) => {
2492 ActionUsageBodyElement::Assign(dummy_node(n, n.value.clone()))
2493 }
2494 ActionUsageBodyElement::ForLoop(n) => {
2495 ActionUsageBodyElement::ForLoop(dummy_node(n, n.value.clone()))
2496 }
2497 ActionUsageBodyElement::ThenAction(n) => {
2498 ActionUsageBodyElement::ThenAction(dummy_node(n, n.value.clone()))
2499 }
2500 ActionUsageBodyElement::Decl(n) => {
2501 ActionUsageBodyElement::Decl(dummy_node(n, n.value.clone()))
2502 }
2503 };
2504 dummy_node(el, value)
2505}