systemc-clang 2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
node_movement.py
Go to the documentation of this file.
1from lark import Tree, Token
2from parselib.utils import dprint
3from parselib.transforms import TopDown
4
5
7 def __init__(self):
8 super().__init__()
9 # record function per module
10 self.functions = dict()
11 self.current_module = None
12
13 def hmodule(self, tree):
14 self.current_module = tree.children[0]
15 self.__push_up(tree)
16 functions = self.functions.get(self.current_module)
17 if functions:
18 for f in functions:
19 tree.children.append(f)
20 self.current_module = None
21 return tree
22
23 def __add_functions(self, functions):
24 res = self.functions.setdefault(self.current_module, [])
25 res.extend(functions)
26
27 def hprocess(self, tree):
28 functions = list(filter(lambda x: isinstance(x, Tree) and x.data == 'hfunction', tree.children))
29 tree.children = list(filter(lambda x: not (isinstance(x, Tree) and x.data == 'hfunction'), tree.children))
30 self.__add_functions(functions)
31 return tree
__push_up(self, current_node)
Definition top_down.py:29