From 432ea5a78b9e99fe8afef49e230e63c58a33450c Mon Sep 17 00:00:00 2001 From: weckyy702 Date: Tue, 22 Dec 2020 21:04:35 +0100 Subject: [PATCH] changed expected syntax for source code interpretation --- .vscode/launch.json | 2 +- interpret_source.py | 4 ++-- res/input/input.java | 6 ++++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 6e0fa0a..eaba26a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "Python: Aktuelle Datei", "type": "python", "request": "launch", - "program": "gui.py", + "program": "interpret_source.py", "console": "integratedTerminal" } ] diff --git a/interpret_source.py b/interpret_source.py index 582b10b..577a2b1 100644 --- a/interpret_source.py +++ b/interpret_source.py @@ -52,10 +52,10 @@ def get_instructions_in_scope(src: List[str], start_idx: int = 0) -> Tuple[List[ logging.debug("Found if instruction in line: %i", i+1) bracket_idx = line.rindex(')') # throws if the contruct is illformed instruction_txt = line[3:bracket_idx] - true_instructions, i = get_instructions_in_scope(src, i+1) + true_instructions, i = get_instructions_in_scope(src, i+2) false_instructions = None if src[i].__contains__("else"): #if there is an else statement, check it - false_instructions, i = get_instructions_in_scope(src, i+1) + false_instructions, i = get_instructions_in_scope(src, i+2) outer_scope.add_instruction(if_instruction(instruction_txt, true_instructions, false_instructions)) else: diff --git a/res/input/input.java b/res/input/input.java index 9879351..d65e001 100644 --- a/res/input/input.java +++ b/res/input/input.java @@ -3,10 +3,12 @@ fahre2(); while(shouldNiet()) { niet4(); niet5(); - if(if6) { + if(if6) + { niet7(); niet8(); - } else { + } else + { niet10(); niet11(); }