systemc-clang
2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
plugins
hdl
parselib
transforms
node_merge.py
Go to the documentation of this file.
1
from
parselib.transforms
import
TopDown
2
3
4
class
NodeMergePass
(
TopDown
):
5
"""
6
This pass merges separate nodes that are created for easy recognition for grammar,
7
but actually shares the same semantics
8
"""
9
def
hnsbinop
(self, tree):
10
self.
__push_up
(tree)
11
tree.data =
'hbinop'
12
return
tree
13
14
def
__transform_arrayref_syscread
(self, tree):
15
if
len(tree.children) == 2
and
tree.children[1].data ==
'hbinop'
and
tree.children[1].children[0] ==
'ARRAYSUBSCRIPT'
:
16
true_node = tree.children[1]
17
true_node.children = true_node.children[1:]
18
true_node.data =
'harrayref'
19
return
true_node
20
return
tree
21
22
def
blkassign
(self, tree):
23
"""this handler fixes the a[b].read() case by removing read() and making it a[b]"""
24
self.
__push_up
(tree)
25
for
idx, t
in
enumerate(tree.children):
26
if
t.data ==
'syscread'
:
27
tree.children[idx] = self.
__transform_arrayref_syscread
(t)
28
# dprint(tree)
29
return
tree
parselib.transforms.node_merge.NodeMergePass
Definition
node_merge.py:4
parselib.transforms.node_merge.NodeMergePass.__transform_arrayref_syscread
__transform_arrayref_syscread(self, tree)
Definition
node_merge.py:14
parselib.transforms.node_merge.NodeMergePass.blkassign
blkassign(self, tree)
Definition
node_merge.py:22
parselib.transforms.node_merge.NodeMergePass.hnsbinop
hnsbinop(self, tree)
Definition
node_merge.py:9
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