1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
pub use crate::generated::veryl_grammar_trait::*;
use paste::paste;
macro_rules! list_to_item {
($x:ident) => {
paste! {
impl From<&[<$x List>]> for Vec<[<$x Item>]> {
fn from(x: &[<$x List>]) -> Self {
let mut ret = Vec::new();
{
let mut x: Vec<[<$x Item>]> = x.[<$x:snake _group>].as_ref().into();
ret.append(&mut x);
}
for x in &x.[<$x:snake _list_list>] {
let mut x: Vec<[<$x Item>]> = x.[<$x:snake _group>].as_ref().into();
ret.append(&mut x);
}
ret
}
}
impl From<&[<$x Group>]> for Vec<[<$x Item>]> {
fn from(x: &[<$x Group>]) -> Self {
let mut ret = Vec::new();
match &*x.[<$x:snake _group_group>] {
[<$x GroupGroup>]::[<LBrace $x ListRBrace>](x) => {
let mut x: Vec<[<$x Item>]> = x.[<$x:snake _list>].as_ref().into();
ret.append(&mut x);
}
[<$x GroupGroup>]::[<$x Item>](x) => {
ret.push(x.[<$x:snake _item>].as_ref().clone());
}
}
ret
}
}
}
};
}
macro_rules! group_to_item {
($x:ident) => {
paste! {
impl From<&[<$x Group>]> for Vec<[<$x Item>]> {
fn from(x: &[<$x Group>]) -> Self {
let mut ret = Vec::new();
match &*x.[<$x:snake _group_group>] {
[<$x GroupGroup>]::[<LBrace $x GroupGroupListRBrace>](x) => {
for x in &x.[<$x:snake _group_group_list>] {
let mut x: Vec<[<$x Item>]> = x.[<$x:snake _group>].as_ref().into();
ret.append(&mut x);
}
}
[<$x GroupGroup>]::[<$x Item>](x) => {
ret.push(x.[<$x:snake _item>].as_ref().clone());
}
}
ret
}
}
}
};
}
impl From<&AttributeList> for Vec<AttributeItem> {
fn from(x: &AttributeList) -> Self {
let mut ret = Vec::new();
ret.push(x.attribute_item.as_ref().clone());
for x in &x.attribute_list_list {
ret.push(x.attribute_item.as_ref().clone());
}
ret
}
}
list_to_item!(Modport);
list_to_item!(Enum);
list_to_item!(Struct);
list_to_item!(InstParameter);
list_to_item!(InstPort);
list_to_item!(WithParameter);
list_to_item!(PortDeclaration);
group_to_item!(Module);
group_to_item!(Interface);
group_to_item!(Package);
group_to_item!(Description);