User:Shazun bhasfu
Jump to navigation
Jump to search
shazun bhasfu user page
/ʃɑːˈzʊn ˈbʱɑːsfu/ Hello, I'm Shazun Bhasfu and welcome to my page, I guess, I'm esolang developer, currently there are two esolangs: somp tzlel and trifack
Since I will not use GitHub, if you want the source code for my esolangs, here it is:
somp
somp is a dual-stack esolang, currently the code is outdated but im filling with more bloat
import sys
import time
def readf(filename):
with open(filename, 'r') as f:
return f.read().replace('\\n', '\n')
if __name__ == '__main__':
buf = ""
file = None
if len(sys.argv) > 2:
if sys.argv[2] == '-ci':
buf = input('> ').replace('\\n', '\n')
file = sys.argv[1]
else:
file = sys.argv[1]
filep = readf(file)
nl = {}
il = {}
j = 0
while j < len(filep) - 1:
if filep[j].isalpha() and filep[j+1] == ':':
nl[filep[j]] = j + 2
elif filep[j] == ':':
il[j] = None
j += 1
pi = 0
bi = 0
stacks = [[], []]
cs = stacks[0]
t = 0
pin = []
while pi < len(filep):
if filep[pi] == ';':
if pin:
pi = pin.pop()
else:
break
elif filep[pi] == '^':
cs.append(0)
elif filep[pi].isdigit():
if cs:
cs.append(cs.pop() * 10 + int(filep[pi]))
else:
cs.append(int(filep[pi]))
elif filep[pi] == '+':
a = cs.pop() if cs else 0
b = cs.pop() if cs else 0
cs.append(a + b)
elif filep[pi] == '-':
cs.append(cs.pop() * -1)
elif filep[pi] == '|':
if cs:
cs.append(cs[-1])
elif filep[pi] == '%':
temp = cs.pop() if cs else 0
a, b = temp // 10, temp % 10
cs.append(a)
cs.append(b)
elif filep[pi] == '&':
cs[:] = cs[::-1]
elif filep[pi] == '?':
a = cs.pop()
if a >= 0:
cs.append(0)
else:
cs.append(1)
elif filep[pi] == '°':
if t == 0:
stacks[1].append(cs.pop() if cs else 0)
else:
stacks[0].append(cs.pop() if cs else 0)
elif filep[pi] == '!':
a = cs.pop()
if a != 0:
pi += 1
elif filep[pi] == ',':
if bi < len(buf):
cs.append(ord(buf[bi]))
bi += 1
else:
cs.append(ord(input()[0]))
elif filep[pi] == '.':
if cs:
print(chr(cs.pop()), end='')
elif filep[pi].isalpha():
if filep[pi] in nl:
pin.append(pi)
pi = nl[filep[pi]]
continue
elif filep[pi] == '/':
temp = pi
while temp >= 0:
if temp in il:
pi = temp
break
temp -= 1
elif filep[pi] == '@':
count = 0
while pi + count < len(filep) and filep[pi + count] == '@':
count += 1
for _ in range(count):
temp = pi + 1
while temp < len(filep):
if temp in il:
pi = temp
break
temp += 1
pi -= 1
elif filep[pi] == '$':
cs.pop()
elif filep[pi] == '"':
if t == 0:
cs = stacks[1]
t = 1
else:
cs = stacks[0]
t = 0
elif filep[pi] == '*':
if t == 0:
stacks[0], stacks[1] = stacks[1], stacks[0]
cs = stacks[0]
else:
stacks[0], stacks[1] = stacks[1], stacks[0]
cs = stacks[1]
elif filep[pi] == '~':
temp = cs[-2]
cs[-2] = cs[-1]
cs[-1] = temp
elif filep[pi] == '`':
a = str(cs.pop())
cs.append(len(a))
elif filep[pi] == '´':
a = cs.pop()
cs[-a:] = cs[-a:][::-1]
elif filep[pi] == '#':
cs.append(len(cs)-1)
elif filep[pi] == '=':
cs.append(len(str(cs[-1]))-1)
pi += 1
tzlel
currently the interpreter is not finished, but if you like to do anyways, here:
import sys
import time
def readf(file):
with open(file, 'r') as f:
return f.read()
if __name__ == '__main__':
df = readf(sys.argv[1])
pf = readf(sys.argv[2])
pi = 0
di = 0
df += '\n' if df[-1] != '\n' else ''
dl = 0
table = {}
while di < len(df):
ndi = df.index('\n', di)
line = df[di:ndi]
if line[0] == '#':
dl = int(line[1:])
elif line[0] == '/':
col = line.index(':')
if len(line[:col])-1 != dl:
sys.exit(1)
else:
table[line[1:col]] = line[col+1:]
di = ndi+1
di = -1
datas = []
while pi < len(pf):
op = table[pf[pi:pi+dl]]
if op == ';':
break
elif op == '0':
datas.insert(di, 0)
elif op[0] == '-':
datas[di] *= -1
elif op[0] == '+':
if op[1] == ',':
datas[di] += datas[-2]
else:
datas[di] += int(op[1:])
elif op[0] == 'o':
print(chr(datas[di]))
elif op[0] == 'O':
print(datas[di])
elif op[0] == '\'':
datas.pop(di)
elif op[0] == '_':
if op[1] == ',':
di += datas[-2]
else:
di += int(op[1:])
elif op[0] == 'I':
if op[1] == ',':
datas.insert(di, int(op[1:]))
else:
datas.insert(di, datas[di])
elif op[0] == 'i':
if op[1] == ',':
datas.insert(di, int(op[1:]))
else:
datas.insert(di, ord(datas[di]))
elif op == ':':
a = datas.pop(di)
pi += a if a%di else a+(a%di)
pi += dl
trifack
import sys
def readf(file):
with open(file, 'r') as f:
return f.read()
def run(file):
i = 0
n = len(file)
did = {'exit': False, 'do': False, 'enter': False}
while i < n:
# debug
print(did)
if file[i] == '{':
did['enter'] = True
did['exit'] = False
did['do'] = False
elif file[i] == '}':
did['enter'] = False
did['exit'] = True
did['do'] = False
elif file[i] == '?':
if i + 1 < n and file[i + 1] == '{' and did['enter']:
j = i
while j > 0 and file[j] != '}':
j -= 1
i = j
elif i + 1 < n and file[i + 1] == '}' and did['exit']:
j = i + 2
while j < n and file[j] != '{':
j += 1
i = j
elif i + 1 < n and file[i + 1] == '?' and not did['do']:
did['enter'] = True
did['exit'] = True
did['do'] = False
elif i + 1 < n and file[i + 1] == '?' and did['do']:
did['enter'] = False
did['exit'] = False
did['do'] = False
else:
did['do'] = True
i += 1
i += 1
if __name__ == '__main__':
file = readf(sys.argv[1])
run(file)