From 2086af34d93415e8d01007ae6cff846ea677f254 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 13 Nov 2017 18:14:53 +0100 Subject: [PATCH] Also silence yacc and stuff. --- llvm_emulator/emulator.py | 12 +++++++----- llvm_emulator/parser.py | 4 ++-- llvm_emulator/stepper.py | 1 - 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/llvm_emulator/emulator.py b/llvm_emulator/emulator.py index 41cf336..5bb4ee6 100644 --- a/llvm_emulator/emulator.py +++ b/llvm_emulator/emulator.py @@ -32,7 +32,7 @@ def main(): global llvm_parser llvm_parser = parser.LLVMParser() - llvm_parser.build() + llvm_parser.build( parse_res['print_level'] <= 1 ) if parse_res['auto_path'] is not None: step_behavior = { @@ -47,11 +47,13 @@ def main(): def go_auto(path_to_file, step_behavior): with open(path_to_file, 'r') as f: file_contents = f.read() - print('Parsing {}' - .format(path_to_file)) + if step_behavior['step_print_level'] > 1: + print('Parsing {}' + .format(path_to_file)) ast = llvm_parser.parse(file_contents) - print('Beginning execution of {}' - .format(path_to_file)) + if step_behavior['step_print_level'] > 1: + print('Beginning execution of {}' + .format(path_to_file)) stepper.auto_step(ast, step_behavior = step_behavior) diff --git a/llvm_emulator/parser.py b/llvm_emulator/parser.py index 3528864..95697bc 100644 --- a/llvm_emulator/parser.py +++ b/llvm_emulator/parser.py @@ -474,7 +474,7 @@ class LLVMParser(object): def __init__(self): self.tokens += self.reserved.values() - def build(self): + def build(self, silence_yacc=False): """ Build the parser. @@ -484,7 +484,7 @@ class LLVMParser(object): """ self.lexer = lex.lex(module=self) - self.parser = yacc.yacc(module=self) + self.parser = yacc.yacc(module=self, errorlog=(silence_yacc and yacc.NullLogger() or None)) def parse(self, text): """ diff --git a/llvm_emulator/stepper.py b/llvm_emulator/stepper.py index 15b8d3d..2f306e1 100644 --- a/llvm_emulator/stepper.py +++ b/llvm_emulator/stepper.py @@ -643,7 +643,6 @@ def auto_step(ast, function_name='tigermain', function_args=[1234, 5678], step_b if True: global PRINT_LEVEL PRINT_LEVEL = step_behavior['step_print_level'] - print(PRINT_LEVEL) # tdecls = ast.tdecls