Skip to content
Snippets Groups Projects
Commit fff1289e authored by Chris's avatar Chris
Browse files

Bugfix: Fehlermeldungen haben WHILE nicht berücksichtigt

parent 2259081c
No related branches found
No related tags found
1 merge request!1Master
......@@ -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)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment