From 432ea5a78b9e99fe8afef49e230e63c58a33450c Mon Sep 17 00:00:00 2001 From: weckyy702 Date: Tue, 22 Dec 2020 21:04:35 +0100 Subject: [PATCH 1/2] 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(); } From 985c7e68eafeca553f983e93f98ddc40189fa4f5 Mon Sep 17 00:00:00 2001 From: weckyy702 Date: Tue, 22 Dec 2020 21:05:42 +0100 Subject: [PATCH 2/2] cleaned up debugging junk --- res/input/Wolfgang.png | Bin 96 -> 0 bytes res/output/Iinstruction.png | Bin 96 -> 0 bytes res/output/testink.png | Bin 1461 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 res/input/Wolfgang.png delete mode 100644 res/output/Iinstruction.png delete mode 100644 res/output/testink.png diff --git a/res/input/Wolfgang.png b/res/input/Wolfgang.png deleted file mode 100644 index 6f46d697b3542b884df79378af8b0229ceb35296..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 96 ycmeZ`n83iyz`(!)#Q*;@Fzf)*Am9KdNh2D7%K7AX@iA=SJgc~a(dVpUNCp6!I|>2- diff --git a/res/output/Iinstruction.png b/res/output/Iinstruction.png deleted file mode 100644 index 6f46d697b3542b884df79378af8b0229ceb35296..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 96 ycmeZ`n83iyz`(!)#Q*;@Fzf)*Am9KdNh2D7%K7AX@iA=SJgc~a(dVpUNCp6!I|>2- diff --git a/res/output/testink.png b/res/output/testink.png deleted file mode 100644 index de039e3dd56c1d39dfa57fd2005d71df19c748e1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1461 zcmeAS@N?(olHy`uVBq!ia0y~yVAKKPFC0uj5ssqv1O^7y8c!F;kcv5PFB>v4DDWIG zII#b@uN%J*Yi(8fGlse0><8Zaa2N_ZooNv;Ry;Dw91VxjL@=5eMoR)}l!!Tu{eEmu UZ|7yT0gGb>Pgg&ebxsLQ0O^poJ^%m!