Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import warnings
- from random import uniform
- import os,glob
- from math import fabs
- #*Seabass Penta Interpreter v 0.43*#
- if not sys.warnoptions:
- warnings.simplefilter("ignore")
- #CLASSES START
- class INDENTATION_ERR(Exception):
- pass
- class FUNCTION_ERR(Exception):
- pass
- class GOTOPOINT_ERR(Exception):
- pass
- #CLASSES END
- #FUNCTIONS START
- def errorprint(code,position):
- code=code[0:position]+"("+code[position]+")"+code[position+1:]
- code+=" "*5
- code = 5*" "+code
- text = code[position:position+13].replace(" ","")
- return("\nThe error had occurred at position "+str(position)+": "+text)
- def indreturn(code):
- starts=0
- for x in ["!","=","<","[","]","{",".","k"]:
- starts+=code.count(x)
- ends=code.count(">")
- return(starts-ends)
- def delcomment(text):#CHECK FOR CONSOLE ERR
- while text.count("/")!=0:
- counter = text.find("/")+1
- while counter!=len(text) and text[counter]!="/" and text[counter]!="\n":
- counter+=1
- text = text.replace(text[text.find("/"):counter+1],"", 1)
- return text
- def indcheck(code):
- code = delcomment(code)
- starts=0
- for x in ["!","=","<","[","]","{",".","k"]:
- starts+=code.count(x)
- ends=code.count(">")
- if starts!=ends:
- if starts>ends:
- raise INDENTATION_ERR("Missing '>' mark(s)")
- else:
- raise INDENTATION_ERR("Excessive '>' mark(s)")
- def finder(tup):
- code=tup[0]
- f=tup[1]
- dep=0
- if f=="NoneType": f=0
- while f!=len(code):
- if ["k","=","<","!","{","[","]",".",","].count(code[f])!=0: dep+=1#if ["k","=","<","!","{","[","]"].count(code[f])!=0: dep+=1
- elif code[f]==">": dep-=1
- if dep==0 and code[f]==">":
- return(f)
- f+=1
- def innerfun(code1,funst,a):
- mycode = source
- mycode = mycode.replace('code = str(input(">> "))',"code=code1",1)
- mycode = mycode.replace("funst=[]","funst="+str(funst),1)
- mycode = mycode.replace("ex"+"tst","innerextst")
- mycode = mycode.replace("ex1tst","extst")
- mycode = mycode.replace("a=[0.0]","a=["+str(a)+"]")
- mycode = "global extst\n"+mycode
- exec(mycode+"\ntempvar=a[an];global tempvar")
- def innerfun2(code1,funst,a):
- global source,declarations
- mycode = declarations+source
- mycode = mycode.replace("funst=[]","funst="+str(funst),1)
- mycode = mycode.replace("ex"+"tst","innerextst")
- mycode = mycode.replace("ex1tst","extst")
- mycode = mycode.replace("a=[0.0]","a=["+str(a)+"]")
- mycode = "global extst\n"+mycode
- exec("global tempvar;code=code1\n"+mycode+"\ntempvar=a[an]")
- def boolcust(inp):
- if inp<=0:
- return(False)
- else:
- return(True)
- def converter(b):
- if isinstance(b,str): return(float(ord(b[0])))
- elif isinstance(b,int): return(float(b))
- elif isinstance(b,float): return(float(b))
- elif isinstance(b,bool): return(float(int(b)))
- def inputype(c):
- try:
- c=float(c)
- except ValueError:
- c=str(c)
- c=float(ord(c[0]))
- return(c)
- def comment(d):
- while d.count("/")>1:
- d=d[:d.find("/")]+d[d.find("/",d.find("/")+1)+1:]
- if d.count("/")==1:
- d=d[0:d.find("/")]
- return(d)
- def filemaker(content,name):
- f = open(name,"w")
- f.write(content)
- f.close()
- def fileapp(content,name):
- f = open(name,"a")
- f.write(content)
- f.close()
- def filereader(name):
- f = open(name,"r")
- toreturn= f.read()
- f.close()
- return(toreturn)
- def findnumber(string,index):
- allnums=[]
- foc=0
- num=False
- while foc!=len(string):
- if not num and ["1","2","3","4","5","6","7","8","9",".","0","-"].count(string[foc])!=0:
- allnums.append(string[foc])
- num=True
- elif num and ["1","2","3","4","5","6","7","8","9",".","0"].count(string[foc])!=0:
- allnums[-1]+=string[foc]
- else:
- if len(allnums)!=0:
- if allnums[-1][-1]=="-":
- allnums.pop()
- num=False
- if len(allnums)!=0:
- if allnums[-1][-1]=="-":
- allnums.pop()
- foc+=1
- return(allnums[int(index)])
- def countnums(text):
- out=0
- chars=["k","=","<","!","{","[","]","."]
- for f in range(len(chars)): out+=text.count(chars[f])
- out-=text.count(">")
- return(out)
- def findnew(code, f):
- code+="~"
- balance=0
- while f!=len(code):
- if ["k","=","<","!","{","[","]","."].count(code[f])!=0:
- balance+=1
- elif code[f]==">":
- balance-=1
- if balance==0 and code[f+1]!="," and code[f+1]!="." and code[f]!="," and code[f]!=".":
- return(f)
- f+=1
- def findnew2(code,f):
- balance=0
- while f!=len(code):
- if ["k","=","<","!","{","[","]","."].count(code[f])!=0:
- balance+=1
- elif code[f]==">":
- balance-=1
- if balance==0:
- return(f)
- f+=1
- def ifchecker(code,f):
- coderev=code[::-1]
- frev=len(code)-f-1
- for m in ["=","<","!","{","[","]","."]:
- if coderev.find("k",frev)==-1:
- return(True)
- if coderev.find(m,frev)<coderev.find("k",frev) and coderev.find(m,frev)!=-1:
- return(True)
- return(False)
- #FUNCTIONS END
- #DECLARATIONS START
- declarations ="""a=[0.0]
- d=[0.0]
- an=0
- dn=0
- extst=[]
- funst=[]
- gotost=[]
- gotopst=[]
- f=0
- globool=False
- ifcount=[]
- gotonum = 0
- ifmode = []
- endbool=False\n"""
- #DECLARATIONS END
- #SOURCE START
- source = r'''global outbool
- codest=[]
- while f!=len(code):
- if code[f]=="@":
- break
- elif code[f]=="i":
- a[an]+=1
- elif code[f]=="I":
- a[an]+=d[dn]
- elif code[f]=="o":
- print(a[an])
- outbool = False
- elif code[f]=="O":
- if a[an]<0:
- if fabs(a[an])<len(extst):
- print(extst[int(fabs(a[an]))])
- if str(extst[int(fabs(a[an]))])[-1]=="\n":
- outbool=False
- else:
- outbool=True
- else:
- print("0",end="")
- outbool=True
- elif a[an]<len(extst):
- print(extst[int(a[an])],end="")
- if str(extst[int(fabs(a[an]))])[-1]=="\n":
- outbool=False
- else:
- outbool=True
- else:
- print("0",end="")
- outbool=True
- elif code[f]=="d":
- a[an]-=1
- elif code[f]=="D":
- a[an]-=d[dn]
- elif code[f]=="s":
- a[an]*=a[an]
- elif code[f]=="S":
- a[an] = a[an]**d[dn]
- elif code[f]=="g":
- a[an]=-a[an]
- elif code[f]=="G":
- d[dn]=-d[dn]
- elif code[f]=="?":
- a[an]=float(uniform(a[an], d[dn]))
- elif code[f]=="v":
- a[an]=a[an]/d[dn]
- elif code[f]=="V":
- a[an]=d[dn]/a[an]
- elif code[f]=="r":
- a[an]=a[an]**0.5
- elif code[f]=="R":
- a[an] = a[an]**(1/d[dn])
- elif code[f]=="m":
- a[an]=a[an]*d[dn]
- elif code[f]=="M":
- a[an]=float(a[an]%d[dn])
- elif code[f]=="%":
- a[an]=float(a[an]//d[dn])
- elif code[f]=="c":
- a[an]=d[dn]
- elif code[f]=="C":
- d[dn]=a[an]
- elif code[f]=="p":
- if a[an]<0: a[an]=-a[an]
- else: pass
- elif code[f]=="P":
- if d[dn]<0: d[dn]=-d[dn]
- else: pass
- elif code[f]=="k":
- if funst.count(int(a[an]))!=0: funst.pop(funst.index(int(a[an]))+1);funst.pop(funst.index(int(a[an])))
- funst.append(int(a[an]));funst.append(code[f+1:finder([code,f])])
- f = finder([code,f])
- ifmode.append(f)
- elif code[f]=="a":
- if an+1==len(a):
- a.append(0.0)
- an+=1
- elif code[f]=="A":
- an+=int(d[dn])
- if an+d[dn]>=len(a):
- exec("a.append(0.0);"*(an-len(a)+1))
- elif code[f]=="b":
- dn+=1
- if len(d)==dn:
- d.append(0.0)
- elif code[f]=="B":
- dn+=int(a[an])
- if len(d)<=dn:
- exec("d.append(0.0);"*(dn-len(d)+1))
- elif code[f]=="x" or code[f]=="X":
- temp = a[an];a[an]=d[dn];d[dn]=temp;del temp
- elif code[f]=="z":
- an=0
- elif code[f]=="Z":
- dn=0
- elif code[f]=="h":
- codest.append(code);codest.append(f+1)
- f=-1
- if not globool:
- code = extst[int(a[an])];indcheck(code)
- else:
- code = ex1tst[int(a[an])];indcheck(code)
- elif code[f]=="H":
- try: innerfun2(funst[funst.index(int(a[an]))+1],funst,d[dn])
- except ValueError: raise FUNCTION_ERR("No such function "+'"'+str(int(a[an]))+'". '+errorprint(code,f))
- d[dn]=tempvar
- elif code[f]=="K":
- globool = not globool
- elif code[f]=="n":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=int(int(a[an]))
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=int(int(a[an]))
- elif code[f]=="N":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=int(int(d[dn]))
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=int(int(d[dn]))
- elif code[f]=="f":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=a[an]
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=a[an]
- elif code[f]=="F":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=d[dn]
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=d[dn]
- elif code[f]=="t":
- if not globool:
- if len(extst)<=fabs(int(d[dn])):
- exec("extst.append(0);"*int(fabs(int(d[dn]))-len(extst)+1))
- if d[dn]>=0: extst[int(d[dn])]=chr(int(a[an]))
- else: extst[-int(d[dn])]=str(int(a[an]))
- else:
- if len(ex1tst)<=int(fabs(d[dn])):
- exec("ex1tst.append(0);"*int(fabs(int(d[dn]))-len(ex1tst)+1))
- if d[dn]>=0: ex1tst[int(d[dn])]=chr(int(a[an]))
- else: ex1tst[-int(d[dn])]=str(int(a[an]))
- elif code[f]=="T":
- if not globool:
- if len(extst)<=int(fabs(d[dn])):
- exec("extst.append(0);"*int(int(fabs(d[dn]))-len(extst)+1))
- if d[dn]>=0:
- if extst[int(d[dn])]!=0: extst[int(d[dn])]+=chr(int(a[an]))
- else: extst[int(d[dn])]=chr(int(a[an]))
- else:
- extst[-int(d[dn])] = a[an]
- else:
- if len(ex1tst)<=int(fabs(d[dn])):
- exec("ex1tst.append(0);"*int(fabs(int(d[dn]))-len(ex1tst)+1))
- if d[dn]>=0:
- if ex1tst[int(d[dn])]!=0: ex1tst[int(d[dn])]+=chr(int(a[an]))
- else: ex1tst[int(d[dn])]=chr(int(a[an]))
- else:
- ex1tst[-int(d[dn])] = a[an]
- elif code[f]=="e":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=boolcust(a[an])
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=boolcust(a[an])
- elif code[f]=="E":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=boolcust(d[dn])
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=boolcust(d[dn])
- elif code[f]=="q":
- a[an]=inputype(input("?> "))
- elif code[f]=="Q":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- try: extst[int(a[an])]=str(input(extst[int(d[dn])]))
- except TypeError: extst[int(a[an])]=str(input())
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- try: ex1tst[int(a[an])]=str(input(ex1tst[int(d[dn])]))
- except TypeError: ex1tst[int(a[an])]=str(input())
- elif code[f]=="l":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- a[an]=converter(extst[int(d[dn])])
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- an[an]=converter(ex1tst[int(d[dn])])
- elif code[f]=="w":
- if not globool:
- if a[an]>=0:
- filemaker(extst[int(a[an])],extst[int(d[dn])])
- else:
- filemaker(chr(int(a[an])),extst[int(d[dn])])
- else:
- if a[an]>=0:
- filemaker(ex1tst[int(a[an])],ex1tst[int(d[dn])])
- else:
- filemaker(chr(int(a[an])),ex1tst[int(d[dn])])
- elif code[f]=="W":
- if not globool:
- if a[an]>=0:
- fileapp(extst[int(a[an])],extst[int(d[dn])])
- else:
- fileapp(chr(int(a[an])),extst[int(d[dn])])
- else:
- if a[an]>=0:
- fileapp(ex1tst[int(a[an])],ex1tst[int(d[dn])])
- else:
- fileapp(chr(int(a[an])),ex1tst[int(d[dn])])
- elif code[f]=="y":
- if not globool:
- extst[int(a[an])]=filereader(extst[int(d[dn])])
- else:
- ex1tst[int(a[an])]=filereader(ex1tst[int(d[dn])])
- elif code[f]=="Y":
- if not globool:
- extst[int(a[an])]+=filereader(extst[int(d[dn])])
- else:
- ex1tst[int(a[an])]+=filereader(ex1tst[int(d[dn])])
- elif code[f]=="#" or code[f]=="L":
- if not globool:
- try: a[an]=float(ord(extst[int(a[an])][int(d[dn])]))
- except IndexError: a[an]=-1.0
- else:
- try: a[an]=float(ord(ex1tst[int(a[an])][int(d[dn])]))
- except IndexError: a[an]=-1.0
- elif code[f]=="№" or code[f]=="$":
- if not globool: a[an]=float(findnumber(extst[int(a[an])],d[dn]))
- else: a[an]=float(findnumber(ex1tst[int(a[an])],d[dn]))
- elif code[f]=="=":
- if a[an]==d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="<":
- if a[an]<d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="!":
- if a[an]!=d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="{":
- if a[an]<=d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="[":
- if not globool:
- if extst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- else:
- if ex1tst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="]":
- if not globool:
- if not extst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- else:
- if not ex1tst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]==".":
- ifcount.append(findnew(code,f))
- elif code[f]==">":
- if len(ifcount)!=0:
- if ifchecker(code,f): f = ifcount.pop()
- elif code[f]==":":
- if gotopst.count(int(a[an]))!=0: f+=1;continue
- if gotost.count(int(a[an]))!=0: gotost.pop(gotost.index(int(a[an]))+1);gotost.pop(gotost.index(int(a[an])))
- gotost.append(int(a[an]))
- gotost.append(str(f))
- elif code[f]==";":
- if gotopst.count(int(a[an]))!=0 or gotopst.count(int(f))!=0 or gotost.count(int(a[an]))!=0:
- pass
- else:
- gotopst.append(int(a[an]))
- gotopst.append(str(f))
- elif code[f]=="j":
- if gotost.count(int(a[an]))!=0:
- exec('ifcount.pop();'*countnums(code[int(gotost[gotost.index(int(a[an]))+1])+1:f]))
- f = int(gotost[gotost.index(int(a[an]))+1])
- else:
- try: f = exec('ifcount.pop();'*countnums(code[int(gotopst[gotopst.index(int(a[an]))+1])+1:f]))
- except ValueError: raise GOTOPOINT_ERR("No such goto point "+'"'+str(int(a[an]))+'". '+errorprint(code,f))
- f = int(gotopst[gotopst.index(int(a[an]))+1])
- elif code[f]=="J":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- if a[an]>=0:
- if gotost.count(a[an])<1:
- extst[int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1]):]
- else:
- extst[int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1]):]
- else:
- if gotost.count(a[an])<1:
- extst[-int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1])+1:]
- else:
- extst[-int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1])+1:]
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- if a[an]>=0:
- if gotost.count(a[an])<1:
- extst[int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1]):]
- else:
- ex1tst[int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1]):]
- else:
- if gotost.count(a[an])<1:
- ex1tst[-int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1])+1:]
- else:
- ex1tst[-int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1])+1:]
- elif code[f]=="/":####COMMENT
- if code.find("/",f+1)==-1:
- if code.find("\n",f+1)==-1: f = len(code)-1
- else: f = f = code.find("\n",f+1)
- elif code.find("\n",f+1)!=-1 and code.find("/",f+1)>code.find("\n",f+1):
- f = code.find("\n",f+1)
- else:
- f = code.find("/",f+1)
- f+=1
- if f==len(code) and len(codest)!=0:
- f = codest.pop()
- code = codest.pop()'''
- #SOURCE END
- print("Welcome to Seabas Penta Interpreter v0.32")
- while 1:
- print("Select option:\n[0] - quit\n[1] - go to Seabass console\n[2] - open a .dfs file")
- option = int(input("Option : "))
- if option==0:
- import sys;sys.exit()
- elif option==1:
- a=[0.0]
- d=[0.0]
- an=0
- dn=0
- extst=[]
- funst=[]
- gotost=[]
- gotopst=[]
- f=0
- globool=False
- tempvar=None
- ifcount=[]
- gotonum = 0
- ifmode = []
- endbool=False
- code=""
- outbool=False
- contbool=False
- codest=[]
- print("═"*29+"╕")#WORKTAG
- while not endbool:
- if not contbool:
- input1 = str(input(">> "))
- else:
- input1 = str(input(".. "))
- if len(input1)!=0 and input1[-1]==" " or indreturn(delcomment(code+input1))>0:#LATEST CHANGE
- code+=input1+"\n"
- contbool=True
- else:
- contbool=False
- code+=input1
- indcheck(code)
- while f!=len(code):
- if code[f]=="@":
- endbool=True
- break
- elif code[f]=="i":
- a[an]+=1
- elif code[f]=="I":
- a[an]+=d[dn]
- elif code[f]=="o":
- print(a[an])
- outbool = False
- elif code[f]=="O":
- if a[an]<0:
- if fabs(a[an])<len(extst):
- print(extst[int(fabs(a[an]))])
- if str(extst[int(fabs(a[an]))])[-1]=="\n":
- outbool=False
- else:
- outbool=True
- else:
- print("0",end="")
- outbool=True
- elif a[an]<len(extst):
- print(extst[int(a[an])],end="")
- if str(extst[int(fabs(a[an]))])[-1]=="\n":
- outbool=False
- else:
- outbool=True
- else:
- print("0",end="")
- outbool=True
- elif code[f]=="d":
- a[an]-=1
- elif code[f]=="D":
- a[an]-=d[dn]
- elif code[f]=="s":
- a[an]*=a[an]
- elif code[f]=="S":
- a[an] = a[an]**d[dn]
- elif code[f]=="g":
- a[an]=-a[an]
- elif code[f]=="G":
- d[dn]=-d[dn]
- elif code[f]=="?":
- a[an]=float(uniform(a[an], d[dn]))
- elif code[f]=="v":
- a[an]=a[an]/d[dn]
- elif code[f]=="V":
- a[an]=d[dn]/a[an]
- elif code[f]=="r":
- a[an]=a[an]**0.5
- elif code[f]=="R":
- a[an] = a[an]**(1/d[dn])
- elif code[f]=="m":
- a[an]=a[an]*d[dn]
- elif code[f]=="M":
- a[an]=float(a[an]%d[dn])
- elif code[f]=="%":
- a[an]=float(a[an]//d[dn])
- elif code[f]=="c":
- a[an]=d[dn]
- elif code[f]=="C":
- d[dn]=a[an]
- elif code[f]=="p":
- if a[an]<0: a[an]=-a[an]
- else: pass
- elif code[f]=="P":
- if d[dn]<0: d[dn]=-d[dn]
- else: pass
- elif code[f]=="k":
- if funst.count(int(a[an]))!=0: funst.pop(funst.index(int(a[an]))+1);funst.pop(funst.index(int(a[an])))
- funst.append(int(a[an]));funst.append(code[f+1:finder([code,f])])
- f = finder([code,f])
- ifmode.append(f)
- elif code[f]=="a":
- if an+1==len(a):
- a.append(0.0)
- an+=1
- elif code[f]=="A":
- an+=int(d[dn])
- if an+d[dn]>=len(a):
- exec("a.append(0.0);"*(an-len(a)+1))
- elif code[f]=="b":
- dn+=1
- if len(d)==dn:
- d.append(0.0)
- elif code[f]=="B":
- dn+=int(a[an])
- if len(d)<=dn:
- exec("d.append(0.0);"*(dn-len(d)+1))
- elif code[f]=="x" or code[f]=="X":
- temp = a[an];a[an]=d[dn];d[dn]=temp;del temp
- elif code[f]=="z":
- an=0
- elif code[f]=="Z":
- dn=0
- elif code[f]=="h":
- codest.append(code);codest.append(f+1)
- f=-1
- if not globool:
- code = extst[int(a[an])];indcheck(code)
- else:
- code = ex1tst[int(a[an])];indcheck(code)
- elif code[f]=="H":
- try: innerfun2(funst[funst.index(int(a[an]))+1],funst,d[dn])
- except ValueError: raise FUNCTION_ERR("No such function "+'"'+str(int(a[an]))+'". '+errorprint(code,f))
- d[dn]=tempvar
- elif code[f]=="K":
- globool = not globool
- elif code[f]=="n":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=int(int(a[an]))
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=int(int(a[an]))
- elif code[f]=="N":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=int(int(d[dn]))
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=int(int(d[dn]))
- elif code[f]=="f":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=a[an]
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=a[an]
- elif code[f]=="F":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=d[dn]
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=d[dn]
- elif code[f]=="t":
- if not globool:
- if len(extst)<=fabs(int(d[dn])):
- exec("extst.append(0);"*int(fabs(int(d[dn]))-len(extst)+1))
- if d[dn]>=0: extst[int(d[dn])]=chr(int(a[an]))
- else: extst[-int(d[dn])]=str(int(a[an]))
- else:
- if len(ex1tst)<=int(fabs(d[dn])):
- exec("ex1tst.append(0);"*int(fabs(int(d[dn]))-len(ex1tst)+1))
- if d[dn]>=0: ex1tst[int(d[dn])]=chr(int(a[an]))
- else: ex1tst[-int(d[dn])]=str(int(a[an]))
- elif code[f]=="T":
- if not globool:
- if len(extst)<=int(fabs(d[dn])):
- exec("extst.append(0);"*int(int(fabs(d[dn]))-len(extst)+1))
- if d[dn]>=0:
- if extst[int(d[dn])]!=0: extst[int(d[dn])]+=chr(int(a[an]))
- else: extst[int(d[dn])]=chr(int(a[an]))
- else:
- extst[-int(d[dn])] = a[an]
- else:
- if len(ex1tst)<=int(fabs(d[dn])):
- exec("ex1tst.append(0);"*int(fabs(int(d[dn]))-len(ex1tst)+1))
- if d[dn]>=0:
- if ex1tst[int(d[dn])]!=0: ex1tst[int(d[dn])]+=chr(int(a[an]))
- else: ex1tst[int(d[dn])]=chr(int(a[an]))
- else:
- ex1tst[-int(d[dn])] = a[an]
- elif code[f]=="e":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=boolcust(a[an])
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=boolcust(a[an])
- elif code[f]=="E":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=boolcust(d[dn])
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=boolcust(d[dn])
- elif code[f]=="q":
- a[an]=inputype(input("?> "))
- elif code[f]=="Q":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- try: extst[int(a[an])]=str(input(extst[int(d[dn])]))
- except TypeError: extst[int(a[an])]=str(input())
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- try: ex1tst[int(a[an])]=str(input(ex1tst[int(d[dn])]))
- except TypeError: ex1tst[int(a[an])]=str(input())
- elif code[f]=="l":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- a[an]=converter(extst[int(d[dn])])
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- an[an]=converter(ex1tst[int(d[dn])])
- elif code[f]=="w":
- if not globool:
- if a[an]>=0:
- filemaker(extst[int(a[an])],extst[int(d[dn])])
- else:
- filemaker(chr(int(a[an])),extst[int(d[dn])])
- else:
- if a[an]>=0:
- filemaker(ex1tst[int(a[an])],ex1tst[int(d[dn])])
- else:
- filemaker(chr(int(a[an])),ex1tst[int(d[dn])])
- elif code[f]=="W":
- if not globool:
- if a[an]>=0:
- fileapp(extst[int(a[an])],extst[int(d[dn])])
- else:
- fileapp(chr(int(a[an])),extst[int(d[dn])])
- else:
- if a[an]>=0:
- fileapp(ex1tst[int(a[an])],ex1tst[int(d[dn])])
- else:
- fileapp(chr(int(a[an])),ex1tst[int(d[dn])])
- elif code[f]=="y":
- if not globool:
- extst[int(a[an])]=filereader(extst[int(d[dn])])
- else:
- ex1tst[int(a[an])]=filereader(ex1tst[int(d[dn])])
- elif code[f]=="Y":
- if not globool:
- extst[int(a[an])]+=filereader(extst[int(d[dn])])
- else:
- ex1tst[int(a[an])]+=filereader(ex1tst[int(d[dn])])
- elif code[f]=="#" or code[f]=="L":
- if not globool:
- try: a[an]=float(ord(extst[int(a[an])][int(d[dn])]))
- except IndexError: a[an]=-1.0
- else:
- try: a[an]=float(ord(ex1tst[int(a[an])][int(d[dn])]))
- except IndexError: a[an]=-1.0
- elif code[f]=="№" or code[f]=="$":
- if not globool: a[an]=float(findnumber(extst[int(a[an])],d[dn]))
- else: a[an]=float(findnumber(ex1tst[int(a[an])],d[dn]))
- elif code[f]=="=":
- if a[an]==d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="<":
- if a[an]<d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="!":
- if a[an]!=d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="{":
- if a[an]<=d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="[":
- if not globool:
- if extst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- else:
- if ex1tst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="]":
- if not globool:
- if not extst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- else:
- if not ex1tst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]==".":
- ifcount.append(findnew(code,f))
- elif code[f]==">":
- if len(ifcount)!=0:
- if ifchecker(code,f): f = ifcount.pop()
- elif code[f]==":":
- if gotopst.count(int(a[an]))!=0: f+=1;continue
- if gotost.count(int(a[an]))!=0: gotost.pop(gotost.index(int(a[an]))+1);gotost.pop(gotost.index(int(a[an])))
- gotost.append(int(a[an]))
- gotost.append(str(f))
- elif code[f]==";":
- if gotopst.count(int(a[an]))!=0 or gotopst.count(int(f))!=0 or gotost.count(int(a[an]))!=0:
- pass
- else:
- gotopst.append(int(a[an]))
- gotopst.append(str(f))
- elif code[f]=="j":
- if gotost.count(int(a[an]))!=0:
- exec('ifcount.pop();'*countnums(code[int(gotost[gotost.index(int(a[an]))+1])+1:f]))
- f = int(gotost[gotost.index(int(a[an]))+1])
- else:
- try: f = exec('ifcount.pop();'*countnums(code[int(gotopst[gotopst.index(int(a[an]))+1])+1:f]))
- except ValueError: raise GOTOPOINT_ERR("No such goto point "+'"'+str(int(a[an]))+'". '+errorprint(code,f))
- f = int(gotopst[gotopst.index(int(a[an]))+1])
- elif code[f]=="J":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- if a[an]>=0:
- if gotost.count(a[an])<1:
- extst[int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1]):]
- else:
- extst[int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1]):]
- else:
- if gotost.count(a[an])<1:
- extst[-int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1])+1:]
- else:
- extst[-int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1])+1:]
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- if a[an]>=0:
- if gotost.count(a[an])<1:
- extst[int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1]):]
- else:
- ex1tst[int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1]):]
- else:
- if gotost.count(a[an])<1:
- ex1tst[-int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1])+1:]
- else:
- ex1tst[-int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1])+1:]
- elif code[f]=="/":####COMMENT
- if code.find("/",f+1)==-1:
- if code.find("\n",f+1)==-1: f = len(code)-1
- else: f = f = code.find("\n",f+1)
- elif code.find("\n",f+1)!=-1 and code.find("/",f+1)>code.find("\n",f+1):
- f = code.find("\n",f+1)
- else:
- f = code.find("/",f+1)
- f+=1
- if f==len(code) and len(codest)!=0:
- f = codest.pop()
- code = codest.pop()
- if outbool: print("",end=None);outbool=False
- f=0
- code=""
- print("═"*29+"╛")#WORKTAG
- else:
- ####FILEWORKS
- curdir = os.path.dirname(os.path.realpath(__file__))
- os.chdir(curdir)
- filelist = []
- print("Select file for interpretation:")
- for file in glob.glob('*.dfs'):
- filelist.append(file)
- if len(filelist)==0:
- print("Error: no files found")
- sys.exit()
- for file in range(len(filelist)):
- print("["+str(file)+"] - "+filelist[file])
- number = int(input("Option : "))
- code = open(os.path.join(curdir,filelist[number])).read()
- ####FILEWORKS
- indcheck(code)
- a=[0.0]
- d=[0.0]
- an=0
- dn=0
- extst=[]
- funst=[]
- gotost=[]
- gotopst=[]
- f=0
- globool=False
- tempvar=None
- ifcount=[]
- gotonum = 0
- ifmode = []
- endbool=False
- outbool=False
- codest=[]
- print("═"*29+"╕")#WORKTAG
- while f!=len(code):
- if code[f]=="@":
- break
- elif code[f]=="i":
- a[an]+=1
- elif code[f]=="I":
- a[an]+=d[dn]
- elif code[f]=="o":
- print(a[an])
- elif code[f]=="O":
- if a[an]<0:
- if fabs(a[an])<len(extst):
- print(extst[int(fabs(a[an]))])
- if str(extst[int(fabs(a[an]))])[-1]=="\n":
- outbool=False
- else:
- outbool=True
- else:
- print("0",end="")
- outbool=True
- elif a[an]<len(extst):
- print(extst[int(a[an])],end="")
- if str(extst[int(fabs(a[an]))])[-1]=="\n":
- outbool=False
- else:
- outbool=True
- else:
- print("0",end="")
- outbool=True
- elif code[f]=="d":
- a[an]-=1
- elif code[f]=="D":
- a[an]-=d[dn]
- elif code[f]=="s":
- a[an]*=a[an]
- elif code[f]=="S":
- a[an] = a[an]**d[dn]
- elif code[f]=="g":
- a[an]=-a[an]
- elif code[f]=="G":
- d[dn]=-d[dn]
- elif code[f]=="?":
- a[an]=float(uniform(a[an], d[dn]))
- elif code[f]=="v":
- a[an]=a[an]/d[dn]
- elif code[f]=="V":
- a[an]=d[dn]/a[an]
- elif code[f]=="r":
- a[an]=a[an]**0.5
- elif code[f]=="R":
- a[an] = a[an]**(1/d[dn])
- elif code[f]=="m":
- a[an]=a[an]*d[dn]
- elif code[f]=="M":
- a[an]=float(a[an]%d[dn])
- elif code[f]=="%":
- a[an]=float(a[an]//d[dn])
- elif code[f]=="c":
- a[an]=d[dn]
- elif code[f]=="C":
- d[dn]=a[an]
- elif code[f]=="p":
- if a[an]<0: a[an]=-a[an]
- else: pass
- elif code[f]=="P":
- if d[dn]<0: d[dn]=-d[dn]
- else: pass
- elif code[f]=="k":
- if funst.count(int(a[an]))!=0: funst.pop(funst.index(int(a[an]))+1);funst.pop(funst.index(int(a[an])))
- funst.append(int(a[an]));funst.append(code[f+1:finder([code,f])])
- f = finder([code,f])
- ifmode.append(f)
- elif code[f]=="a":
- if an+1==len(a):
- a.append(0.0)
- an+=1
- elif code[f]=="A":
- an+=int(d[dn])
- if an+d[dn]>=len(a):
- exec("a.append(0.0);"*(an-len(a)+1))
- elif code[f]=="b":
- dn+=1
- if len(d)==dn:
- d.append(0.0)
- elif code[f]=="B":
- dn+=int(a[an])
- if len(d)<=dn:
- exec("d.append(0.0);"*(dn-len(d)+1))
- elif code[f]=="x" or code[f]=="X":
- temp = a[an];a[an]=d[dn];d[dn]=temp;del temp
- elif code[f]=="z":
- an=0
- elif code[f]=="Z":
- dn=0
- elif code[f]=="h":
- codest.append(code);codest.append(f+1)
- f=-1
- if not globool:
- code = extst[int(a[an])];indcheck(code)
- else:
- code = ex1tst[int(a[an])];indcheck(code)
- elif code[f]=="H":
- try: innerfun2(funst[funst.index(int(a[an]))+1],funst,d[dn])
- except ValueError: raise FUNCTION_ERR("No such function "+'"'+str(int(a[an]))+'". '+errorprint(code,f))
- d[dn]=tempvar
- elif code[f]=="K":
- globool = not globool
- elif code[f]=="n":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=int(int(a[an]))
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=int(int(a[an]))
- elif code[f]=="N":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=int(int(d[dn]))
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=int(int(d[dn]))
- elif code[f]=="f":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=a[an]
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=a[an]
- elif code[f]=="F":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=d[dn]
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=d[dn]
- elif code[f]=="t":
- if not globool:
- if len(extst)<=fabs(int(d[dn])):
- exec("extst.append(0);"*int(fabs(int(d[dn]))-len(extst)+1))
- if d[dn]>=0: extst[int(d[dn])]=chr(int(a[an]))
- else: extst[-int(d[dn])]=str(int(a[an]))
- else:
- if len(ex1tst)<=int(fabs(d[dn])):
- exec("ex1tst.append(0);"*int(fabs(int(d[dn]))-len(ex1tst)+1))
- if d[dn]>=0: ex1tst[int(d[dn])]=chr(int(a[an]))
- else: ex1tst[-int(d[dn])]=str(int(a[an]))
- elif code[f]=="T":
- if not globool:
- if len(extst)<=int(fabs(d[dn])):
- exec("extst.append(0);"*int(int(fabs(d[dn]))-len(extst)+1))
- if d[dn]>=0:
- if extst[int(d[dn])]!=0: extst[int(d[dn])]+=chr(int(a[an]))
- else: extst[int(d[dn])]=chr(int(a[an]))
- else:
- extst[-int(d[dn])] = a[an]
- else:
- if len(ex1tst)<=int(fabs(d[dn])):
- exec("ex1tst.append(0);"*int(fabs(int(d[dn]))-len(ex1tst)+1))
- if d[dn]>=0:
- if ex1tst[int(d[dn])]!=0: ex1tst[int(d[dn])]+=chr(int(a[an]))
- else: ex1tst[int(d[dn])]=chr(int(a[an]))
- else:
- ex1tst[-int(d[dn])] = a[an]
- elif code[f]=="e":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=boolcust(a[an])
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=boolcust(a[an])
- elif code[f]=="E":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=boolcust(d[dn])
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=boolcust(d[dn])
- elif code[f]=="q":
- a[an]=inputype(input("?> "))
- elif code[f]=="Q":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- try: extst[int(a[an])]=str(input(extst[int(d[dn])]))
- except TypeError: extst[int(a[an])]=str(input())
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- try: ex1tst[int(a[an])]=str(input(ex1tst[int(d[dn])]))
- except TypeError: ex1tst[int(a[an])]=str(input())
- elif code[f]=="l":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- a[an]=converter(extst[int(d[dn])])
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- an[an]=converter(ex1tst[int(d[dn])])
- elif code[f]=="w":
- if not globool:
- if a[an]>=0:
- filemaker(extst[int(a[an])],extst[int(d[dn])])
- else:
- filemaker(chr(int(a[an])),extst[int(d[dn])])
- else:
- if a[an]>=0:
- filemaker(ex1tst[int(a[an])],ex1tst[int(d[dn])])
- else:
- filemaker(chr(int(a[an])),ex1tst[int(d[dn])])
- elif code[f]=="W":
- if not globool:
- if a[an]>=0:
- fileapp(extst[int(a[an])],extst[int(d[dn])])
- else:
- fileapp(chr(int(a[an])),extst[int(d[dn])])
- else:
- if a[an]>=0:
- fileapp(ex1tst[int(a[an])],ex1tst[int(d[dn])])
- else:
- fileapp(chr(int(a[an])),ex1tst[int(d[dn])])
- elif code[f]=="y":
- if not globool:
- extst[int(a[an])]=filereader(extst[int(d[dn])])
- else:
- ex1tst[int(a[an])]=filereader(ex1tst[int(d[dn])])
- elif code[f]=="Y":
- if not globool:
- extst[int(a[an])]+=filereader(extst[int(d[dn])])
- else:
- ex1tst[int(a[an])]+=filereader(ex1tst[int(d[dn])])
- elif code[f]=="#" or code[f]=="L":
- if not globool:
- try: a[an]=float(ord(extst[int(a[an])][int(d[dn])]))
- except IndexError: a[an]=-1.0
- else:
- try: a[an]=float(ord(ex1tst[int(a[an])][int(d[dn])]))
- except IndexError: a[an]=-1.0
- elif code[f]=="№" or code[f]=="$":
- if not globool: a[an]=float(findnumber(extst[int(a[an])],d[dn]))
- else: a[an]=float(findnumber(ex1tst[int(a[an])],d[dn]))
- elif code[f]=="=":
- if a[an]==d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="<":
- if a[an]<d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="!":
- if a[an]!=d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="{":
- if a[an]<=d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="[":
- if not globool:
- if extst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- else:
- if ex1tst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="]":
- if not globool:
- if not extst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- else:
- if not ex1tst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]==".":
- ifcount.append(findnew(code,f))
- elif code[f]==">":
- if len(ifcount)!=0:
- if ifchecker(code,f): f = ifcount.pop()
- elif code[f]==":":
- if gotopst.count(int(a[an]))!=0: f+=1;continue
- if gotost.count(int(a[an]))!=0: gotost.pop(gotost.index(int(a[an]))+1);gotost.pop(gotost.index(int(a[an])))
- gotost.append(int(a[an]))
- gotost.append(str(f))
- elif code[f]==";":
- if gotopst.count(int(a[an]))!=0 or gotopst.count(int(f))!=0 or gotost.count(int(a[an]))!=0:
- pass
- else:
- gotopst.append(int(a[an]))
- gotopst.append(str(f))
- elif code[f]=="j":
- if gotost.count(int(a[an]))!=0:
- exec('ifcount.pop();'*countnums(code[int(gotost[gotost.index(int(a[an]))+1])+1:f]))
- f = int(gotost[gotost.index(int(a[an]))+1])
- else:
- try: f = exec('ifcount.pop();'*countnums(code[int(gotopst[gotopst.index(int(a[an]))+1])+1:f]))
- except ValueError: raise GOTOPOINT_ERR("No such goto point "+'"'+str(int(a[an]))+'". '+errorprint(code,f))
- f = int(gotopst[gotopst.index(int(a[an]))+1])
- elif code[f]=="J":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- if a[an]>=0:
- if gotost.count(a[an])<1:
- extst[int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1]):]
- else:
- extst[int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1]):]
- else:
- if gotost.count(a[an])<1:
- extst[-int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1])+1:]
- else:
- extst[-int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1])+1:]
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- if a[an]>=0:
- if gotost.count(a[an])<1:
- extst[int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1]):]
- else:
- ex1tst[int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1]):]
- else:
- if gotost.count(a[an])<1:
- ex1tst[-int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1])+1:]
- else:
- ex1tst[-int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1])+1:]
- elif code[f]=="/":####COMMENT
- if code.find("/",f+1)==-1:
- if code.find("\n",f+1)==-1: f = len(code)-1
- else: f = f = code.find("\n",f+1)
- elif code.find("\n",f+1)!=-1 and code.find("/",f+1)>code.find("\n",f+1):
- f = code.find("\n",f+1)
- else:
- f = code.find("/",f+1)
- f+=1
- if f==len(code) and len(codest)!=0:
- f = codest.pop()
- code = codest.pop()
- if outbool: print("",end=None);outbool=False
- print("═"*29+"╛")#WORKTAG
- print("End of "+filelist[number]+", choose option:\n[0] - quit\n[1] - initiate Seabass console\n[2] - continue")
- option = int(input("Option : "))
- if option==0:
- sys.exit()
- elif option==1:
- f=0
- globool=False
- code=""
- outbool=False
- contbool=False
- codest=[]
- print("═"*29+"╕")#WORKTAG
- while not endbool:
- if not contbool:
- input1 = str(input(">> "))
- else:
- input1 = str(input(".. "))
- if len(input1)!=0 and input1[-1]==" " or indreturn(code+input1)>0:
- code+=input1+"\n"
- contbool=True
- else:
- contbool=False
- code+=input1
- indcheck(code)
- while f!=len(code):
- if code[f]=="@":
- endbool=True
- break
- elif code[f]=="i":
- a[an]+=1
- elif code[f]=="I":
- a[an]+=d[dn]
- elif code[f]=="o":
- print(a[an])
- outbool = False
- elif code[f]=="O":
- if a[an]<0:
- if fabs(a[an])<len(extst):
- print(extst[int(fabs(a[an]))])
- if str(extst[int(fabs(a[an]))])[-1]=="\n":
- outbool=False
- else:
- outbool=True
- else:
- print("0",end="")
- outbool=True
- elif a[an]<len(extst):
- print(extst[int(a[an])],end="")
- if str(extst[int(fabs(a[an]))])[-1]=="\n":
- outbool=False
- else:
- outbool=True
- else:
- print("0",end="")
- outbool=True
- elif code[f]=="d":
- a[an]-=1
- elif code[f]=="D":
- a[an]-=d[dn]
- elif code[f]=="s":
- a[an]*=a[an]
- elif code[f]=="S":
- a[an] = a[an]**d[dn]
- elif code[f]=="g":
- a[an]=-a[an]
- elif code[f]=="G":
- d[dn]=-d[dn]
- elif code[f]=="?":
- a[an]=float(uniform(a[an], d[dn]))
- elif code[f]=="v":
- a[an]=a[an]/d[dn]
- elif code[f]=="V":
- a[an]=d[dn]/a[an]
- elif code[f]=="r":
- a[an]=a[an]**0.5
- elif code[f]=="R":
- a[an] = a[an]**(1/d[dn])
- elif code[f]=="m":
- a[an]=a[an]*d[dn]
- elif code[f]=="M":
- a[an]=float(a[an]%d[dn])
- elif code[f]=="%":
- a[an]=float(a[an]//d[dn])
- elif code[f]=="c":
- a[an]=d[dn]
- elif code[f]=="C":
- d[dn]=a[an]
- elif code[f]=="p":
- if a[an]<0: a[an]=-a[an]
- else: pass
- elif code[f]=="P":
- if d[dn]<0: d[dn]=-d[dn]
- else: pass
- elif code[f]=="k":
- if funst.count(int(a[an]))!=0: funst.pop(funst.index(int(a[an]))+1);funst.pop(funst.index(int(a[an])))
- funst.append(int(a[an]));funst.append(code[f+1:finder([code,f])])
- f = finder([code,f])
- ifmode.append(f)
- elif code[f]=="a":
- if an+1==len(a):
- a.append(0.0)
- an+=1
- elif code[f]=="A":
- an+=int(d[dn])
- if an+d[dn]>=len(a):
- exec("a.append(0.0);"*(an-len(a)+1))
- elif code[f]=="b":
- dn+=1
- if len(d)==dn:
- d.append(0.0)
- elif code[f]=="B":
- dn+=int(a[an])
- if len(d)<=dn:
- exec("d.append(0.0);"*(dn-len(d)+1))
- elif code[f]=="x" or code[f]=="X":
- temp = a[an];a[an]=d[dn];d[dn]=temp;del temp
- elif code[f]=="z":
- an=0
- elif code[f]=="Z":
- dn=0
- elif code[f]=="h":
- codest.append(code);codest.append(f+1)
- f=-1
- if not globool:
- code = extst[int(a[an])];indcheck(code)
- else:
- code = ex1tst[int(a[an])];indcheck(code)
- elif code[f]=="H":
- try: innerfun2(funst[funst.index(int(a[an]))+1],funst,d[dn])
- except ValueError: raise FUNCTION_ERR("No such function "+'"'+str(int(a[an]))+'". '+errorprint(code,f))
- d[dn]=tempvar
- elif code[f]=="K":
- globool = not globool
- elif code[f]=="n":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=int(int(a[an]))
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=int(int(a[an]))
- elif code[f]=="N":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=int(int(d[dn]))
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=int(int(d[dn]))
- elif code[f]=="f":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=a[an]
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=a[an]
- elif code[f]=="F":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=d[dn]
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=d[dn]
- elif code[f]=="t":
- if not globool:
- if len(extst)<=fabs(int(d[dn])):
- exec("extst.append(0);"*int(fabs(int(d[dn]))-len(extst)+1))
- if d[dn]>=0: extst[int(d[dn])]=chr(int(a[an]))
- else: extst[-int(d[dn])]=str(int(a[an]))
- else:
- if len(ex1tst)<=int(fabs(d[dn])):
- exec("ex1tst.append(0);"*int(fabs(int(d[dn]))-len(ex1tst)+1))
- if d[dn]>=0: ex1tst[int(d[dn])]=chr(int(a[an]))
- else: ex1tst[-int(d[dn])]=str(int(a[an]))
- elif code[f]=="T":
- if not globool:
- if len(extst)<=int(fabs(d[dn])):
- exec("extst.append(0);"*int(int(fabs(d[dn]))-len(extst)+1))
- if d[dn]>=0:
- if extst[int(d[dn])]!=0: extst[int(d[dn])]+=chr(int(a[an]))
- else: extst[int(d[dn])]=chr(int(a[an]))
- else:
- extst[-int(d[dn])] = a[an]
- else:
- if len(ex1tst)<=int(fabs(d[dn])):
- exec("ex1tst.append(0);"*int(fabs(int(d[dn]))-len(ex1tst)+1))
- if d[dn]>=0:
- if ex1tst[int(d[dn])]!=0: ex1tst[int(d[dn])]+=chr(int(a[an]))
- else: ex1tst[int(d[dn])]=chr(int(a[an]))
- else:
- ex1tst[-int(d[dn])] = a[an]
- elif code[f]=="e":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- extst[int(d[dn])]=boolcust(a[an])
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- ex1tst[int(d[dn])]=boolcust(a[an])
- elif code[f]=="E":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- extst[int(a[an])]=boolcust(d[dn])
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- ex1tst[int(a[an])]=boolcust(d[dn])
- elif code[f]=="q":
- a[an]=inputype(input("?> "))
- elif code[f]=="Q":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- try: extst[int(a[an])]=str(input(extst[int(d[dn])]))
- except TypeError: extst[int(a[an])]=str(input())
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- try: ex1tst[int(a[an])]=str(input(ex1tst[int(d[dn])]))
- except TypeError: ex1tst[int(a[an])]=str(input())
- elif code[f]=="l":
- if not globool:
- if len(extst)<=int(d[dn]):
- exec("extst.append(0);"*(int(d[dn])-len(extst)+1))
- a[an]=converter(extst[int(d[dn])])
- else:
- if len(ex1tst)<=int(d[dn]):
- exec("ex1tst.append(0);"*(int(d[dn])-len(ex1tst)+1))
- an[an]=converter(ex1tst[int(d[dn])])
- elif code[f]=="w":
- if not globool:
- if a[an]>=0:
- filemaker(extst[int(a[an])],extst[int(d[dn])])
- else:
- filemaker(chr(int(a[an])),extst[int(d[dn])])
- else:
- if a[an]>=0:
- filemaker(ex1tst[int(a[an])],ex1tst[int(d[dn])])
- else:
- filemaker(chr(int(a[an])),ex1tst[int(d[dn])])
- elif code[f]=="W":
- if not globool:
- if a[an]>=0:
- fileapp(extst[int(a[an])],extst[int(d[dn])])
- else:
- fileapp(chr(int(a[an])),extst[int(d[dn])])
- else:
- if a[an]>=0:
- fileapp(ex1tst[int(a[an])],ex1tst[int(d[dn])])
- else:
- fileapp(chr(int(a[an])),ex1tst[int(d[dn])])
- elif code[f]=="y":
- if not globool:
- extst[int(a[an])]=filereader(extst[int(d[dn])])
- else:
- ex1tst[int(a[an])]=filereader(ex1tst[int(d[dn])])
- elif code[f]=="Y":
- if not globool:
- extst[int(a[an])]+=filereader(extst[int(d[dn])])
- else:
- ex1tst[int(a[an])]+=filereader(ex1tst[int(d[dn])])
- elif code[f]=="#" or code[f]=="L":
- if not globool:
- try: a[an]=float(ord(extst[int(a[an])][int(d[dn])]))
- except IndexError: a[an]=-1.0
- else:
- try: a[an]=float(ord(ex1tst[int(a[an])][int(d[dn])]))
- except IndexError: a[an]=-1.0
- elif code[f]=="№" or code[f]=="$":
- if not globool: a[an]=float(findnumber(extst[int(a[an])],d[dn]))
- else: a[an]=float(findnumber(ex1tst[int(a[an])],d[dn]))
- elif code[f]=="=":
- if a[an]==d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="<":
- if a[an]<d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="!":
- if a[an]!=d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="{":
- if a[an]<=d[dn]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="[":
- if not globool:
- if extst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- else:
- if ex1tst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]=="]":
- if not globool:
- if not extst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- else:
- if not ex1tst[int(a[an])]:
- ifcount.append(findnew(code,f))
- else:
- f = findnew2(code,f)
- elif code[f]==".":
- ifcount.append(findnew(code,f))
- elif code[f]==">":
- if len(ifcount)!=0:
- if ifchecker(code,f): f = ifcount.pop()
- elif code[f]==":":
- if gotopst.count(int(a[an]))!=0: f+=1;continue
- if gotost.count(int(a[an]))!=0: gotost.pop(gotost.index(int(a[an]))+1);gotost.pop(gotost.index(int(a[an])))
- gotost.append(int(a[an]))
- gotost.append(str(f))
- elif code[f]==";":
- if gotopst.count(int(a[an]))!=0 or gotopst.count(int(f))!=0 or gotost.count(int(a[an]))!=0:
- pass
- else:
- gotopst.append(int(a[an]))
- gotopst.append(str(f))
- elif code[f]=="j":
- if gotost.count(int(a[an]))!=0:
- exec('ifcount.pop();'*countnums(code[int(gotost[gotost.index(int(a[an]))+1])+1:f]))
- f = int(gotost[gotost.index(int(a[an]))+1])
- else:
- try: f = exec('ifcount.pop();'*countnums(code[int(gotopst[gotopst.index(int(a[an]))+1])+1:f]))
- except ValueError: raise GOTOPOINT_ERR("No such goto point "+'"'+str(int(a[an]))+'". '+errorprint(code,f))
- f = int(gotopst[gotopst.index(int(a[an]))+1])
- elif code[f]=="J":
- if not globool:
- if len(extst)<=int(a[an]):
- exec("extst.append(0);"*(int(a[an])-len(extst)+1))
- if a[an]>=0:
- if gotost.count(a[an])<1:
- extst[int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1]):]
- else:
- extst[int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1]):]
- else:
- if gotost.count(a[an])<1:
- extst[-int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1])+1:]
- else:
- extst[-int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1])+1:]
- else:
- if len(ex1tst)<=int(a[an]):
- exec("ex1tst.append(0);"*(int(a[an])-len(ex1tst)+1))
- if a[an]>=0:
- if gotost.count(a[an])<1:
- extst[int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1]):]
- else:
- ex1tst[int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1]):]
- else:
- if gotost.count(a[an])<1:
- ex1tst[-int(d[dn])] = code[int(gotopst[gotopst.index(int(a[an]))+1])+1:]
- else:
- ex1tst[-int(d[dn])] = code[int(gotost[gotost.index(int(a[an]))+1])+1:]
- elif code[f]=="/":####COMMENT
- if code.find("/",f+1)==-1:
- if code.find("\n",f+1)==-1: f = len(code)-1
- else: f = f = code.find("\n",f+1)
- elif code.find("\n",f+1)!=-1 and code.find("/",f+1)>code.find("\n",f+1):
- f = code.find("\n",f+1)
- else:
- f = code.find("/",f+1)
- f+=1
- if f==len(code) and len(codest)!=0:
- f = codest.pop()
- code = codest.pop()
- if outbool: print("",end=None);outbool=False
- f=0
- code=""
- print("═"*29+"╛")#WORKTAG
- else:
- continue
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement