This commit is contained in:
oleting
2021-01-17 12:12:54 +00:00

View File

@@ -1,6 +1,5 @@
import logging
import re
import sys
from typing import Dict, List, Match, Tuple, Union
from errors.custom import InterpreterException, JavaSyntaxError, ScopeNotFoundException
@@ -122,6 +121,10 @@ class JavaInterpreter:
return 2
raise ScopeNotFoundException("Unable to find scope start. Is the program ill-formed?")
def _get_subscope(self, idx: int):
brace_offset = self._get_scope_start_offset(idx)
return self._get_instructions_in_scope(idx+brace_offset)
def _handle_while(self, line: str, idx: int):
bracket_idx = line.rindex(')') # throws if while contruct is illformed
@@ -129,10 +132,6 @@ class JavaInterpreter:
child_instructions, idx = self._get_subscope(idx)
return while_instruction_front(("while" + instruction_txt), child_instructions), idx
def _get_subscope(self, idx: int):
brace_offset = self._get_scope_start_offset(idx)
return self._get_instructions_in_scope(idx+brace_offset)
def _get_else_scope(self, idx:int):
instructions = None
if self._check_line_start(idx, "}else"):