systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
structure_collector.py
Go to the documentation of this file.
1import warnings
2
3from lark import Token
4
5from parselib.transforms import TopDown
6from ..utils import dprint, is_tree_type
7from ..grammar import UnexpectedHCodeStructureError
8from ..utils import dprint
9
10
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
__push_up(self, current_node)
Definition top_down.py:29