1use super::behavior::{Allocate, InOut, InOutDecl, StateDefBody, StateUsage};
2use super::common::{CommentAnnotation, ConnectBody, DocComment, Identification, ParseErrorNode};
3use super::requirement::{EnumerationUsage, ItemUsage, RequirementUsage, Satisfy};
4use super::view::{CalcUsage, ConstraintDefBody};
5use crate::ast::core::{Expression, Node, Span};
6
7#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct PartDef {
10 pub definition_prefix: Option<DefinitionPrefix>,
12 pub is_individual: bool,
14 pub identification: Identification,
15 pub specializes: Option<String>,
17 pub specializes_span: Option<Span>,
19 pub body: PartDefBody,
20}
21
22#[derive(Debug, Clone, PartialEq, Eq)]
24pub enum DefinitionPrefix {
25 Abstract,
26 Variation,
27}
28
29#[derive(Debug, Clone, PartialEq, Eq)]
31pub enum PartDefBody {
32 Semicolon,
33 Brace {
34 elements: Vec<Node<PartDefBodyElement>>,
35 },
36}
37
38#[derive(Debug, Clone, PartialEq, Eq)]
40pub enum PartDefBodyElement {
41 Error(Node<ParseErrorNode>),
42 Doc(Node<DocComment>),
43 Comment(Node<CommentAnnotation>),
44 Annotation(Node<Annotation>),
45 MetadataKeywordUsage(Node<MetadataKeywordUsage>),
46 Other(String),
47 AttributeDef(Node<AttributeDef>),
48 AttributeUsage(Node<AttributeUsage>),
49 RequirementUsage(Node<RequirementUsage>),
50 ItemUsage(Node<ItemUsage>),
51 Ref(Node<RefDecl>),
52 PortUsage(Node<PortUsage>),
53 PartUsage(Box<Node<PartUsage>>),
54 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
55 InterfaceDef(Node<InterfaceDef>),
56 InterfaceUsage(Node<InterfaceUsage>),
57 Connect(Node<Connect>),
58 Connection(Node<ConnectionUsageMember>),
60 Perform(Node<Perform>),
61 Allocate(Node<Allocate>),
62 OpaqueMember(Node<OpaqueMemberDecl>),
63 ExhibitState(Node<ExhibitState>),
65 CalcUsage(Node<CalcUsage>),
67 EnumerationUsage(Node<EnumerationUsage>),
69}
70
71#[derive(Debug, Clone, PartialEq, Eq)]
73pub struct OpaqueMemberDecl {
74 pub keyword: String,
75 pub name: String,
76 pub text: String,
77 pub body: AttributeBody,
78}
79
80#[derive(Debug, Clone, PartialEq, Eq)]
82pub struct ConnectionUsageMember {
83 pub name: Option<String>,
84 pub type_name: Option<String>,
85 pub body: ConnectionDefBody,
86 pub subsets: Option<String>,
87 pub redefines: Option<String>,
88}
89
90#[derive(Debug, Clone, PartialEq, Eq)]
92pub struct ExhibitState {
93 pub name: String,
94 pub type_name: Option<String>,
95 pub redefines: Option<String>,
96 pub body: StateDefBody,
97}
98
99#[derive(Debug, Clone, PartialEq, Eq)]
101pub struct AttributeDef {
102 pub name: String,
103 pub typing: Option<String>,
105 pub value: Option<Node<Expression>>,
107 pub body: AttributeBody,
108 pub name_span: Option<Span>,
110 pub typing_span: Option<Span>,
112}
113
114#[derive(Debug, Clone, PartialEq, Eq)]
116pub enum AttributeBody {
117 Semicolon,
118 Brace {
119 elements: Vec<Node<AttributeBodyElement>>,
120 },
121}
122
123#[derive(Debug, Clone, PartialEq, Eq)]
124pub enum AttributeBodyElement {
125 Error(Node<ParseErrorNode>),
126 Doc(Node<DocComment>),
127 AttributeDef(Node<AttributeDef>),
128 AttributeUsage(Node<AttributeUsage>),
129 Other(String),
130}
131
132#[derive(Debug, Clone, PartialEq, Eq)]
134pub struct ItemDef {
135 pub identification: Identification,
136 pub specializes: Option<String>,
137 pub specializes_span: Option<Span>,
138 pub body: AttributeBody,
139}
140
141#[derive(Debug, Clone, PartialEq, Eq)]
143pub struct IndividualDef {
144 pub identification: Identification,
145 pub specializes: Option<String>,
146 pub specializes_span: Option<Span>,
147 pub body: AttributeBody,
148}
149
150#[derive(Debug, Clone, PartialEq, Eq)]
152pub struct PartUsage {
153 pub is_individual: bool,
154 pub name: String,
155 pub type_name: String,
157 pub multiplicity: Option<String>,
159 pub ordered: bool,
160 pub subsets: Option<(String, Option<Node<Expression>>)>,
162 pub redefines: Option<String>,
164 pub value: Option<Node<Expression>>,
166 pub body: PartUsageBody,
167 pub name_span: Option<Span>,
169 pub type_ref_span: Option<Span>,
171}
172
173#[derive(Debug, Clone, PartialEq, Eq)]
175pub enum PartUsageBody {
176 Semicolon,
177 Brace {
178 elements: Vec<Node<PartUsageBodyElement>>,
179 },
180}
181
182#[derive(Debug, Clone, PartialEq, Eq)]
184pub struct MetadataAnnotation {
185 pub name: String,
186 pub type_name: Option<String>,
187 pub body: ConnectBody,
188 pub head_span: Option<Span>,
189 pub type_span: Option<Span>,
190}
191
192#[derive(Debug, Clone, PartialEq, Eq)]
194pub struct MetadataKeywordUsage {
195 pub keyword: String,
196 pub type_name: Option<String>,
197 pub body: ConnectBody,
198 pub keyword_span: Span,
199 pub type_span: Option<Span>,
200}
201
202#[derive(Debug, Clone, PartialEq, Eq)]
204pub struct Annotation {
205 pub sigil: String,
206 pub head: String,
207 pub type_name: Option<String>,
208 pub body: ConnectBody,
209 pub head_span: Option<Span>,
210 pub type_span: Option<Span>,
211}
212
213#[derive(Debug, Clone, PartialEq, Eq)]
215pub enum PartUsageBodyElement {
216 Error(Node<ParseErrorNode>),
217 Doc(Node<DocComment>),
218 Annotation(Node<Annotation>),
219 AttributeUsage(Node<AttributeUsage>),
220 EnumerationUsage(Node<EnumerationUsage>),
221 PartUsage(Box<Node<PartUsage>>),
222 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
223 PortUsage(Node<PortUsage>),
224 Bind(Node<Bind>),
225 Ref(Node<RefDecl>),
227 InterfaceUsage(Node<InterfaceUsage>),
228 Connect(Node<Connect>),
229 Perform(Node<Perform>),
230 Allocate(Node<Allocate>),
231 Satisfy(Node<Satisfy>),
232 StateUsage(Node<StateUsage>),
233 MetadataAnnotation(Node<MetadataAnnotation>),
234 MetadataKeywordUsage(Node<MetadataKeywordUsage>),
235}
236
237#[derive(Debug, Clone, PartialEq, Eq)]
239pub struct Perform {
240 pub action_name: String,
242 pub type_name: Option<String>,
244 pub body: PerformBody,
245}
246
247#[derive(Debug, Clone, PartialEq, Eq)]
249pub enum PerformBody {
250 Semicolon,
251 Brace {
252 elements: Vec<Node<PerformBodyElement>>,
253 },
254}
255
256#[derive(Debug, Clone, PartialEq, Eq)]
258pub enum PerformBodyElement {
259 Doc(Node<DocComment>),
260 InOut(Node<PerformInOutBinding>),
261}
262
263#[derive(Debug, Clone, PartialEq, Eq)]
265pub struct PerformInOutBinding {
266 pub direction: InOut,
267 pub name: String,
268 pub value: Node<Expression>,
269}
270
271#[derive(Debug, Clone, PartialEq, Eq)]
273pub struct AttributeUsage {
274 pub name: String,
275 pub typing: Option<String>,
277 pub subsets: Option<String>,
279 pub redefines: Option<String>,
281 pub references: Option<String>,
283 pub crosses: Option<String>,
285 pub value: Option<Node<Expression>>,
287 pub body: AttributeBody,
288 pub name_span: Option<Span>,
290 pub typing_span: Option<Span>,
292 pub redefines_span: Option<Span>,
294}
295
296#[derive(Debug, Clone, PartialEq, Eq)]
302pub struct PortDef {
303 pub identification: Identification,
304 pub specializes: Option<String>,
306 pub specializes_span: Option<Span>,
307 pub body: PortDefBody,
308}
309
310#[derive(Debug, Clone, PartialEq, Eq)]
312pub enum PortDefBody {
313 Semicolon,
314 Brace {
315 elements: Vec<Node<PortDefBodyElement>>,
316 },
317}
318
319#[derive(Debug, Clone, PartialEq, Eq)]
321pub enum PortDefBodyElement {
322 InOutDecl(Node<InOutDecl>),
323 Doc(Node<DocComment>),
324 Error(Node<ParseErrorNode>),
325 AttributeDef(Node<AttributeDef>),
326 AttributeUsage(Node<AttributeUsage>),
327 PortUsage(Node<PortUsage>),
328}
329
330#[derive(Debug, Clone, PartialEq, Eq)]
332pub struct PortUsage {
333 pub name: String,
334 pub type_name: Option<String>,
335 pub multiplicity: Option<String>,
336 pub subsets: Option<(String, Option<Node<Expression>>)>,
338 pub redefines: Option<String>,
339 pub references: Option<String>,
341 pub crosses: Option<String>,
343 pub body: PortBody,
344 pub name_span: Option<Span>,
346 pub type_ref_span: Option<Span>,
348}
349
350#[derive(Debug, Clone, PartialEq, Eq)]
352pub enum PortBody {
353 Semicolon,
354 Brace {
355 elements: Vec<Node<PortBodyElement>>,
356 },
357}
358
359#[derive(Debug, Clone, PartialEq, Eq)]
361#[allow(clippy::large_enum_variant)]
362pub enum PortBodyElement {
363 Error(Node<ParseErrorNode>),
364 InOutDecl(Node<InOutDecl>),
365 PortUsage(Node<PortUsage>),
366 Other(String),
367}
368
369#[derive(Debug, Clone, PartialEq, Eq)]
371pub struct ConnectStmt {
372 pub from: Node<Expression>,
373 pub to: Node<Expression>,
374 pub body: ConnectBody,
375}
376
377#[derive(Debug, Clone, PartialEq, Eq)]
383pub struct InterfaceDef {
384 pub identification: Identification,
385 pub specializes: Option<String>,
386 pub specializes_span: Option<Span>,
387 pub body: InterfaceDefBody,
388}
389
390#[derive(Debug, Clone, PartialEq, Eq)]
392pub enum InterfaceDefBody {
393 Semicolon,
394 Brace {
395 elements: Vec<Node<InterfaceDefBodyElement>>,
396 },
397}
398
399#[derive(Debug, Clone, PartialEq, Eq)]
401pub enum InterfaceDefBodyElement {
402 Doc(Node<DocComment>),
403 EndDecl(Node<EndDecl>),
404 RefDecl(Node<RefDecl>),
405 ConnectStmt(Node<ConnectStmt>),
406}
407
408#[derive(Debug, Clone, PartialEq, Eq)]
410pub struct EndDecl {
411 pub name: String,
412 pub type_name: String,
413 pub uses_derived_syntax: bool,
414 pub name_span: Option<Span>,
416 pub type_ref_span: Option<Span>,
418}
419
420#[derive(Debug, Clone, PartialEq, Eq)]
422pub struct RefDecl {
423 pub name: String,
424 pub type_name: String,
425 pub value: Option<Node<Expression>>,
427 pub body: RefBody,
428 pub name_span: Option<Span>,
430 pub type_ref_span: Option<Span>,
432}
433
434#[derive(Debug, Clone, PartialEq, Eq)]
436pub enum RefBody {
437 Semicolon,
438 Brace,
439}
440
441#[derive(Debug, Clone, PartialEq, Eq)]
447pub struct ConnectionDef {
448 pub annotation: Option<String>,
449 pub identification: Identification,
450 pub specializes: Option<String>,
451 pub specializes_span: Option<Span>,
452 pub body: ConnectionDefBody,
453}
454
455#[derive(Debug, Clone, PartialEq, Eq)]
457pub enum ConnectionDefBody {
458 Semicolon,
459 Brace {
460 elements: Vec<Node<ConnectionDefBodyElement>>,
461 },
462}
463
464#[derive(Debug, Clone, PartialEq, Eq)]
465pub enum ConnectionDefBodyElement {
466 EndDecl(Node<EndDecl>),
467 RefDecl(Node<RefDecl>),
468 ConnectStmt(Node<ConnectStmt>),
469}
470
471#[derive(Debug, Clone, PartialEq, Eq)]
477pub struct MetadataDef {
478 pub is_abstract: bool,
479 pub identification: Identification,
480 pub specializes: Option<String>,
481 pub specializes_span: Option<Span>,
482 pub body: AttributeBody,
483}
484
485#[derive(Debug, Clone, PartialEq, Eq)]
487pub struct MetadataUsage {
488 pub name: String,
489 pub type_name: Option<String>,
490 pub body: AttributeBody,
491}
492
493#[derive(Debug, Clone, PartialEq, Eq)]
499pub struct EnumDef {
500 pub identification: Identification,
501 pub specializes: Option<String>,
502 pub specializes_span: Option<Span>,
503 pub body: EnumerationBody,
504}
505
506#[derive(Debug, Clone, PartialEq, Eq)]
507pub enum EnumerationBody {
508 Semicolon,
509 Brace { values: Vec<String> },
510}
511
512#[derive(Debug, Clone, PartialEq, Eq)]
518pub struct OccurrenceDef {
519 pub is_abstract: bool,
520 pub identification: Identification,
521 pub specializes: Option<String>,
522 pub specializes_span: Option<Span>,
523 pub body: DefinitionBody,
524}
525
526#[derive(Debug, Clone, PartialEq, Eq)]
528pub struct OccurrenceUsage {
529 pub is_individual: bool,
530 pub is_then: bool,
531 pub portion_kind: Option<String>,
532 pub name: String,
533 pub type_name: Option<String>,
534 pub subsets: Option<String>,
535 pub redefines: Option<String>,
536 pub references: Option<String>,
537 pub crosses: Option<String>,
538 pub body: OccurrenceUsageBody,
539}
540
541#[derive(Debug, Clone, PartialEq, Eq)]
542pub enum OccurrenceUsageBody {
543 Semicolon,
544 Brace {
545 elements: Vec<Node<OccurrenceBodyElement>>,
546 },
547}
548
549#[derive(Debug, Clone, PartialEq, Eq)]
551pub struct AssertConstraintMember {
552 pub body: ConstraintDefBody,
553}
554
555#[derive(Debug, Clone, PartialEq, Eq)]
556#[allow(clippy::large_enum_variant)]
557pub enum OccurrenceBodyElement {
558 Error(Node<ParseErrorNode>),
559 Doc(Node<DocComment>),
560 Annotation(Node<Annotation>),
561 AssertConstraint(Node<AssertConstraintMember>),
562 Other(String),
563 AttributeUsage(Node<AttributeUsage>),
564 PartUsage(Box<Node<PartUsage>>),
565 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
566}
567
568#[derive(Debug, Clone, PartialEq, Eq)]
574pub enum DefinitionBody {
575 Semicolon,
576 Brace {
577 elements: Vec<Node<DefinitionBodyElement>>,
578 },
579}
580
581#[derive(Debug, Clone, PartialEq, Eq)]
582#[allow(clippy::large_enum_variant)]
583pub enum DefinitionBodyElement {
584 Error(Node<ParseErrorNode>),
585 Doc(Node<DocComment>),
586 OccurrenceMember(Node<OccurrenceBodyElement>),
587 Other(String),
588}
589#[derive(Debug, Clone, PartialEq, Eq)]
595pub struct Bind {
596 pub left: Node<Expression>,
597 pub right: Node<Expression>,
598 pub body: Option<ConnectBody>,
600}
601
602#[derive(Debug, Clone, PartialEq, Eq)]
604pub enum InterfaceUsage {
605 TypedConnect {
607 interface_type: Option<String>,
608 from: Node<Expression>,
609 to: Node<Expression>,
610 body: ConnectBody,
611 body_elements: Vec<Node<InterfaceUsageBodyElement>>,
612 },
613 Connection {
615 from: Node<Expression>,
616 to: Node<Expression>,
617 body_elements: Vec<Node<InterfaceUsageBodyElement>>,
618 },
619}
620
621#[derive(Debug, Clone, PartialEq, Eq)]
623pub enum InterfaceUsageBodyElement {
624 RefRedef {
626 name: String,
627 value: Node<Expression>,
628 body: RefBody,
629 },
630}
631
632#[derive(Debug, Clone, PartialEq, Eq)]
634pub struct Connect {
635 pub from: Node<Expression>,
636 pub to: Node<Expression>,
637 pub body: ConnectBody,
638}
639
640#[derive(Debug, Clone, PartialEq, Eq)]
646pub struct AliasDef {
647 pub identification: Identification,
648 pub target: String,
649 pub body: AliasBody,
650}
651
652#[derive(Debug, Clone, PartialEq, Eq)]
654pub enum AliasBody {
655 Semicolon,
656 Brace,
657}