Commit 203f5210 authored by Christopher Happe's avatar Christopher Happe
Browse files

Jupyter Error mit sys.exit() behoben

parent 7caff8cf
......@@ -42,7 +42,7 @@ class ErrorHandler:
print("Variable " + k + ": " + str(v))
user_input = input("Drücke ENTER zum Fotfahren oder schreibe EXIT zum Beenden:")
if user_input.lower() == 'exit':
sys.exit(0)
raise KeyboardInterrupt
def process_assignment(value_list, forbidden_identifiers, identifier_token_1):
......@@ -239,21 +239,24 @@ def next_nonempty_token(current_function, expected_token):
def interpret(program):
global error_handler, lex, values
lex = lexer.Lexer(regex_to_token, program)
error_handler = ErrorHandler(program)
values = {}
forbidden_identifiers = []
current_token = next_token()
while current_token is not None:
current_token, values = process_program(values, forbidden_identifiers, current_token)
if current_token is not None:
if not current_token.k == 'SEMICOLON':
error_handler.handle_error("Semicolon erwartet")
current_token = next_token()
if current_token is None:
error_handler.handle_error("Semikolons werden nur zur Trennung und nicht zum " +
"Abschluss von Programmen verwendet")
if "x0" in values:
return values.get("x0")
return 0
try:
global error_handler, lex, values
lex = lexer.Lexer(regex_to_token, program)
error_handler = ErrorHandler(program)
values = {}
forbidden_identifiers = []
current_token = next_token()
while current_token is not None:
current_token, values = process_program(values, forbidden_identifiers, current_token)
if current_token is not None:
if not current_token.k == 'SEMICOLON':
error_handler.handle_error("Semicolon erwartet")
current_token = next_token()
if current_token is None:
error_handler.handle_error("Semikolons werden nur zur Trennung und nicht zum " +
"Abschluss von Programmen verwendet")
if "x0" in values:
return values.get("x0")
return 0
except KeyboardInterrupt:
return -1
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment