GolfScratch
Jump to navigation
Jump to search
GolfScratch - language for Code Golfing Made By User:ChuckEsoteric08
Commands
'Word' is an command or argument
PUSH - Push Something To The Stack (If It Is The ACC Push Accumulator) POP - Pop From Top of The Stack PRINT - Print Top of The Stack INP Get Input And Push It To The Stack GOTO [x] - Goto word [x] IF [x] [y] [z] - If Top Of The Stack == [x] Goto word [y] Else Goto word [z] (space) - Seperate commands and arguments CH. - Increment ACC by Top Of The Stack
Examples
Hello World
PUSH Hello,_World PRINT
NOTE:Spaces are used to split Commands so, strings with spaces cannot be printed.
Print 1 Forever
PUSH 1 PRINT GOTO 1
Cat program
INP PRINT GOTO 1
Computation Class
Maybe This is Turing Complete, Because You Can Make Infinity Loop,and the stack is unbounded. Due to its use of only 7 commands, this language would also be considered a Turing tarpit if so.
External links
Python implementation by User:Ractangle
code=input().split(" "); a=p=0; s=[]
while len(code)!=p:
if code[p]=="PUSH":
if code[p+1]=="ACC": s.append(a);p+=1
else: s.append(code[p+1])
elif code[p]=="POP": s.pop()
elif code[p]=="PRINT": print(s[-1])
elif code[p]=="INP": s.append(input())
elif code[p]=="GOTO": p=int(code[p+1])-1
elif code[p]=="IF":
if s[-1]==code[p+1]:
p=int(code[p+2])
else:p=int(code[p+3])
else: a+=int(s[-1])
p+=1