Skip to content

Instantly share code, notes, and snippets.

@urbanangel
Last active February 9, 2020 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urbanangel/7cd8ed849e6faa4e53434b384c4a09a8 to your computer and use it in GitHub Desktop.
Save urbanangel/7cd8ed849e6faa4e53434b384c4a09a8 to your computer and use it in GitHub Desktop.
import sys
choice = input("Import or type? [import/[anything]]")
if choice == "import":
file = open(input("execute "))
code = file.read()
else:
code = input("")
var = {}
var[0] = 0
var[1] = 0
loc = 0
for i in range(len(code)):
if code[i] == "+":
var[0] += 1
elif code[i] == "-":
var[0] -= 1
elif code[i] == "*":
var[1] += 1
elif code[i] == "/":
var[1] -= 1
elif code[i] == ".":
if var[1] >= 1:
code = list(code)
code[var[1]-1] = str(chr(var[0]))
"".join(code)
else:
print(code[i] + " symbol at position " + str(i+1) + " is attempting to change a position less than 1.")
print(str("".join(code)))
sys.exit()
elif code[i] == ",":
if var[0] >= 1:
code = list(code)
code[var[0]-1] = str(chr(var[1]))
"".join(code)
else:
print(code[i] + " symbol at position " + str(i+1) + " is attempting to change a position less than 1.")
print(str("".join(code)))
sys.exit()
elif code[i] == ":":
var[0] = ord(input("> "))
elif code[i] == ";":
var[1] = ord(input("> "))
elif code[i] == "@":
loc = i+1
elif code[i] == "!":
string = ""
for j in range(loc-1):
string += code[j]
print(string)
else:
print("Syntax error! Unexpected symbol at position " + str(i+1) + ".")
print(code[i])
print(str("".join(code)))
sys.exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment