-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDirectiveHandler.py
More file actions
19 lines (16 loc) · 953 Bytes
/
DirectiveHandler.py
File metadata and controls
19 lines (16 loc) · 953 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from ActionSymbol import ActionSymbol
from CodeGenerator import CodeGenerator
from SemanticSymbol import SemanticSymbol
from Semantics import Semantics
class DirectiveHandler:
def __init__(self, error_writer, file_out):
self.semantics = Semantics(error_writer=error_writer)
self.code_generator = CodeGenerator(self.semantics, file_out=file_out)
def handle_directive(self, directive, cur_non_terminal, cur_node):
if isinstance(directive, SemanticSymbol):
self.semantics.handle_semantic_symbol(directive, current_non_terminal=cur_non_terminal,
current_node=cur_node)
elif isinstance(directive, ActionSymbol):
if not self.semantics.error_writer.error:
self.code_generator.handle_action_symbol(directive, current_non_terminal=cur_non_terminal,
current_node=cur_node)