started implementing support for for loops
This commit is contained in:
@@ -161,4 +161,7 @@ class while_instruction_back(while_instruction_front):
|
|||||||
for inst in self.child_instructions:
|
for inst in self.child_instructions:
|
||||||
res += '\t' +str(inst) + ";\n"
|
res += '\t' +str(inst) + ";\n"
|
||||||
res += f"{'}'}while({self.instruction_text});"
|
res += f"{'}'}while({self.instruction_text});"
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
class for_instruction(while_instruction_front):
|
||||||
|
pass
|
||||||
@@ -166,6 +166,9 @@ class JavaInterpreter:
|
|||||||
|
|
||||||
return while_instruction_back(instruction_txt, child_instructions), idx
|
return while_instruction_back(instruction_txt, child_instructions), idx
|
||||||
|
|
||||||
|
def _handle_for(self, line: str, idx: int):
|
||||||
|
return generic_instruction(line), idx
|
||||||
|
|
||||||
def _handle_variable(self, line: str, idx: int):
|
def _handle_variable(self, line: str, idx: int):
|
||||||
groups = self._variable_pattern.match(line).groups()
|
groups = self._variable_pattern.match(line).groups()
|
||||||
var_type = groups[0]
|
var_type = groups[0]
|
||||||
@@ -188,6 +191,10 @@ class JavaInterpreter:
|
|||||||
logging.debug("Found do-while construct in line: %i", idx+1)
|
logging.debug("Found do-while construct in line: %i", idx+1)
|
||||||
return self._handle_do_while(line, idx)
|
return self._handle_do_while(line, idx)
|
||||||
|
|
||||||
|
elif line.startswith("for("):
|
||||||
|
logging.debug("Found for construct in line: %i", idx+1)
|
||||||
|
return self._handle_for(line, idx)
|
||||||
|
|
||||||
elif self._variable_pattern.match(line):
|
elif self._variable_pattern.match(line):
|
||||||
logging.debug("Found variable in line %i", idx+1)
|
logging.debug("Found variable in line %i", idx+1)
|
||||||
return self._handle_variable(line, idx)
|
return self._handle_variable(line, idx)
|
||||||
|
|||||||
Reference in New Issue
Block a user