StackBBQ2+
Jump to navigation
Jump to search
StackBBQ2+ is a language designed by islptng to compile to StackBBQ.
Commands
| Command | Compile into | Explanation |
|---|---|---|
| ~ | 110 | NOT top |
| z | 1110 | Push 0 |
| | | 1111010 | OR top 2 values |
| : | 1111011100 | Duplicate stack top |
| { abc... } | a1110110b1110110c1110110... | Push the content to Q |
| _ | 1110111100 | Push Q to P and clear Q |
| ? | 11101110110 | Append top of P to the program |
| ; | 11101110111100 | pop P and discard |
| $ | 11101110111011100 | reverse the stack |
Compiler
p = input()
d = {'~':'110','z':'1110','|':'1111010'
,':':'1111011100','_':'1110111100','?':'11101110110',
';':'11101110111100','$':'11101110111011100'}
for i in d:
p = p.replace(i,d[i])
def eb(s):
res = ""
for i in list(s):
res += ("1" if i == "1" else "1110") + "1110110"
return res
def meb(s,n):
for i in range(n): s = eb(s)
return s
res = ""
dep = 0
for i in list(p):
if i == "{":
dep += 1
elif i == "}":
dep -= 1
else:
res += meb(i,dep)
print(res)