Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKilobyte authored Jun 2, 2023
1 parent 87dfb40 commit 4c71556
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
Binary file modified omicron.exe
Binary file not shown.
19 changes: 10 additions & 9 deletions omicron.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import sys, math
if len(sys.argv) > 1:
program = [c.strip() for c in open(sys.argv[1], 'r').read().split()]
try:
program = [c.strip() for c in open(sys.argv[1], 'r').read().split()]
except FileNotFoundError:
print("File not found: %s"%sys.argv[1])
sys.exit()
memory = {}
def error(m):
global ok
Expand All @@ -9,20 +13,18 @@ def error(m):
def number(n):
return float(n) if ('.' in str(n)) else int(n)
def mem(instruction):
for cell in memory: instruction = instruction.replace("@"+str(cell), str(memory[cell]))
while '@' in instruction:
for cell in memory: instruction = instruction.replace("@"+str(cell), str(memory[cell]))
return number(instruction)
ok = 1
pointer = 0
i = 0
markers = {}
for m in range(0, len(program)):
if program[m].startswith(":"): markers[int(program[m][1:])] = m
while True:
while i < len(program):
try:
try: instruction = program[i]
except IndexError:
error("Missing stop")
break
instruction = program[i]
# Pointer
if instruction == '>': pointer += 1
elif instruction == '<': pointer -= 1
Expand Down Expand Up @@ -151,5 +153,4 @@ def mem(instruction):
break
if not ok: input()
else:
print("Missing input file")
input()
print("Missing input file")

0 comments on commit 4c71556

Please sign in to comment.