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 pub value_span: Option<Span>,
114}
115
116#[derive(Debug, Clone, PartialEq, Eq)]
118pub enum AttributeBody {
119 Semicolon,
120 Brace {
121 elements: Vec<Node<AttributeBodyElement>>,
122 },
123}
124
125#[derive(Debug, Clone, PartialEq, Eq)]
126pub enum AttributeBodyElement {
127 Error(Node<ParseErrorNode>),
128 Doc(Node<DocComment>),
129 AttributeDef(Node<AttributeDef>),
130 AttributeUsage(Node<AttributeUsage>),
131 Other(String),
132}
133
134#[derive(Debug, Clone, PartialEq, Eq)]
136pub struct ItemDef {
137 pub identification: Identification,
138 pub specializes: Option<String>,
139 pub specializes_span: Option<Span>,
140 pub body: AttributeBody,
141}
142
143#[derive(Debug, Clone, PartialEq, Eq)]
145pub struct IndividualDef {
146 pub identification: Identification,
147 pub specializes: Option<String>,
148 pub specializes_span: Option<Span>,
149 pub body: AttributeBody,
150}
151
152#[derive(Debug, Clone, PartialEq, Eq)]
154pub struct PartUsage {
155 pub is_individual: bool,
156 pub name: String,
157 pub type_name: String,
159 pub multiplicity: Option<String>,
161 pub ordered: bool,
162 pub subsets: Option<(String, Option<Node<Expression>>)>,
164 pub redefines: Option<String>,
166 pub value: Option<Node<Expression>>,
168 pub body: PartUsageBody,
169 pub name_span: Option<Span>,
171 pub type_ref_span: Option<Span>,
173}
174
175#[derive(Debug, Clone, PartialEq, Eq)]
177pub enum PartUsageBody {
178 Semicolon,
179 Brace {
180 elements: Vec<Node<PartUsageBodyElement>>,
181 },
182}
183
184#[derive(Debug, Clone, PartialEq, Eq)]
186pub struct MetadataAnnotation {
187 pub name: String,
188 pub type_name: Option<String>,
189 pub body: ConnectBody,
190 pub head_span: Option<Span>,
191 pub type_span: Option<Span>,
192}
193
194#[derive(Debug, Clone, PartialEq, Eq)]
196pub struct MetadataKeywordUsage {
197 pub keyword: String,
198 pub type_name: Option<String>,
199 pub body: ConnectBody,
200 pub keyword_span: Span,
201 pub type_span: Option<Span>,
202}
203
204#[derive(Debug, Clone, PartialEq, Eq)]
206pub struct Annotation {
207 pub sigil: String,
208 pub head: String,
209 pub type_name: Option<String>,
210 pub body: ConnectBody,
211 pub head_span: Option<Span>,
212 pub type_span: Option<Span>,
213}
214
215#[derive(Debug, Clone, PartialEq, Eq)]
217pub enum PartUsageBodyElement {
218 Error(Node<ParseErrorNode>),
219 Doc(Node<DocComment>),
220 Annotation(Node<Annotation>),
221 AttributeUsage(Node<AttributeUsage>),
222 EnumerationUsage(Node<EnumerationUsage>),
223 PartUsage(Box<Node<PartUsage>>),
224 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
225 PortUsage(Node<PortUsage>),
226 Bind(Node<Bind>),
227 Ref(Node<RefDecl>),
229 InterfaceUsage(Node<InterfaceUsage>),
230 Connect(Node<Connect>),
231 Perform(Node<Perform>),
232 Allocate(Node<Allocate>),
233 Satisfy(Node<Satisfy>),
234 StateUsage(Node<StateUsage>),
235 MetadataAnnotation(Node<MetadataAnnotation>),
236 MetadataKeywordUsage(Node<MetadataKeywordUsage>),
237}
238
239#[derive(Debug, Clone, PartialEq, Eq)]
241pub struct Perform {
242 pub action_name: String,
244 pub type_name: Option<String>,
246 pub body: PerformBody,
247}
248
249#[derive(Debug, Clone, PartialEq, Eq)]
251pub enum PerformBody {
252 Semicolon,
253 Brace {
254 elements: Vec<Node<PerformBodyElement>>,
255 },
256}
257
258#[derive(Debug, Clone, PartialEq, Eq)]
260pub enum PerformBodyElement {
261 Doc(Node<DocComment>),
262 InOut(Node<PerformInOutBinding>),
263}
264
265#[derive(Debug, Clone, PartialEq, Eq)]
267pub struct PerformInOutBinding {
268 pub direction: InOut,
269 pub name: String,
270 pub value: Node<Expression>,
271}
272
273#[derive(Debug, Clone, PartialEq, Eq)]
275pub struct AttributeUsage {
276 pub name: String,
277 pub typing: Option<String>,
279 pub subsets: Option<String>,
281 pub redefines: Option<String>,
283 pub references: Option<String>,
285 pub crosses: Option<String>,
287 pub value: Option<Node<Expression>>,
289 pub body: AttributeBody,
290 pub name_span: Option<Span>,
292 pub typing_span: Option<Span>,
294 pub redefines_span: Option<Span>,
296}
297
298#[derive(Debug, Clone, PartialEq, Eq)]
304pub struct PortDef {
305 pub identification: Identification,
306 pub specializes: Option<String>,
308 pub specializes_span: Option<Span>,
309 pub body: PortDefBody,
310}
311
312#[derive(Debug, Clone, PartialEq, Eq)]
314pub enum PortDefBody {
315 Semicolon,
316 Brace {
317 elements: Vec<Node<PortDefBodyElement>>,
318 },
319}
320
321#[derive(Debug, Clone, PartialEq, Eq)]
323pub enum PortDefBodyElement {
324 InOutDecl(Node<InOutDecl>),
325 Doc(Node<DocComment>),
326 Error(Node<ParseErrorNode>),
327 AttributeDef(Node<AttributeDef>),
328 AttributeUsage(Node<AttributeUsage>),
329 PortUsage(Node<PortUsage>),
330}
331
332#[derive(Debug, Clone, PartialEq, Eq)]
334pub struct PortUsage {
335 pub name: String,
336 pub type_name: Option<String>,
337 pub multiplicity: Option<String>,
338 pub subsets: Option<(String, Option<Node<Expression>>)>,
340 pub redefines: Option<String>,
341 pub references: Option<String>,
343 pub crosses: Option<String>,
345 pub body: PortBody,
346 pub name_span: Option<Span>,
348 pub type_ref_span: Option<Span>,
350}
351
352#[derive(Debug, Clone, PartialEq, Eq)]
354pub enum PortBody {
355 Semicolon,
356 Brace {
357 elements: Vec<Node<PortBodyElement>>,
358 },
359}
360
361#[derive(Debug, Clone, PartialEq, Eq)]
363#[allow(clippy::large_enum_variant)]
364pub enum PortBodyElement {
365 Error(Node<ParseErrorNode>),
366 InOutDecl(Node<InOutDecl>),
367 PortUsage(Node<PortUsage>),
368 Other(String),
369}
370
371#[derive(Debug, Clone, PartialEq, Eq)]
373pub struct ConnectStmt {
374 pub from: Node<Expression>,
375 pub to: Node<Expression>,
376 pub body: ConnectBody,
377}
378
379#[derive(Debug, Clone, PartialEq, Eq)]
385pub struct InterfaceDef {
386 pub identification: Identification,
387 pub specializes: Option<String>,
388 pub specializes_span: Option<Span>,
389 pub body: InterfaceDefBody,
390}
391
392#[derive(Debug, Clone, PartialEq, Eq)]
394pub enum InterfaceDefBody {
395 Semicolon,
396 Brace {
397 elements: Vec<Node<InterfaceDefBodyElement>>,
398 },
399}
400
401#[derive(Debug, Clone, PartialEq, Eq)]
403pub enum InterfaceDefBodyElement {
404 Doc(Node<DocComment>),
405 EndDecl(Node<EndDecl>),
406 RefDecl(Node<RefDecl>),
407 ConnectStmt(Node<ConnectStmt>),
408}
409
410#[derive(Debug, Clone, PartialEq, Eq)]
412pub struct EndDecl {
413 pub name: String,
414 pub type_name: String,
415 pub uses_derived_syntax: bool,
416 pub name_span: Option<Span>,
418 pub type_ref_span: Option<Span>,
420}
421
422#[derive(Debug, Clone, PartialEq, Eq)]
424pub struct RefDecl {
425 pub name: String,
426 pub type_name: String,
427 pub value: Option<Node<Expression>>,
429 pub body: RefBody,
430 pub name_span: Option<Span>,
432 pub type_ref_span: Option<Span>,
434}
435
436#[derive(Debug, Clone, PartialEq, Eq)]
438pub enum RefBody {
439 Semicolon,
440 Brace,
441}
442
443#[derive(Debug, Clone, PartialEq, Eq)]
449pub struct ConnectionDef {
450 pub annotation: Option<String>,
451 pub identification: Identification,
452 pub specializes: Option<String>,
453 pub specializes_span: Option<Span>,
454 pub body: ConnectionDefBody,
455}
456
457#[derive(Debug, Clone, PartialEq, Eq)]
459pub enum ConnectionDefBody {
460 Semicolon,
461 Brace {
462 elements: Vec<Node<ConnectionDefBodyElement>>,
463 },
464}
465
466#[derive(Debug, Clone, PartialEq, Eq)]
467pub enum ConnectionDefBodyElement {
468 EndDecl(Node<EndDecl>),
469 RefDecl(Node<RefDecl>),
470 ConnectStmt(Node<ConnectStmt>),
471}
472
473#[derive(Debug, Clone, PartialEq, Eq)]
479pub struct MetadataDef {
480 pub is_abstract: bool,
481 pub identification: Identification,
482 pub specializes: Option<String>,
483 pub specializes_span: Option<Span>,
484 pub body: AttributeBody,
485}
486
487#[derive(Debug, Clone, PartialEq, Eq)]
489pub struct MetadataUsage {
490 pub name: String,
491 pub type_name: Option<String>,
492 pub body: AttributeBody,
493}
494
495#[derive(Debug, Clone, PartialEq, Eq)]
501pub struct EnumDef {
502 pub identification: Identification,
503 pub specializes: Option<String>,
504 pub specializes_span: Option<Span>,
505 pub body: EnumerationBody,
506}
507
508#[derive(Debug, Clone, PartialEq, Eq)]
509pub enum EnumerationBody {
510 Semicolon,
511 Brace { values: Vec<String> },
512}
513
514#[derive(Debug, Clone, PartialEq, Eq)]
520pub struct OccurrenceDef {
521 pub is_abstract: bool,
522 pub identification: Identification,
523 pub specializes: Option<String>,
524 pub specializes_span: Option<Span>,
525 pub body: DefinitionBody,
526}
527
528#[derive(Debug, Clone, PartialEq, Eq)]
530pub struct OccurrenceUsage {
531 pub is_individual: bool,
532 pub is_then: bool,
533 pub portion_kind: Option<String>,
534 pub name: String,
535 pub type_name: Option<String>,
536 pub subsets: Option<String>,
537 pub redefines: Option<String>,
538 pub references: Option<String>,
539 pub crosses: Option<String>,
540 pub body: OccurrenceUsageBody,
541}
542
543#[derive(Debug, Clone, PartialEq, Eq)]
544pub enum OccurrenceUsageBody {
545 Semicolon,
546 Brace {
547 elements: Vec<Node<OccurrenceBodyElement>>,
548 },
549}
550
551#[derive(Debug, Clone, PartialEq, Eq)]
553pub struct AssertConstraintMember {
554 pub body: ConstraintDefBody,
555}
556
557#[derive(Debug, Clone, PartialEq, Eq)]
558#[allow(clippy::large_enum_variant)]
559pub enum OccurrenceBodyElement {
560 Error(Node<ParseErrorNode>),
561 Doc(Node<DocComment>),
562 Annotation(Node<Annotation>),
563 AssertConstraint(Node<AssertConstraintMember>),
564 Other(String),
565 AttributeUsage(Node<AttributeUsage>),
566 PartUsage(Box<Node<PartUsage>>),
567 OccurrenceUsage(Box<Node<OccurrenceUsage>>),
568}
569
570#[derive(Debug, Clone, PartialEq, Eq)]
576pub enum DefinitionBody {
577 Semicolon,
578 Brace {
579 elements: Vec<Node<DefinitionBodyElement>>,
580 },
581}
582
583#[derive(Debug, Clone, PartialEq, Eq)]
584#[allow(clippy::large_enum_variant)]
585pub enum DefinitionBodyElement {
586 Error(Node<ParseErrorNode>),
587 Doc(Node<DocComment>),
588 OccurrenceMember(Node<OccurrenceBodyElement>),
589 Other(String),
590}
591#[derive(Debug, Clone, PartialEq, Eq)]
597pub struct Bind {
598 pub left: Node<Expression>,
599 pub right: Node<Expression>,
600 pub body: Option<ConnectBody>,
602}
603
604#[derive(Debug, Clone, PartialEq, Eq)]
606pub enum InterfaceUsage {
607 TypedConnect {
609 interface_type: Option<String>,
610 from: Node<Expression>,
611 to: Node<Expression>,
612 body: ConnectBody,
613 body_elements: Vec<Node<InterfaceUsageBodyElement>>,
614 },
615 Connection {
617 from: Node<Expression>,
618 to: Node<Expression>,
619 body_elements: Vec<Node<InterfaceUsageBodyElement>>,
620 },
621}
622
623#[derive(Debug, Clone, PartialEq, Eq)]
625pub enum InterfaceUsageBodyElement {
626 RefRedef {
628 name: String,
629 value: Node<Expression>,
630 body: RefBody,
631 },
632}
633
634#[derive(Debug, Clone, PartialEq, Eq)]
636pub struct Connect {
637 pub from: Node<Expression>,
638 pub to: Node<Expression>,
639 pub body: ConnectBody,
640}
641
642#[derive(Debug, Clone, PartialEq, Eq)]
648pub struct AliasDef {
649 pub identification: Identification,
650 pub target: String,
651 pub body: AliasBody,
652}
653
654#[derive(Debug, Clone, PartialEq, Eq)]
656pub enum AliasBody {
657 Semicolon,
658 Brace,
659}