Better brainfuck compille
This commit is contained in:
@@ -24,14 +24,11 @@ class BrainFuckByteCodeCompiler:
|
||||
self.source_data: bytearray = data
|
||||
|
||||
def compile(self) -> bytearray:
|
||||
# whitespace_b = whitespace.encode()
|
||||
valid_b = set(ord(s) for s in BrainFuckByteCode.keys())
|
||||
self.source_data = bytearray(b for b in self.source_data if b in valid_b)
|
||||
|
||||
out = bytearray()
|
||||
for byte in self.source_data:
|
||||
out.append(BrainFuckByteCode[chr(byte)])
|
||||
return out
|
||||
return bytearray(
|
||||
BrainFuckByteCode[c]
|
||||
for byte in self.source_data
|
||||
if (c := chr(byte)) in BrainFuckByteCode
|
||||
)
|
||||
|
||||
|
||||
class BrainFuckEnterpreter(Enterpreter):
|
||||
|
||||
Reference in New Issue
Block a user