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 redefines: Option<String>,
557 pub value: Option<Node<Expression>>,
559 pub body: AttributeBody,
560 pub name_span: Option<Span>,
562 pub redefines_span: Option<Span>,
564}
565
566#[derive(Debug, Clone, PartialEq, Eq)]
572pub struct PortDef {
573 pub identification: Identification,
574 pub specializes: Option<String>,
576 pub body: PortDefBody,
577}
578
579#[derive(Debug, Clone, PartialEq, Eq)]
581pub enum PortDefBody {
582 Semicolon,
583 Brace {
584 elements: Vec<Node<PortDefBodyElement>>,
585 },
586}
587
588#[derive(Debug, Clone, PartialEq, Eq)]
590pub enum PortDefBodyElement {
591 InOutDecl(Node<InOutDecl>),
592 Doc(Node<DocComment>),
593 AttributeDef(Node<AttributeDef>),
594 AttributeUsage(Node<AttributeUsage>),
595 PortUsage(Node<PortUsage>),
596}
597
598#[derive(Debug, Clone, PartialEq, Eq)]
600pub struct PortUsage {
601 pub name: String,
602 pub type_name: Option<String>,
603 pub multiplicity: Option<String>,
604 pub subsets: Option<(String, Option<Node<Expression>>)>,
606 pub redefines: Option<String>,
607 pub body: PortBody,
608 pub name_span: Option<Span>,
610 pub type_ref_span: Option<Span>,
612}
613
614#[derive(Debug, Clone, PartialEq, Eq)]
616pub enum PortBody {
617 Semicolon,
618 Brace,
619 BraceWithPorts {
621 elements: Vec<Node<PortUsage>>,
622 },
623}
624
625#[derive(Debug, Clone, PartialEq, Eq)]
631pub struct InterfaceDef {
632 pub identification: Identification,
633 pub body: InterfaceDefBody,
634}
635
636#[derive(Debug, Clone, PartialEq, Eq)]
638pub enum InterfaceDefBody {
639 Semicolon,
640 Brace {
641 elements: Vec<Node<InterfaceDefBodyElement>>,
642 },
643}
644
645#[derive(Debug, Clone, PartialEq, Eq)]
647pub enum InterfaceDefBodyElement {
648 Doc(Node<DocComment>),
649 EndDecl(Node<EndDecl>),
650 RefDecl(Node<RefDecl>),
651 ConnectStmt(Node<ConnectStmt>),
652}
653
654#[derive(Debug, Clone, PartialEq, Eq)]
656pub struct EndDecl {
657 pub name: String,
658 pub type_name: String,
659 pub uses_derived_syntax: bool,
660 pub name_span: Option<Span>,
662 pub type_ref_span: Option<Span>,
664}
665
666#[derive(Debug, Clone, PartialEq, Eq)]
668pub struct RefDecl {
669 pub name: String,
670 pub type_name: String,
671 pub value: Option<Node<Expression>>,
673 pub body: RefBody,
674 pub name_span: Option<Span>,
676 pub type_ref_span: Option<Span>,
678}
679
680#[derive(Debug, Clone, PartialEq, Eq)]
682pub enum RefBody {
683 Semicolon,
684 Brace,
685}
686
687#[derive(Debug, Clone, PartialEq, Eq)]
693pub struct ConnectionDef {
694 pub annotation: Option<String>,
695 pub identification: Identification,
696 pub body: ConnectionDefBody,
697}
698
699#[derive(Debug, Clone, PartialEq, Eq)]
701pub enum ConnectionDefBody {
702 Semicolon,
703 Brace {
704 elements: Vec<Node<ConnectionDefBodyElement>>,
705 },
706}
707
708#[derive(Debug, Clone, PartialEq, Eq)]
709pub enum ConnectionDefBodyElement {
710 EndDecl(Node<EndDecl>),
711 RefDecl(Node<RefDecl>),
712 ConnectStmt(Node<ConnectStmt>),
713}
714
715#[derive(Debug, Clone, PartialEq, Eq)]
721pub struct MetadataDef {
722 pub is_abstract: bool,
723 pub identification: Identification,
724 pub body: DefinitionBody,
725}
726
727#[derive(Debug, Clone, PartialEq, Eq)]
733pub struct EnumDef {
734 pub identification: Identification,
735 pub body: EnumerationBody,
736}
737
738#[derive(Debug, Clone, PartialEq, Eq)]
739pub enum EnumerationBody {
740 Semicolon,
741 Brace { values: Vec<String> },
742}
743
744#[derive(Debug, Clone, PartialEq, Eq)]
750pub struct OccurrenceDef {
751 pub is_abstract: bool,
752 pub identification: Identification,
753 pub body: DefinitionBody,
754}
755
756#[derive(Debug, Clone, PartialEq, Eq)]
758pub struct OccurrenceUsage {
759 pub is_individual: bool,
760 pub is_then: bool,
761 pub portion_kind: Option<String>,
762 pub name: String,
763 pub type_name: Option<String>,
764 pub subsets: Option<String>,
765 pub redefines: Option<String>,
766 pub body: OccurrenceUsageBody,
767}
768
769#[derive(Debug, Clone, PartialEq, Eq)]
770pub enum OccurrenceUsageBody {
771 Semicolon,
772 Brace {
773 elements: Vec<Node<OccurrenceBodyElement>>,
774 },
775}
776
777#[derive(Debug, Clone, PartialEq, Eq)]
779pub struct AssertConstraintMember {
780 pub body: ConstraintDefBody,
781}
782
783#[derive(Debug, Clone, PartialEq, Eq)]
784pub enum OccurrenceBodyElement {
785 Error(Node<ParseErrorNode>),
786 Doc(Node<DocComment>),
787 Annotation(Node<Annotation>),
788 AssertConstraint(Node<AssertConstraintMember>),
789 Other(String),
790 AttributeUsage(Node<AttributeUsage>),
791 PartUsage(Box<Node<PartUsage>>),
792 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
793}
794
795#[derive(Debug, Clone, PartialEq, Eq)]
801pub struct LibraryPackage {
802 pub is_standard: bool,
803 pub identification: Identification,
804 pub body: PackageBody,
805}
806
807#[derive(Debug, Clone, PartialEq, Eq)]
809pub enum DefinitionBody {
810 Semicolon,
811 Brace,
812}
813
814#[derive(Debug, Clone, PartialEq, Eq)]
816pub struct ConnectStmt {
817 pub from: Node<Expression>,
818 pub to: Node<Expression>,
819 pub body: ConnectBody,
820}
821
822#[derive(Debug, Clone, PartialEq, Eq)]
824pub enum ConnectBody {
825 Semicolon,
826 Brace,
827}
828
829#[derive(Debug, Clone, PartialEq, Eq)]
835pub struct Bind {
836 pub left: Node<Expression>,
837 pub right: Node<Expression>,
838 pub body: Option<ConnectBody>,
840}
841
842#[derive(Debug, Clone, PartialEq, Eq)]
844pub enum InterfaceUsage {
845 TypedConnect {
847 interface_type: Option<String>,
848 from: Node<Expression>,
849 to: Node<Expression>,
850 body: ConnectBody,
851 body_elements: Vec<Node<InterfaceUsageBodyElement>>,
852 },
853 Connection {
855 from: Node<Expression>,
856 to: Node<Expression>,
857 body_elements: Vec<Node<InterfaceUsageBodyElement>>,
858 },
859}
860
861#[derive(Debug, Clone, PartialEq, Eq)]
863pub enum InterfaceUsageBodyElement {
864 RefRedef {
866 name: String,
867 value: Node<Expression>,
868 body: RefBody,
869 },
870}
871
872#[derive(Debug, Clone, PartialEq, Eq)]
874pub struct Connect {
875 pub from: Node<Expression>,
876 pub to: Node<Expression>,
877 pub body: ConnectBody,
878}
879
880#[derive(Debug, Clone, PartialEq, Eq)]
886pub struct AliasDef {
887 pub identification: Identification,
888 pub target: String,
889 pub body: AliasBody,
890}
891
892#[derive(Debug, Clone, PartialEq, Eq)]
894pub enum AliasBody {
895 Semicolon,
896 Brace,
897}
898
899#[derive(Debug, Clone, PartialEq, Eq)]
905pub struct ActionDef {
906 pub identification: Identification,
907 pub body: ActionDefBody,
908}
909
910#[derive(Debug, Clone, PartialEq, Eq)]
912pub enum ActionDefBody {
913 Semicolon,
914 Brace {
915 elements: Vec<Node<ActionDefBodyElement>>,
916 },
917}
918
919#[derive(Debug, Clone, PartialEq, Eq)]
921pub enum ActionDefBodyElement {
922 Error(Node<ParseErrorNode>),
923 InOutDecl(Node<InOutDecl>),
924 Doc(Node<DocComment>),
925 Annotation(Node<Annotation>),
926 RefDecl(Node<RefDecl>),
927 Perform(Node<Perform>),
928 Bind(Node<Bind>),
929 Flow(Node<Flow>),
930 FirstStmt(Node<FirstStmt>),
931 MergeStmt(Node<MergeStmt>),
932 StateUsage(Node<StateUsage>),
933 ActionUsage(Box<Node<ActionUsage>>),
934 Assign(Node<AssignStmt>),
935 ForLoop(Node<ForLoop>),
936 ThenAction(Node<ThenAction>),
937 Decl(Node<ActionBodyDecl>),
938}
939
940#[derive(Debug, Clone, PartialEq, Eq)]
946pub struct AssignStmt {
947 pub is_then: bool,
948 pub lhs: String,
949 pub rhs: String,
950}
951
952#[derive(Debug, Clone, PartialEq, Eq)]
954pub struct ForLoop {
955 pub var: String,
956 pub range: String,
957 pub body: ActionDefBody,
958}
959
960#[derive(Debug, Clone, PartialEq, Eq)]
962pub struct ThenAction {
963 pub action: Node<ActionUsage>,
964}
965
966#[derive(Debug, Clone, PartialEq, Eq)]
968pub struct InOutDecl {
969 pub direction: InOut,
970 pub name: String,
971 pub type_name: String,
972}
973
974#[derive(Debug, Clone, Copy, PartialEq, Eq)]
975pub enum InOut {
976 In,
977 Out,
978 InOut,
979}
980
981#[derive(Debug, Clone, PartialEq, Eq)]
983pub struct ActionUsage {
984 pub name: String,
985 pub type_name: String,
986 pub accept: Option<(String, String)>,
988 pub body: ActionUsageBody,
989 pub name_span: Option<Span>,
991 pub type_ref_span: Option<Span>,
993}
994
995#[derive(Debug, Clone, PartialEq, Eq)]
997pub enum ActionUsageBody {
998 Semicolon,
999 Brace {
1000 elements: Vec<Node<ActionUsageBodyElement>>,
1001 },
1002}
1003
1004#[derive(Debug, Clone, PartialEq, Eq)]
1006pub enum ActionUsageBodyElement {
1007 Error(Node<ParseErrorNode>),
1008 Doc(Node<DocComment>),
1009 Annotation(Node<Annotation>),
1010 InOutDecl(Node<InOutDecl>),
1011 RefDecl(Node<RefDecl>),
1012 Bind(Node<Bind>),
1013 Flow(Node<Flow>),
1014 FirstStmt(Node<FirstStmt>),
1015 MergeStmt(Node<MergeStmt>),
1016 StateUsage(Node<StateUsage>),
1017 ActionUsage(Box<Node<ActionUsage>>),
1018 Assign(Node<AssignStmt>),
1019 ForLoop(Node<ForLoop>),
1020 ThenAction(Node<ThenAction>),
1021 Decl(Node<ActionBodyDecl>),
1022}
1023
1024#[derive(Debug, Clone, PartialEq, Eq)]
1026pub struct ActionBodyDecl {
1027 pub keyword: String,
1028 pub text: String,
1029}
1030
1031#[derive(Debug, Clone, PartialEq, Eq)]
1033pub struct Flow {
1034 pub from: Node<Expression>,
1035 pub to: Node<Expression>,
1036 pub body: ConnectBody,
1037}
1038
1039#[derive(Debug, Clone, PartialEq, Eq)]
1041pub struct FlowDef {
1042 pub identification: Identification,
1043 pub body: DefinitionBody,
1044}
1045
1046#[derive(Debug, Clone, PartialEq, Eq)]
1048pub struct FlowUsage {
1049 pub name: String,
1050 pub type_name: Option<String>,
1051 pub from: Option<Node<Expression>>,
1052 pub to: Option<Node<Expression>>,
1053 pub body: DefinitionBody,
1054}
1055
1056#[derive(Debug, Clone, PartialEq, Eq)]
1058pub struct FirstStmt {
1059 pub first: Node<Expression>,
1060 pub then: Node<Expression>,
1061 pub body: FirstMergeBody,
1062}
1063
1064#[derive(Debug, Clone, PartialEq, Eq)]
1066pub struct MergeStmt {
1067 pub merge: Node<Expression>,
1068 pub body: FirstMergeBody,
1069}
1070
1071#[derive(Debug, Clone, PartialEq, Eq)]
1073pub enum FirstMergeBody {
1074 Semicolon,
1075 Brace,
1076}
1077
1078#[derive(Debug, Clone, PartialEq, Eq)]
1084pub struct Allocate {
1085 pub source: Node<Expression>,
1086 pub target: Node<Expression>,
1087 pub body: ConnectBody,
1088}
1089
1090#[derive(Debug, Clone, PartialEq, Eq)]
1092pub struct AllocationDef {
1093 pub identification: Identification,
1094 pub body: DefinitionBody,
1095}
1096
1097#[derive(Debug, Clone, PartialEq, Eq)]
1099pub struct AllocationUsage {
1100 pub name: String,
1101 pub type_name: Option<String>,
1102 pub source: Option<Node<Expression>>,
1103 pub target: Option<Node<Expression>>,
1104 pub body: DefinitionBody,
1105}
1106
1107#[derive(Debug, Clone, PartialEq, Eq)]
1113pub struct RequirementDef {
1114 pub identification: Identification,
1115 pub body: RequirementDefBody,
1116}
1117
1118#[derive(Debug, Clone, PartialEq, Eq)]
1120pub enum RequirementDefBody {
1121 Semicolon,
1122 Brace {
1123 elements: Vec<Node<RequirementDefBodyElement>>,
1124 },
1125}
1126
1127#[derive(Debug, Clone, PartialEq, Eq)]
1128pub enum RequirementDefBodyElement {
1129 Error(Node<ParseErrorNode>),
1130 Other(String),
1132 Annotation(Node<Annotation>),
1133 Import(Node<Import>),
1134 SubjectDecl(Node<SubjectDecl>),
1135 AttributeDef(Node<AttributeDef>),
1136 AttributeUsage(Node<AttributeUsage>),
1137 VerifyRequirement(Node<VerifyRequirementMember>),
1138 RequireConstraint(Node<RequireConstraint>),
1139 Frame(Node<FrameMember>),
1140 Doc(Node<DocComment>),
1141}
1142
1143#[derive(Debug, Clone, PartialEq, Eq)]
1145pub struct SubjectDecl {
1146 pub name: String,
1147 pub type_name: String,
1148}
1149
1150#[derive(Debug, Clone, PartialEq, Eq)]
1152pub struct RequireConstraint {
1153 pub body: RequireConstraintBody,
1154}
1155
1156#[derive(Debug, Clone, PartialEq, Eq)]
1159pub struct VerifyRequirementMember {
1160 pub explicit_requirement_keyword: bool,
1162 pub requirement: Option<Node<RequirementUsage>>,
1164 pub target: Option<String>,
1166}
1167
1168#[derive(Debug, Clone, PartialEq, Eq)]
1170pub enum RequireConstraintBody {
1171 Semicolon,
1172 Brace {
1173 elements: Vec<Node<ConstraintDefBodyElement>>,
1174 },
1175}
1176
1177#[derive(Debug, Clone, PartialEq, Eq)]
1179pub struct Satisfy {
1180 pub source: Node<Expression>,
1181 pub target: Node<Expression>,
1182 pub body: ConnectBody,
1183}
1184
1185#[derive(Debug, Clone, PartialEq, Eq)]
1187pub struct RequirementUsage {
1188 pub name: String,
1189 pub type_name: Option<String>,
1190 pub subsets: Option<String>,
1191 pub body: RequirementDefBody,
1192}
1193
1194#[derive(Debug, Clone, PartialEq, Eq)]
1196pub struct Dependency {
1197 pub identification: Option<Identification>,
1198 pub clients: Vec<String>,
1199 pub suppliers: Vec<String>,
1200 pub body: ConnectBody,
1201}
1202
1203#[derive(Debug, Clone, PartialEq, Eq)]
1205pub struct FrameMember {
1206 pub name: String,
1207 pub body: RequirementDefBody,
1208}
1209
1210#[derive(Debug, Clone, PartialEq, Eq)]
1212pub struct ConcernUsage {
1213 pub name: String,
1214 pub type_name: Option<String>,
1215 pub body: RequirementDefBody,
1216}
1217
1218#[derive(Debug, Clone, PartialEq, Eq)]
1220pub struct CaseDef {
1221 pub identification: Identification,
1222 pub body: UseCaseDefBody,
1223}
1224
1225#[derive(Debug, Clone, PartialEq, Eq)]
1227pub struct CaseUsage {
1228 pub name: String,
1229 pub type_name: Option<String>,
1230 pub body: UseCaseDefBody,
1231}
1232
1233#[derive(Debug, Clone, PartialEq, Eq)]
1235pub struct AnalysisCaseDef {
1236 pub identification: Identification,
1237 pub body: UseCaseDefBody,
1238}
1239
1240#[derive(Debug, Clone, PartialEq, Eq)]
1242pub struct AnalysisCaseUsage {
1243 pub name: String,
1244 pub type_name: Option<String>,
1245 pub body: UseCaseDefBody,
1246}
1247
1248#[derive(Debug, Clone, PartialEq, Eq)]
1250pub struct VerificationCaseDef {
1251 pub identification: Identification,
1252 pub body: UseCaseDefBody,
1253}
1254
1255#[derive(Debug, Clone, PartialEq, Eq)]
1257pub struct VerificationCaseUsage {
1258 pub name: String,
1259 pub type_name: Option<String>,
1260 pub body: UseCaseDefBody,
1261}
1262
1263#[derive(Debug, Clone, PartialEq, Eq)]
1265pub struct UseCaseUsage {
1266 pub name: String,
1267 pub type_name: Option<String>,
1268 pub body: UseCaseDefBody,
1269}
1270
1271#[derive(Debug, Clone, PartialEq, Eq)]
1277pub struct ActorDecl {
1278 pub identification: Identification,
1279}
1280
1281#[derive(Debug, Clone, PartialEq, Eq)]
1283pub struct UseCaseDef {
1284 pub identification: Identification,
1285 pub body: UseCaseDefBody,
1286}
1287
1288#[derive(Debug, Clone, PartialEq, Eq)]
1289pub enum UseCaseDefBody {
1290 Semicolon,
1291 Brace {
1292 elements: Vec<Node<UseCaseDefBodyElement>>,
1293 },
1294}
1295
1296#[derive(Debug, Clone, PartialEq, Eq)]
1298pub struct FirstSuccession {
1299 pub target: String,
1300}
1301
1302#[derive(Debug, Clone, PartialEq, Eq)]
1304pub struct ThenDone {}
1305
1306#[derive(Debug, Clone, PartialEq, Eq)]
1308pub struct IncludeUseCase {
1309 pub name: String,
1310 pub multiplicity: Option<String>,
1312 pub body: UseCaseDefBody,
1313}
1314
1315#[derive(Debug, Clone, PartialEq, Eq)]
1317pub struct ThenIncludeUseCase {
1318 pub include: Node<IncludeUseCase>,
1319}
1320
1321#[derive(Debug, Clone, PartialEq, Eq)]
1323pub struct ThenUseCaseUsage {
1324 pub use_case: Node<UseCaseUsage>,
1325}
1326
1327#[derive(Debug, Clone, PartialEq, Eq)]
1329pub struct SubjectRef {}
1330
1331#[derive(Debug, Clone, PartialEq, Eq)]
1333pub struct ActorRedefinitionAssignment {
1334 pub name: String,
1335 pub rhs: String,
1337}
1338
1339#[derive(Debug, Clone, PartialEq, Eq)]
1341pub struct RefRedefinition {
1342 pub name: String,
1343 pub body: String,
1345}
1346
1347#[derive(Debug, Clone, PartialEq, Eq)]
1349pub struct ReturnRef {
1350 pub name: String,
1351 pub multiplicity: Option<String>,
1352 pub body: String,
1354}
1355
1356#[derive(Debug, Clone, PartialEq, Eq)]
1357pub enum UseCaseDefBodyElement {
1358 Error(Node<ParseErrorNode>),
1359 Other(String),
1361 Doc(Node<DocComment>),
1362 SubjectDecl(Node<SubjectDecl>),
1363 SubjectRef(Node<SubjectRef>),
1365 ActorUsage(Node<ActorUsage>),
1366 ActorRedefinitionAssignment(Node<ActorRedefinitionAssignment>),
1367 Objective(Node<Objective>),
1368 FirstSuccession(Node<FirstSuccession>),
1369 ThenIncludeUseCase(Node<ThenIncludeUseCase>),
1370 ThenUseCaseUsage(Node<ThenUseCaseUsage>),
1371 ThenDone(Node<ThenDone>),
1372 IncludeUseCase(Node<IncludeUseCase>),
1373 RefRedefinition(Node<RefRedefinition>),
1374 ReturnRef(Node<ReturnRef>),
1375 Assign(Node<AssignStmt>),
1376 ForLoop(Node<ForLoop>),
1377 ThenAction(Node<ThenAction>),
1378}
1379
1380#[derive(Debug, Clone, PartialEq, Eq)]
1382pub struct ActorUsage {
1383 pub name: String,
1384 pub type_name: String,
1385}
1386
1387#[derive(Debug, Clone, PartialEq, Eq)]
1389pub struct Objective {
1390 pub visibility: Option<Visibility>,
1391 pub requirement: Node<RequirementUsage>,
1392}
1393
1394#[derive(Debug, Clone, PartialEq, Eq)]
1400pub struct StateDef {
1401 pub identification: Identification,
1402 pub body: StateDefBody,
1403}
1404
1405#[derive(Debug, Clone, PartialEq, Eq)]
1406pub enum StateDefBody {
1407 Semicolon,
1408 Brace {
1409 elements: Vec<Node<StateDefBodyElement>>,
1410 },
1411}
1412
1413#[derive(Debug, Clone, PartialEq, Eq)]
1414pub enum StateDefBodyElement {
1415 Error(Node<ParseErrorNode>),
1416 Doc(Node<DocComment>),
1417 Annotation(Node<Annotation>),
1418 Other(String),
1419 Entry(Node<EntryAction>),
1421 Then(Node<ThenStmt>),
1423 Ref(Node<RefDecl>),
1425 RequirementUsage(Node<RequirementUsage>),
1426 StateUsage(Node<StateUsage>),
1427 Transition(Node<Transition>),
1428}
1429
1430#[derive(Debug, Clone, PartialEq, Eq)]
1432pub struct EntryAction {
1433 pub action_name: Option<String>,
1435 pub body: StateDefBody,
1436}
1437
1438#[derive(Debug, Clone, PartialEq, Eq)]
1440pub struct ThenStmt {
1441 pub state_name: String,
1442}
1443
1444#[derive(Debug, Clone, PartialEq, Eq)]
1446pub struct StateUsage {
1447 pub name: String,
1448 pub type_name: Option<String>,
1449 pub body: StateDefBody,
1450}
1451
1452#[derive(Debug, Clone, PartialEq, Eq)]
1454pub struct Transition {
1455 pub name: Option<String>,
1456 pub source: Option<Node<Expression>>,
1458 pub guard: Option<Node<Expression>>,
1459 pub effect: Option<Node<Expression>>,
1460 pub target: Node<Expression>,
1461 pub body: ConnectBody,
1462}
1463
1464#[derive(Debug, Clone, PartialEq, Eq)]
1470pub struct ConstraintDef {
1471 pub identification: Identification,
1472 pub body: ConstraintDefBody,
1473}
1474
1475#[derive(Debug, Clone, PartialEq, Eq)]
1476pub enum ConstraintDefBody {
1477 Semicolon,
1478 Brace {
1479 elements: Vec<Node<ConstraintDefBodyElement>>,
1480 },
1481}
1482
1483#[derive(Debug, Clone, PartialEq, Eq)]
1484pub enum ConstraintDefBodyElement {
1485 Error(Node<ParseErrorNode>),
1486 Doc(Node<DocComment>),
1487 InOutDecl(Node<InOutDecl>),
1488 Expression(Node<Expression>), Other(String),
1491}
1492
1493#[derive(Debug, Clone, PartialEq, Eq)]
1495pub enum ConstraintBody {
1496 Semicolon,
1497 Brace, }
1499
1500#[derive(Debug, Clone, PartialEq, Eq)]
1502pub struct DocComment {
1503 pub identification: Option<Identification>,
1505 pub locale: Option<String>,
1507 pub text: String,
1509}
1510
1511#[derive(Debug, Clone, PartialEq, Eq)]
1513pub struct CommentAnnotation {
1514 pub identification: Option<Identification>,
1515 pub locale: Option<String>,
1516 pub text: String,
1517}
1518
1519#[derive(Debug, Clone, PartialEq, Eq)]
1521pub struct TextualRepresentation {
1522 pub rep_identification: Option<Identification>,
1523 pub language: String,
1524 pub text: String,
1525}
1526
1527#[derive(Debug, Clone, PartialEq, Eq)]
1529pub struct CalcDef {
1530 pub identification: Identification,
1531 pub body: CalcDefBody,
1532}
1533
1534#[derive(Debug, Clone, PartialEq, Eq)]
1535pub enum CalcDefBody {
1536 Semicolon,
1537 Brace {
1538 elements: Vec<Node<CalcDefBodyElement>>,
1539 },
1540}
1541
1542#[derive(Debug, Clone, PartialEq, Eq)]
1543pub enum CalcDefBodyElement {
1544 Error(Node<ParseErrorNode>),
1545 Doc(Node<DocComment>),
1546 InOutDecl(Node<InOutDecl>),
1547 ReturnDecl(Node<ReturnDecl>),
1548 Expression(Node<Expression>), Other(String),
1551}
1552
1553#[derive(Debug, Clone, PartialEq, Eq)]
1555pub struct ReturnDecl {
1556 pub name: String,
1557 pub type_name: String,
1558}
1559
1560#[derive(Debug, Clone, PartialEq, Eq)]
1566pub struct ViewDef {
1567 pub identification: Identification,
1568 pub body: ViewDefBody,
1569}
1570
1571#[derive(Debug, Clone, PartialEq, Eq)]
1572pub enum ViewDefBody {
1573 Semicolon,
1574 Brace {
1575 elements: Vec<Node<ViewDefBodyElement>>,
1576 },
1577}
1578
1579#[derive(Debug, Clone, PartialEq, Eq)]
1580pub enum ViewDefBodyElement {
1581 Error(Node<ParseErrorNode>),
1582 Other(String),
1584 Doc(Node<DocComment>),
1585 Filter(Node<FilterMember>),
1586 ViewRendering(Node<ViewRenderingUsage>),
1587}
1588
1589#[derive(Debug, Clone, PartialEq, Eq)]
1591pub struct ViewRenderingUsage {
1592 pub name: String,
1593 pub type_name: Option<String>,
1594 pub body: ConnectBody,
1595}
1596
1597#[derive(Debug, Clone, PartialEq, Eq)]
1599pub struct ViewpointDef {
1600 pub identification: Identification,
1601 pub body: RequirementDefBody,
1602}
1603
1604#[derive(Debug, Clone, PartialEq, Eq)]
1606pub struct RenderingDef {
1607 pub identification: Identification,
1608 pub body: RenderingDefBody,
1609}
1610
1611#[derive(Debug, Clone, PartialEq, Eq)]
1612pub enum RenderingDefBody {
1613 Semicolon,
1614 Brace,
1615}
1616
1617#[derive(Debug, Clone, PartialEq, Eq)]
1619pub struct ViewUsage {
1620 pub name: String,
1621 pub type_name: Option<String>,
1622 pub body: ViewBody,
1623}
1624
1625#[derive(Debug, Clone, PartialEq, Eq)]
1626pub enum ViewBody {
1627 Semicolon,
1628 Brace {
1629 elements: Vec<Node<ViewBodyElement>>,
1630 },
1631}
1632
1633#[derive(Debug, Clone, PartialEq, Eq)]
1634pub enum ViewBodyElement {
1635 Error(Node<ParseErrorNode>),
1636 Other(String),
1638 Doc(Node<DocComment>),
1639 Filter(Node<FilterMember>),
1640 ViewRendering(Node<ViewRenderingUsage>),
1641 Expose(Node<ExposeMember>),
1642 Satisfy(Node<SatisfyViewMember>),
1643}
1644
1645#[derive(Debug, Clone, PartialEq, Eq)]
1647pub struct ExposeMember {
1648 pub target: String,
1650 pub body: ConnectBody,
1651}
1652
1653#[derive(Debug, Clone, PartialEq, Eq)]
1655pub struct SatisfyViewMember {
1656 pub viewpoint_ref: String,
1657 pub body: ConnectBody,
1658}
1659
1660#[derive(Debug, Clone, PartialEq, Eq)]
1662pub struct ViewpointUsage {
1663 pub name: String,
1664 pub type_name: String,
1665 pub body: RequirementDefBody,
1666}
1667
1668#[derive(Debug, Clone, PartialEq, Eq)]
1670pub struct RenderingUsage {
1671 pub name: String,
1672 pub type_name: Option<String>,
1673 pub body: ConnectBody,
1674}
1675
1676impl RootNamespace {
1681 pub fn normalize_for_test_comparison(&self) -> Self {
1684 RootNamespace {
1685 elements: self
1686 .elements
1687 .iter()
1688 .map(normalize_root_element_node)
1689 .collect(),
1690 }
1691 }
1692}
1693
1694fn dummy_node<T: Clone>(_n: &Node<T>, value: T) -> Node<T> {
1695 Node::new(Span::dummy(), value)
1696}
1697
1698fn normalize_root_element_node(el: &Node<RootElement>) -> Node<RootElement> {
1699 let value = match &el.value {
1700 RootElement::Package(p) => RootElement::Package(dummy_node(p, normalize_package(&p.value))),
1701 RootElement::LibraryPackage(lp) => {
1702 RootElement::LibraryPackage(dummy_node(lp, normalize_library_package(&lp.value)))
1703 }
1704 RootElement::Namespace(n) => {
1705 RootElement::Namespace(dummy_node(n, normalize_namespace_decl(&n.value)))
1706 }
1707 RootElement::Import(n) => RootElement::Import(dummy_node(n, n.value.clone())),
1708 };
1709 dummy_node(el, value)
1710}
1711
1712fn normalize_library_package(lp: &LibraryPackage) -> LibraryPackage {
1713 LibraryPackage {
1714 is_standard: lp.is_standard,
1715 identification: lp.identification.clone(),
1716 body: normalize_package_body(&lp.body),
1717 }
1718}
1719
1720fn normalize_namespace_decl(n: &NamespaceDecl) -> NamespaceDecl {
1721 NamespaceDecl {
1722 identification: n.identification.clone(),
1723 body: normalize_package_body(&n.body),
1724 }
1725}
1726
1727fn normalize_package(p: &Package) -> Package {
1728 Package {
1729 identification: p.identification.clone(),
1730 body: normalize_package_body(&p.body),
1731 }
1732}
1733
1734fn normalize_package_body(b: &PackageBody) -> PackageBody {
1735 match b {
1736 PackageBody::Semicolon => PackageBody::Semicolon,
1737 PackageBody::Brace { elements } => PackageBody::Brace {
1738 elements: elements
1739 .iter()
1740 .map(normalize_package_body_element_node)
1741 .collect(),
1742 },
1743 }
1744}
1745
1746fn normalize_package_body_element_node(el: &Node<PackageBodyElement>) -> Node<PackageBodyElement> {
1747 let value = match &el.value {
1748 PackageBodyElement::Error(n) => PackageBodyElement::Error(dummy_node(n, n.value.clone())),
1749 PackageBodyElement::Doc(n) => PackageBodyElement::Doc(dummy_node(n, n.value.clone())),
1750 PackageBodyElement::Comment(n) => {
1751 PackageBodyElement::Comment(dummy_node(n, n.value.clone()))
1752 }
1753 PackageBodyElement::TextualRep(n) => {
1754 PackageBodyElement::TextualRep(dummy_node(n, n.value.clone()))
1755 }
1756 PackageBodyElement::Filter(n) => PackageBodyElement::Filter(dummy_node(n, n.value.clone())),
1757 PackageBodyElement::Package(n) => {
1758 PackageBodyElement::Package(dummy_node(n, normalize_package(&n.value)))
1759 }
1760 PackageBodyElement::LibraryPackage(n) => {
1761 PackageBodyElement::LibraryPackage(dummy_node(n, normalize_library_package(&n.value)))
1762 }
1763 PackageBodyElement::Import(n) => PackageBodyElement::Import(dummy_node(n, n.value.clone())),
1764 PackageBodyElement::PartDef(n) => {
1765 PackageBodyElement::PartDef(dummy_node(n, normalize_part_def(&n.value)))
1766 }
1767 PackageBodyElement::PartUsage(n) => {
1768 PackageBodyElement::PartUsage(dummy_node(n, normalize_part_usage(&n.value)))
1769 }
1770 PackageBodyElement::PortDef(n) => {
1771 PackageBodyElement::PortDef(dummy_node(n, normalize_port_def(&n.value)))
1772 }
1773 PackageBodyElement::InterfaceDef(n) => {
1774 PackageBodyElement::InterfaceDef(dummy_node(n, normalize_interface_def(&n.value)))
1775 }
1776 PackageBodyElement::ConnectionDef(n) => {
1777 PackageBodyElement::ConnectionDef(dummy_node(n, normalize_connection_def(&n.value)))
1778 }
1779 PackageBodyElement::MetadataDef(n) => {
1780 PackageBodyElement::MetadataDef(dummy_node(n, normalize_metadata_def(&n.value)))
1781 }
1782 PackageBodyElement::EnumDef(n) => {
1783 PackageBodyElement::EnumDef(dummy_node(n, normalize_enum_def(&n.value)))
1784 }
1785 PackageBodyElement::OccurrenceDef(n) => {
1786 PackageBodyElement::OccurrenceDef(dummy_node(n, normalize_occurrence_def(&n.value)))
1787 }
1788 PackageBodyElement::OccurrenceUsage(n) => {
1789 PackageBodyElement::OccurrenceUsage(dummy_node(n, n.value.clone()))
1790 }
1791 PackageBodyElement::AliasDef(n) => {
1792 PackageBodyElement::AliasDef(dummy_node(n, n.value.clone()))
1793 }
1794 PackageBodyElement::AttributeDef(n) => {
1795 PackageBodyElement::AttributeDef(dummy_node(n, normalize_attribute_def(&n.value)))
1796 }
1797 PackageBodyElement::ActionDef(n) => {
1798 PackageBodyElement::ActionDef(dummy_node(n, normalize_action_def(&n.value)))
1799 }
1800 PackageBodyElement::ActionUsage(n) => {
1801 PackageBodyElement::ActionUsage(dummy_node(n, normalize_action_usage(&n.value)))
1802 }
1803 PackageBodyElement::RequirementDef(n) => {
1804 PackageBodyElement::RequirementDef(dummy_node(n, n.value.clone()))
1805 }
1806 PackageBodyElement::RequirementUsage(n) => {
1807 PackageBodyElement::RequirementUsage(dummy_node(n, n.value.clone()))
1808 }
1809 PackageBodyElement::Satisfy(n) => {
1810 PackageBodyElement::Satisfy(dummy_node(n, n.value.clone()))
1811 }
1812 PackageBodyElement::UseCaseDef(n) => {
1813 PackageBodyElement::UseCaseDef(dummy_node(n, n.value.clone()))
1814 }
1815 PackageBodyElement::Actor(n) => PackageBodyElement::Actor(dummy_node(n, n.value.clone())),
1816 PackageBodyElement::StateDef(n) => {
1817 PackageBodyElement::StateDef(dummy_node(n, n.value.clone()))
1818 }
1819 PackageBodyElement::StateUsage(n) => {
1820 PackageBodyElement::StateUsage(dummy_node(n, n.value.clone()))
1821 }
1822 PackageBodyElement::ItemDef(n) => {
1823 PackageBodyElement::ItemDef(dummy_node(n, n.value.clone()))
1824 }
1825 PackageBodyElement::IndividualDef(n) => {
1826 PackageBodyElement::IndividualDef(dummy_node(n, n.value.clone()))
1827 }
1828 PackageBodyElement::ConstraintDef(n) => {
1829 PackageBodyElement::ConstraintDef(dummy_node(n, n.value.clone()))
1830 }
1831 PackageBodyElement::CalcDef(n) => {
1832 PackageBodyElement::CalcDef(dummy_node(n, n.value.clone()))
1833 }
1834 PackageBodyElement::ViewDef(n) => {
1835 PackageBodyElement::ViewDef(dummy_node(n, n.value.clone()))
1836 }
1837 PackageBodyElement::ViewpointDef(n) => {
1838 PackageBodyElement::ViewpointDef(dummy_node(n, n.value.clone()))
1839 }
1840 PackageBodyElement::RenderingDef(n) => {
1841 PackageBodyElement::RenderingDef(dummy_node(n, n.value.clone()))
1842 }
1843 PackageBodyElement::ViewUsage(n) => {
1844 PackageBodyElement::ViewUsage(dummy_node(n, n.value.clone()))
1845 }
1846 PackageBodyElement::ViewpointUsage(n) => {
1847 PackageBodyElement::ViewpointUsage(dummy_node(n, n.value.clone()))
1848 }
1849 PackageBodyElement::RenderingUsage(n) => {
1850 PackageBodyElement::RenderingUsage(dummy_node(n, n.value.clone()))
1851 }
1852 PackageBodyElement::Dependency(n) => {
1853 PackageBodyElement::Dependency(dummy_node(n, n.value.clone()))
1854 }
1855 PackageBodyElement::AllocationDef(n) => {
1856 PackageBodyElement::AllocationDef(dummy_node(n, n.value.clone()))
1857 }
1858 PackageBodyElement::AllocationUsage(n) => {
1859 PackageBodyElement::AllocationUsage(dummy_node(n, n.value.clone()))
1860 }
1861 PackageBodyElement::FlowDef(n) => {
1862 PackageBodyElement::FlowDef(dummy_node(n, n.value.clone()))
1863 }
1864 PackageBodyElement::FlowUsage(n) => {
1865 PackageBodyElement::FlowUsage(dummy_node(n, n.value.clone()))
1866 }
1867 PackageBodyElement::ConcernUsage(n) => {
1868 PackageBodyElement::ConcernUsage(dummy_node(n, n.value.clone()))
1869 }
1870 PackageBodyElement::CaseDef(n) => {
1871 PackageBodyElement::CaseDef(dummy_node(n, n.value.clone()))
1872 }
1873 PackageBodyElement::CaseUsage(n) => {
1874 PackageBodyElement::CaseUsage(dummy_node(n, n.value.clone()))
1875 }
1876 PackageBodyElement::AnalysisCaseDef(n) => {
1877 PackageBodyElement::AnalysisCaseDef(dummy_node(n, n.value.clone()))
1878 }
1879 PackageBodyElement::AnalysisCaseUsage(n) => {
1880 PackageBodyElement::AnalysisCaseUsage(dummy_node(n, n.value.clone()))
1881 }
1882 PackageBodyElement::VerificationCaseDef(n) => {
1883 PackageBodyElement::VerificationCaseDef(dummy_node(n, n.value.clone()))
1884 }
1885 PackageBodyElement::VerificationCaseUsage(n) => {
1886 PackageBodyElement::VerificationCaseUsage(dummy_node(n, n.value.clone()))
1887 }
1888 PackageBodyElement::UseCaseUsage(n) => {
1889 PackageBodyElement::UseCaseUsage(dummy_node(n, n.value.clone()))
1890 }
1891 PackageBodyElement::FeatureDecl(n) => {
1892 PackageBodyElement::FeatureDecl(dummy_node(n, n.value.clone()))
1893 }
1894 PackageBodyElement::ClassifierDecl(n) => {
1895 PackageBodyElement::ClassifierDecl(dummy_node(n, n.value.clone()))
1896 }
1897 PackageBodyElement::KermlSemanticDecl(n) => {
1898 PackageBodyElement::KermlSemanticDecl(dummy_node(n, n.value.clone()))
1899 }
1900 PackageBodyElement::KermlFeatureDecl(n) => {
1901 PackageBodyElement::KermlFeatureDecl(dummy_node(n, n.value.clone()))
1902 }
1903 PackageBodyElement::ExtendedLibraryDecl(n) => {
1904 PackageBodyElement::ExtendedLibraryDecl(dummy_node(n, n.value.clone()))
1905 }
1906 };
1907 dummy_node(el, value)
1908}
1909
1910fn normalize_attribute_def(a: &AttributeDef) -> AttributeDef {
1911 AttributeDef {
1912 name: a.name.clone(),
1913 typing: a.typing.clone(),
1914 value: a.value.clone(),
1915 body: a.body.clone(),
1916 name_span: None,
1917 typing_span: None,
1918 }
1919}
1920
1921fn normalize_part_def(p: &PartDef) -> PartDef {
1922 PartDef {
1923 definition_prefix: p.definition_prefix.clone(),
1924 is_individual: p.is_individual,
1925 identification: p.identification.clone(),
1926 specializes: p.specializes.clone(),
1927 specializes_span: None,
1928 body: normalize_part_def_body(&p.body),
1929 }
1930}
1931
1932fn normalize_part_def_body(b: &PartDefBody) -> PartDefBody {
1933 match b {
1934 PartDefBody::Semicolon => PartDefBody::Semicolon,
1935 PartDefBody::Brace { elements } => PartDefBody::Brace {
1936 elements: elements
1937 .iter()
1938 .map(normalize_part_def_body_element_node)
1939 .collect(),
1940 },
1941 }
1942}
1943
1944fn normalize_part_def_body_element_node(el: &Node<PartDefBodyElement>) -> Node<PartDefBodyElement> {
1945 let value = match &el.value {
1946 PartDefBodyElement::Error(n) => PartDefBodyElement::Error(dummy_node(n, n.value.clone())),
1947 PartDefBodyElement::Doc(n) => PartDefBodyElement::Doc(dummy_node(n, n.value.clone())),
1948 PartDefBodyElement::Comment(n) => {
1949 PartDefBodyElement::Comment(dummy_node(n, n.value.clone()))
1950 }
1951 PartDefBodyElement::Annotation(n) => {
1952 PartDefBodyElement::Annotation(dummy_node(n, n.value.clone()))
1953 }
1954 PartDefBodyElement::Other(text) => PartDefBodyElement::Other(text.clone()),
1955 PartDefBodyElement::AttributeDef(n) => {
1956 PartDefBodyElement::AttributeDef(dummy_node(n, normalize_attribute_def(&n.value)))
1957 }
1958 PartDefBodyElement::AttributeUsage(n) => {
1959 PartDefBodyElement::AttributeUsage(dummy_node(n, normalize_attribute_usage(&n.value)))
1960 }
1961 PartDefBodyElement::RequirementUsage(n) => {
1962 PartDefBodyElement::RequirementUsage(dummy_node(n, n.value.clone()))
1963 }
1964 PartDefBodyElement::Ref(n) => {
1965 PartDefBodyElement::Ref(dummy_node(n, normalize_ref_decl(&n.value)))
1966 }
1967 PartDefBodyElement::PortUsage(n) => {
1968 PartDefBodyElement::PortUsage(dummy_node(n, normalize_port_usage(&n.value)))
1969 }
1970 PartDefBodyElement::PartUsage(n) => {
1971 PartDefBodyElement::PartUsage(Box::new(dummy_node(n, normalize_part_usage(&n.value))))
1972 }
1973 PartDefBodyElement::OccurrenceUsage(n) => {
1974 PartDefBodyElement::OccurrenceUsage(Box::new(dummy_node(n, n.value.clone())))
1975 }
1976 PartDefBodyElement::InterfaceDef(n) => {
1977 PartDefBodyElement::InterfaceDef(dummy_node(n, normalize_interface_def(&n.value)))
1978 }
1979 PartDefBodyElement::InterfaceUsage(n) => {
1980 PartDefBodyElement::InterfaceUsage(dummy_node(n, n.value.clone()))
1981 }
1982 PartDefBodyElement::Connect(n) => {
1983 PartDefBodyElement::Connect(dummy_node(n, n.value.clone()))
1984 }
1985 PartDefBodyElement::Connection(n) => {
1986 PartDefBodyElement::Connection(dummy_node(n, n.value.clone()))
1987 }
1988 PartDefBodyElement::Perform(n) => {
1989 PartDefBodyElement::Perform(dummy_node(n, n.value.clone()))
1990 }
1991 PartDefBodyElement::Allocate(n) => {
1992 PartDefBodyElement::Allocate(dummy_node(n, n.value.clone()))
1993 }
1994 PartDefBodyElement::OpaqueMember(n) => {
1995 PartDefBodyElement::OpaqueMember(dummy_node(n, n.value.clone()))
1996 }
1997 PartDefBodyElement::ExhibitState(n) => {
1998 PartDefBodyElement::ExhibitState(dummy_node(n, n.value.clone()))
1999 }
2000 };
2001 dummy_node(el, value)
2002}
2003
2004fn normalize_attribute_usage(a: &AttributeUsage) -> AttributeUsage {
2005 AttributeUsage {
2006 name: a.name.clone(),
2007 redefines: a.redefines.clone(),
2008 value: a.value.clone(),
2009 body: a.body.clone(),
2010 name_span: None,
2011 redefines_span: None,
2012 }
2013}
2014
2015fn normalize_part_usage(p: &PartUsage) -> PartUsage {
2016 PartUsage {
2017 is_individual: p.is_individual,
2018 name: p.name.clone(),
2019 type_name: p.type_name.clone(),
2020 multiplicity: p.multiplicity.clone(),
2021 ordered: p.ordered,
2022 subsets: p.subsets.clone(),
2023 redefines: p.redefines.clone(),
2024 value: p.value.clone(),
2025 body: normalize_part_usage_body(&p.body),
2026 name_span: None,
2027 type_ref_span: None,
2028 }
2029}
2030
2031fn normalize_part_usage_body(b: &PartUsageBody) -> PartUsageBody {
2032 match b {
2033 PartUsageBody::Semicolon => PartUsageBody::Semicolon,
2034 PartUsageBody::Brace { elements } => PartUsageBody::Brace {
2035 elements: elements
2036 .iter()
2037 .map(normalize_part_usage_body_element_node)
2038 .collect(),
2039 },
2040 }
2041}
2042
2043fn normalize_perform(p: &Perform) -> Perform {
2044 Perform {
2045 action_name: p.action_name.clone(),
2046 type_name: p.type_name.clone(),
2047 body: normalize_perform_body(&p.body),
2048 }
2049}
2050
2051fn normalize_perform_body(b: &PerformBody) -> PerformBody {
2052 match b {
2053 PerformBody::Semicolon => PerformBody::Semicolon,
2054 PerformBody::Brace { elements } => PerformBody::Brace {
2055 elements: elements
2056 .iter()
2057 .map(normalize_perform_body_element_node)
2058 .collect(),
2059 },
2060 }
2061}
2062
2063fn normalize_perform_body_element_node(el: &Node<PerformBodyElement>) -> Node<PerformBodyElement> {
2064 let value = match &el.value {
2065 PerformBodyElement::Doc(n) => PerformBodyElement::Doc(dummy_node(n, n.value.clone())),
2066 PerformBodyElement::InOut(n) => PerformBodyElement::InOut(dummy_node(
2067 n,
2068 PerformInOutBinding {
2069 direction: n.value.direction,
2070 name: n.value.name.clone(),
2071 value: normalize_expression_node(&n.value.value),
2072 },
2073 )),
2074 };
2075 dummy_node(el, value)
2076}
2077
2078fn normalize_expression_node(node: &Node<Expression>) -> Node<Expression> {
2079 let value = match &node.value {
2080 Expression::LiteralInteger(x) => Expression::LiteralInteger(*x),
2081 Expression::LiteralReal(s) => Expression::LiteralReal(s.clone()),
2082 Expression::LiteralString(s) => Expression::LiteralString(s.clone()),
2083 Expression::LiteralBoolean(b) => Expression::LiteralBoolean(*b),
2084 Expression::FeatureRef(s) => Expression::FeatureRef(s.clone()),
2085 Expression::MemberAccess(base, member) => {
2086 Expression::MemberAccess(Box::new(normalize_expression_node(base)), member.clone())
2087 }
2088 Expression::Index { base, index } => Expression::Index {
2089 base: Box::new(normalize_expression_node(base)),
2090 index: Box::new(normalize_expression_node(index)),
2091 },
2092 Expression::Bracket(inner) => {
2093 Expression::Bracket(Box::new(normalize_expression_node(inner)))
2094 }
2095 Expression::LiteralWithUnit { value: v, unit } => Expression::LiteralWithUnit {
2096 value: Box::new(normalize_expression_node(v)),
2097 unit: Box::new(normalize_expression_node(unit)),
2098 },
2099 Expression::BinaryOp { op, left, right } => Expression::BinaryOp {
2100 op: op.clone(),
2101 left: Box::new(normalize_expression_node(left)),
2102 right: Box::new(normalize_expression_node(right)),
2103 },
2104 Expression::UnaryOp { op, operand } => Expression::UnaryOp {
2105 op: op.clone(),
2106 operand: Box::new(normalize_expression_node(operand)),
2107 },
2108 Expression::Invocation { callee, args } => Expression::Invocation {
2109 callee: Box::new(normalize_expression_node(callee)),
2110 args: args.iter().map(normalize_expression_node).collect(),
2111 },
2112 Expression::Tuple(items) => {
2113 Expression::Tuple(items.iter().map(normalize_expression_node).collect())
2114 }
2115 Expression::Null => Expression::Null,
2116 };
2117 Node::new(Span::dummy(), value)
2118}
2119
2120fn normalize_part_usage_body_element_node(
2121 el: &Node<PartUsageBodyElement>,
2122) -> Node<PartUsageBodyElement> {
2123 let value = match &el.value {
2124 PartUsageBodyElement::Error(n) => {
2125 PartUsageBodyElement::Error(dummy_node(n, n.value.clone()))
2126 }
2127 PartUsageBodyElement::Doc(n) => PartUsageBodyElement::Doc(dummy_node(n, n.value.clone())),
2128 PartUsageBodyElement::Annotation(n) => {
2129 PartUsageBodyElement::Annotation(dummy_node(n, n.value.clone()))
2130 }
2131 PartUsageBodyElement::AttributeUsage(n) => {
2132 PartUsageBodyElement::AttributeUsage(dummy_node(n, normalize_attribute_usage(&n.value)))
2133 }
2134 PartUsageBodyElement::PartUsage(n) => {
2135 PartUsageBodyElement::PartUsage(Box::new(dummy_node(n, normalize_part_usage(&n.value))))
2136 }
2137 PartUsageBodyElement::OccurrenceUsage(n) => {
2138 PartUsageBodyElement::OccurrenceUsage(Box::new(dummy_node(n, n.value.clone())))
2139 }
2140 PartUsageBodyElement::PortUsage(n) => {
2141 PartUsageBodyElement::PortUsage(dummy_node(n, normalize_port_usage(&n.value)))
2142 }
2143 PartUsageBodyElement::Ref(n) => {
2144 PartUsageBodyElement::Ref(dummy_node(n, normalize_ref_decl(&n.value)))
2145 }
2146 PartUsageBodyElement::Bind(n) => PartUsageBodyElement::Bind(dummy_node(n, n.value.clone())),
2147 PartUsageBodyElement::InterfaceUsage(n) => {
2148 PartUsageBodyElement::InterfaceUsage(dummy_node(n, n.value.clone()))
2149 }
2150 PartUsageBodyElement::Connect(n) => {
2151 PartUsageBodyElement::Connect(dummy_node(n, n.value.clone()))
2152 }
2153 PartUsageBodyElement::Perform(n) => {
2154 PartUsageBodyElement::Perform(dummy_node(n, normalize_perform(&n.value)))
2155 }
2156 PartUsageBodyElement::Allocate(n) => {
2157 PartUsageBodyElement::Allocate(dummy_node(n, n.value.clone()))
2158 }
2159 PartUsageBodyElement::Satisfy(n) => {
2160 PartUsageBodyElement::Satisfy(dummy_node(n, n.value.clone()))
2161 }
2162 PartUsageBodyElement::StateUsage(n) => {
2163 PartUsageBodyElement::StateUsage(dummy_node(n, n.value.clone()))
2164 }
2165 PartUsageBodyElement::MetadataAnnotation(n) => {
2166 PartUsageBodyElement::MetadataAnnotation(dummy_node(n, n.value.clone()))
2167 }
2168 };
2169 dummy_node(el, value)
2170}
2171
2172fn normalize_port_usage(p: &PortUsage) -> PortUsage {
2173 PortUsage {
2174 name: p.name.clone(),
2175 type_name: p.type_name.clone(),
2176 multiplicity: p.multiplicity.clone(),
2177 subsets: p.subsets.clone(),
2178 redefines: p.redefines.clone(),
2179 body: normalize_port_body(&p.body),
2180 name_span: None,
2181 type_ref_span: None,
2182 }
2183}
2184
2185fn normalize_port_body(b: &PortBody) -> PortBody {
2186 match b {
2187 PortBody::Semicolon => PortBody::Semicolon,
2188 PortBody::Brace => PortBody::Brace,
2189 PortBody::BraceWithPorts { elements } => PortBody::BraceWithPorts {
2190 elements: elements
2191 .iter()
2192 .map(|n| dummy_node(n, normalize_port_usage(&n.value)))
2193 .collect(),
2194 },
2195 }
2196}
2197
2198fn normalize_port_def(p: &PortDef) -> PortDef {
2199 PortDef {
2200 identification: p.identification.clone(),
2201 specializes: p.specializes.clone(),
2202 body: normalize_port_def_body(&p.body),
2203 }
2204}
2205
2206fn normalize_port_def_body(b: &PortDefBody) -> PortDefBody {
2207 match b {
2208 PortDefBody::Semicolon => PortDefBody::Semicolon,
2209 PortDefBody::Brace { elements } => PortDefBody::Brace {
2210 elements: elements
2211 .iter()
2212 .map(normalize_port_def_body_element_node)
2213 .collect(),
2214 },
2215 }
2216}
2217
2218fn normalize_port_def_body_element_node(el: &Node<PortDefBodyElement>) -> Node<PortDefBodyElement> {
2219 let value = match &el.value {
2220 PortDefBodyElement::InOutDecl(n) => {
2221 PortDefBodyElement::InOutDecl(dummy_node(n, n.value.clone()))
2222 }
2223 PortDefBodyElement::Doc(n) => PortDefBodyElement::Doc(dummy_node(n, n.value.clone())),
2224 PortDefBodyElement::AttributeDef(n) => {
2225 PortDefBodyElement::AttributeDef(dummy_node(n, normalize_attribute_def(&n.value)))
2226 }
2227 PortDefBodyElement::AttributeUsage(n) => {
2228 PortDefBodyElement::AttributeUsage(dummy_node(n, normalize_attribute_usage(&n.value)))
2229 }
2230 PortDefBodyElement::PortUsage(n) => {
2231 PortDefBodyElement::PortUsage(dummy_node(n, normalize_port_usage(&n.value)))
2232 }
2233 };
2234 dummy_node(el, value)
2235}
2236
2237fn normalize_interface_def(i: &InterfaceDef) -> InterfaceDef {
2238 InterfaceDef {
2239 identification: i.identification.clone(),
2240 body: normalize_interface_def_body(&i.body),
2241 }
2242}
2243
2244fn normalize_connection_def(c: &ConnectionDef) -> ConnectionDef {
2245 ConnectionDef {
2246 annotation: c.annotation.clone(),
2247 identification: c.identification.clone(),
2248 body: normalize_connection_def_body(&c.body),
2249 }
2250}
2251
2252fn normalize_connection_def_body(b: &ConnectionDefBody) -> ConnectionDefBody {
2253 match b {
2254 ConnectionDefBody::Semicolon => ConnectionDefBody::Semicolon,
2255 ConnectionDefBody::Brace { elements } => ConnectionDefBody::Brace {
2256 elements: elements
2257 .iter()
2258 .map(normalize_connection_def_body_element_node)
2259 .collect(),
2260 },
2261 }
2262}
2263
2264fn normalize_connection_def_body_element_node(
2265 el: &Node<ConnectionDefBodyElement>,
2266) -> Node<ConnectionDefBodyElement> {
2267 let value = match &el.value {
2268 ConnectionDefBodyElement::EndDecl(n) => {
2269 ConnectionDefBodyElement::EndDecl(dummy_node(n, normalize_end_decl(&n.value)))
2270 }
2271 ConnectionDefBodyElement::RefDecl(n) => {
2272 ConnectionDefBodyElement::RefDecl(dummy_node(n, normalize_ref_decl(&n.value)))
2273 }
2274 ConnectionDefBodyElement::ConnectStmt(n) => {
2275 ConnectionDefBodyElement::ConnectStmt(dummy_node(n, n.value.clone()))
2276 }
2277 };
2278 dummy_node(el, value)
2279}
2280
2281fn normalize_metadata_def(m: &MetadataDef) -> MetadataDef {
2282 MetadataDef {
2283 is_abstract: m.is_abstract,
2284 identification: m.identification.clone(),
2285 body: m.body.clone(),
2286 }
2287}
2288
2289fn normalize_enum_def(e: &EnumDef) -> EnumDef {
2290 EnumDef {
2291 identification: e.identification.clone(),
2292 body: e.body.clone(),
2293 }
2294}
2295
2296fn normalize_occurrence_def(o: &OccurrenceDef) -> OccurrenceDef {
2297 OccurrenceDef {
2298 is_abstract: o.is_abstract,
2299 identification: o.identification.clone(),
2300 body: o.body.clone(),
2301 }
2302}
2303
2304fn normalize_interface_def_body(b: &InterfaceDefBody) -> InterfaceDefBody {
2305 match b {
2306 InterfaceDefBody::Semicolon => InterfaceDefBody::Semicolon,
2307 InterfaceDefBody::Brace { elements } => InterfaceDefBody::Brace {
2308 elements: elements
2309 .iter()
2310 .map(normalize_interface_def_body_element_node)
2311 .collect(),
2312 },
2313 }
2314}
2315
2316fn normalize_interface_def_body_element_node(
2317 el: &Node<InterfaceDefBodyElement>,
2318) -> Node<InterfaceDefBodyElement> {
2319 let value = match &el.value {
2320 InterfaceDefBodyElement::Doc(n) => {
2321 InterfaceDefBodyElement::Doc(dummy_node(n, n.value.clone()))
2322 }
2323 InterfaceDefBodyElement::EndDecl(n) => {
2324 InterfaceDefBodyElement::EndDecl(dummy_node(n, normalize_end_decl(&n.value)))
2325 }
2326 InterfaceDefBodyElement::RefDecl(n) => {
2327 InterfaceDefBodyElement::RefDecl(dummy_node(n, normalize_ref_decl(&n.value)))
2328 }
2329 InterfaceDefBodyElement::ConnectStmt(n) => {
2330 InterfaceDefBodyElement::ConnectStmt(dummy_node(n, n.value.clone()))
2331 }
2332 };
2333 dummy_node(el, value)
2334}
2335
2336fn normalize_end_decl(e: &EndDecl) -> EndDecl {
2337 EndDecl {
2338 name: e.name.clone(),
2339 type_name: e.type_name.clone(),
2340 uses_derived_syntax: e.uses_derived_syntax,
2341 name_span: None,
2342 type_ref_span: None,
2343 }
2344}
2345
2346fn normalize_ref_decl(r: &RefDecl) -> RefDecl {
2347 RefDecl {
2348 name: r.name.clone(),
2349 type_name: r.type_name.clone(),
2350 value: r.value.clone(),
2351 body: r.body.clone(),
2352 name_span: None,
2353 type_ref_span: None,
2354 }
2355}
2356
2357fn normalize_action_def(a: &ActionDef) -> ActionDef {
2358 ActionDef {
2359 identification: a.identification.clone(),
2360 body: normalize_action_def_body(&a.body),
2361 }
2362}
2363
2364fn normalize_action_def_body(b: &ActionDefBody) -> ActionDefBody {
2365 match b {
2366 ActionDefBody::Semicolon => ActionDefBody::Semicolon,
2367 ActionDefBody::Brace { elements } => ActionDefBody::Brace {
2368 elements: elements
2369 .iter()
2370 .map(normalize_action_def_body_element_node)
2371 .collect(),
2372 },
2373 }
2374}
2375
2376fn normalize_action_def_body_element_node(
2377 el: &Node<ActionDefBodyElement>,
2378) -> Node<ActionDefBodyElement> {
2379 let value = match &el.value {
2380 ActionDefBodyElement::Error(n) => {
2381 ActionDefBodyElement::Error(dummy_node(n, n.value.clone()))
2382 }
2383 ActionDefBodyElement::InOutDecl(n) => {
2384 ActionDefBodyElement::InOutDecl(dummy_node(n, n.value.clone()))
2385 }
2386 ActionDefBodyElement::Doc(n) => ActionDefBodyElement::Doc(dummy_node(n, n.value.clone())),
2387 ActionDefBodyElement::Annotation(n) => {
2388 ActionDefBodyElement::Annotation(dummy_node(n, n.value.clone()))
2389 }
2390 ActionDefBodyElement::RefDecl(n) => {
2391 ActionDefBodyElement::RefDecl(dummy_node(n, normalize_ref_decl(&n.value)))
2392 }
2393 ActionDefBodyElement::Perform(n) => {
2394 ActionDefBodyElement::Perform(dummy_node(n, normalize_perform(&n.value)))
2395 }
2396 ActionDefBodyElement::Bind(n) => ActionDefBodyElement::Bind(dummy_node(n, n.value.clone())),
2397 ActionDefBodyElement::Flow(n) => ActionDefBodyElement::Flow(dummy_node(n, n.value.clone())),
2398 ActionDefBodyElement::FirstStmt(n) => {
2399 ActionDefBodyElement::FirstStmt(dummy_node(n, n.value.clone()))
2400 }
2401 ActionDefBodyElement::MergeStmt(n) => {
2402 ActionDefBodyElement::MergeStmt(dummy_node(n, n.value.clone()))
2403 }
2404 ActionDefBodyElement::StateUsage(n) => {
2405 ActionDefBodyElement::StateUsage(dummy_node(n, n.value.clone()))
2406 }
2407 ActionDefBodyElement::ActionUsage(n) => ActionDefBodyElement::ActionUsage(Box::new(
2408 dummy_node(n, normalize_action_usage(&n.value)),
2409 )),
2410 ActionDefBodyElement::Assign(n) => {
2411 ActionDefBodyElement::Assign(dummy_node(n, n.value.clone()))
2412 }
2413 ActionDefBodyElement::ForLoop(n) => {
2414 ActionDefBodyElement::ForLoop(dummy_node(n, n.value.clone()))
2415 }
2416 ActionDefBodyElement::ThenAction(n) => {
2417 ActionDefBodyElement::ThenAction(dummy_node(n, n.value.clone()))
2418 }
2419 ActionDefBodyElement::Decl(n) => ActionDefBodyElement::Decl(dummy_node(n, n.value.clone())),
2420 };
2421 dummy_node(el, value)
2422}
2423
2424fn normalize_action_usage(a: &ActionUsage) -> ActionUsage {
2425 ActionUsage {
2426 name: a.name.clone(),
2427 type_name: a.type_name.clone(),
2428 accept: a.accept.clone(),
2429 body: normalize_action_usage_body(&a.body),
2430 name_span: None,
2431 type_ref_span: None,
2432 }
2433}
2434
2435fn normalize_action_usage_body(b: &ActionUsageBody) -> ActionUsageBody {
2436 match b {
2437 ActionUsageBody::Semicolon => ActionUsageBody::Semicolon,
2438 ActionUsageBody::Brace { elements } => ActionUsageBody::Brace {
2439 elements: elements
2440 .iter()
2441 .map(normalize_action_usage_body_element_node)
2442 .collect(),
2443 },
2444 }
2445}
2446
2447fn normalize_action_usage_body_element_node(
2448 el: &Node<ActionUsageBodyElement>,
2449) -> Node<ActionUsageBodyElement> {
2450 let value = match &el.value {
2451 ActionUsageBodyElement::Error(n) => {
2452 ActionUsageBodyElement::Error(dummy_node(n, n.value.clone()))
2453 }
2454 ActionUsageBodyElement::Doc(n) => {
2455 ActionUsageBodyElement::Doc(dummy_node(n, n.value.clone()))
2456 }
2457 ActionUsageBodyElement::Annotation(n) => {
2458 ActionUsageBodyElement::Annotation(dummy_node(n, n.value.clone()))
2459 }
2460 ActionUsageBodyElement::InOutDecl(n) => {
2461 ActionUsageBodyElement::InOutDecl(dummy_node(n, n.value.clone()))
2462 }
2463 ActionUsageBodyElement::RefDecl(n) => {
2464 ActionUsageBodyElement::RefDecl(dummy_node(n, normalize_ref_decl(&n.value)))
2465 }
2466 ActionUsageBodyElement::Bind(n) => {
2467 ActionUsageBodyElement::Bind(dummy_node(n, n.value.clone()))
2468 }
2469 ActionUsageBodyElement::Flow(n) => {
2470 ActionUsageBodyElement::Flow(dummy_node(n, n.value.clone()))
2471 }
2472 ActionUsageBodyElement::FirstStmt(n) => {
2473 ActionUsageBodyElement::FirstStmt(dummy_node(n, n.value.clone()))
2474 }
2475 ActionUsageBodyElement::MergeStmt(n) => {
2476 ActionUsageBodyElement::MergeStmt(dummy_node(n, n.value.clone()))
2477 }
2478 ActionUsageBodyElement::StateUsage(n) => {
2479 ActionUsageBodyElement::StateUsage(dummy_node(n, n.value.clone()))
2480 }
2481 ActionUsageBodyElement::ActionUsage(n) => ActionUsageBodyElement::ActionUsage(Box::new(
2482 dummy_node(n, normalize_action_usage(&n.value)),
2483 )),
2484 ActionUsageBodyElement::Assign(n) => {
2485 ActionUsageBodyElement::Assign(dummy_node(n, n.value.clone()))
2486 }
2487 ActionUsageBodyElement::ForLoop(n) => {
2488 ActionUsageBodyElement::ForLoop(dummy_node(n, n.value.clone()))
2489 }
2490 ActionUsageBodyElement::ThenAction(n) => {
2491 ActionUsageBodyElement::ThenAction(dummy_node(n, n.value.clone()))
2492 }
2493 ActionUsageBodyElement::Decl(n) => {
2494 ActionUsageBodyElement::Decl(dummy_node(n, n.value.clone()))
2495 }
2496 };
2497 dummy_node(el, value)
2498}