fixed tokenizer hanging on unknown instruction

float_support
Anton Lydike 4 years ago
parent a3ab418858
commit 91a12fd2a8

@ -63,7 +63,6 @@ See [docs/debugging.md](docs/debugging.md) for more info.
* RISC-V reference card: https://www.cl.cam.ac.uk/teaching/1617/ECAD+Arch/files/docs/RISCVGreenCardv8-20151013.pdf
## TODO:
* Prevent tokenizer infinite loop on unknown instructions
* Move cpu instructions to different file, allow for instruction set selection and composition
* Add a cycle limit to the options and CPU to catch infinite loops
* Move away from `print` and use `logging.logger` instead

@ -3,6 +3,7 @@ from enum import IntEnum
from typing import List
from .CPU import CPU, Registers
from .Exceptions import ParseException
REGISTERS = list(Registers.all_registers())
@ -130,7 +131,6 @@ class RiscVInput:
regex = re.compile(regex)
match = regex.match(self.content[at:])
if match is None:
print("Regex matched none at {}!".format(self.context()))
return None
if regex_group != 0 and not match.group(0).startswith(match.group(regex_group)):
@ -272,9 +272,7 @@ class RiscVTokenizer:
self.parse_instruction()
else:
token = self.input.peek(size=5)
print("Unknown token around {} at: {}".format(repr(token), repr(self.input.context())))
self.input.consume_whitespace()
print("After whitespace at: {}".format(repr(self.input.context())))
raise ParseException("Unknown token around {} at: {}".format(repr(token), repr(self.input.context())))
self.input.consume_whitespace()
def parse_pseudo_op(self):

Loading…
Cancel
Save