Commit fff1289e authored by Christopher Happe's avatar Christopher Happe
Browse files

Bugfix: Fehlermeldungen haben WHILE nicht berücksichtigt

parent 2259081c
......@@ -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)
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