From fff1289ee09bb0b30f6f9202503c411d37ed8113 Mon Sep 17 00:00:00 2001 From: Chris <Christopher.Happe@uni-duesseldorf.de> Date: Wed, 18 Nov 2020 12:32:31 +0100 Subject: [PATCH] =?UTF-8?q?Bugfix:=20Fehlermeldungen=20haben=20WHILE=20nic?= =?UTF-8?q?ht=20ber=C3=BCcksichtigt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- info4/kapitel-8/Interpreter/whileinterpreter.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/info4/kapitel-8/Interpreter/whileinterpreter.py b/info4/kapitel-8/Interpreter/whileinterpreter.py index e47e6f6..cbddb54 100644 --- a/info4/kapitel-8/Interpreter/whileinterpreter.py +++ b/info4/kapitel-8/Interpreter/whileinterpreter.py @@ -17,14 +17,13 @@ class WHILEInterpreter(LOOPInterpreter): (re.compile(r'END'), 'END'), (re.compile(r';'), 'SEMICOLON'), (re.compile(r'BREAK'), 'BREAK'), - (re.compile(r'\n', re.MULTILINE), 'LINEBREAK'), - (re.compile(r'\s+'), 'WHITESPACE'), + (re.compile(r'\s+', re.MULTILINE), 'WHITESPACE'), (re.compile(r'[^\n]*'), 'UNKNOWN')] def process_program(self, forbidden_identifiers, current_token): if current_token is None or current_token.k not in ['IDENTIFIER', 'LOOP', 'WHILE']: self.error_handler.handle_error("Keine passende Anweisung gefunden\n" + - "Erwartet: IDENTIFIER (x0, x1, ...) oder LOOP") + "Erwartet: IDENTIFIER (x0, x1, ...), LOOP oder WHILE") elif current_token.k == 'IDENTIFIER': current_token = self.process_assignment(forbidden_identifiers, current_token) elif current_token.k == 'LOOP': @@ -36,7 +35,7 @@ class WHILEInterpreter(LOOPInterpreter): def verify_program(self, forbidden_identifiers, current_token): if current_token is None or current_token.k not in ['IDENTIFIER', 'LOOP', 'WHILE']: self.error_handler.handle_error("Keine passende Anweisung gefunden\n" + - "Erwartet: IDENTIFIER (x0, x1, ...) oder LOOP") + "Erwartet: IDENTIFIER (x0, x1, ...), LOOP oder WHILE") elif current_token.k == 'IDENTIFIER': current_token = self.verify_assignment(forbidden_identifiers, current_token) elif current_token.k == 'LOOP': @@ -133,6 +132,7 @@ class WHILEInterpreter(LOOPInterpreter): return self.next_token() + def interpret(program): interpreter = WHILEInterpreter() return interpreter.interpret(program) -- GitLab