systemc-clang
2.0.0
Parsing SystemC constructs
Loading...
Searching...
No Matches
plugins
hdl
parselib
transforms
top_down.py
Go to the documentation of this file.
1
from
contextlib
import
contextmanager
2
from
lark.visitors
import
Interpreter
3
# visit_children_decor first visit the child and then execute the current function
4
5
6
class
VariableBindings
:
7
variable_binding_stack = list()
8
9
@staticmethod
10
def
get_type
(name):
11
for
var_dict
in
reversed(VariableBindings.variable_binding_stack):
12
if
name
in
var_dict:
13
return
var_dict[name]
14
return
None
15
16
17
@contextmanager
18
def
some_vars
(var_dict):
19
VariableBindings.variable_binding_stack.append(var_dict)
20
yield
21
VariableBindings.variable_binding_stack.pop()
22
23
24
class
TopDown
(Interpreter):
25
def
__default__
(self, t):
26
self.
__push_up
(t)
27
return
t
28
29
def
__push_up
(self, current_node):
30
current_node.children = self.visit_children(current_node)
31
32
def
__init__
(self):
33
pass
34
parselib.transforms.top_down.TopDown
Definition
top_down.py:24
parselib.transforms.top_down.TopDown.__default__
__default__(self, t)
Definition
top_down.py:25
parselib.transforms.top_down.TopDown.__push_up
__push_up(self, current_node)
Definition
top_down.py:29
parselib.transforms.top_down.TopDown.__init__
__init__(self)
Definition
top_down.py:32
parselib.transforms.top_down.VariableBindings
Definition
top_down.py:6
parselib.transforms.top_down.VariableBindings.get_type
get_type(name)
Definition
top_down.py:10
parselib.transforms.top_down.some_vars
some_vars(var_dict)
Definition
top_down.py:18
Generated by
1.12.0