systemc-clang
2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
plugins
hdl
parselib
transforms
structure_collector.py
Go to the documentation of this file.
1
import
warnings
2
3
from
lark
import
Token
4
5
from
parselib.transforms
import
TopDown
6
from
..utils
import
dprint, is_tree_type
7
from
..grammar
import
UnexpectedHCodeStructureError
8
from
..utils
import
dprint
9
10
11
class
StructureCollector
(
TopDown
):
12
"""Collect structural information, such as:
13
module_name: list of port name
14
15
We could leverage this to facilitate generation of assign of ports
16
"""
17
def
__init__
(self):
18
super().
__init__
()
19
self.
hier
= {}
20
self.
current
= self.
hier
21
22
def
moddecl
(self, tree):
23
# we can safely assume that moddecl only contains module types
24
self.
__push_up
(tree)
25
mod_name = tree.children[0]
26
mod_type = tree.children[1].children[0].children[0]
27
self.
current
[mod_name] = mod_type
28
return
tree
29
30
def
start
(self, tree):
31
self.
__push_up
(tree)
32
return
tree
33
34
def
hmodule
(self, tree):
35
d = {}
36
mod_name = tree.children[0]
37
orig = self.
current
38
orig[mod_name] = d
39
self.
current
= d
40
41
self.
__push_up
(tree)
42
43
# restore
44
self.
current
= orig
45
return
tree
parselib.transforms.structure_collector.StructureCollector
Definition
structure_collector.py:11
parselib.transforms.structure_collector.StructureCollector.hmodule
hmodule(self, tree)
Definition
structure_collector.py:34
parselib.transforms.structure_collector.StructureCollector.hier
dict hier
Definition
structure_collector.py:19
parselib.transforms.structure_collector.StructureCollector.current
dict current
Definition
structure_collector.py:20
parselib.transforms.structure_collector.StructureCollector.moddecl
moddecl(self, tree)
Definition
structure_collector.py:22
parselib.transforms.structure_collector.StructureCollector.start
start(self, tree)
Definition
structure_collector.py:30
parselib.transforms.structure_collector.StructureCollector.__init__
__init__(self)
Definition
structure_collector.py:17
parselib.transforms.top_down.TopDown
Definition
top_down.py:24
parselib.transforms.top_down.TopDown.__push_up
__push_up(self, current_node)
Definition
top_down.py:29
parselib.transforms
Definition
__init__.py:1
Generated by
1.12.0