KEMURI
This entry is an introduction of new programming language. Here is Japanese version.
KEMURI (means 'smoke' in Japanese) is proposed by NISHIO Hirokazu and OBINATA Daichi in the 39th symposium for young researcher of information science (jouhou kagaku wakate-no-kai in Japanese).
This is a code to print "Just Another Python Hacker," in KEMURI. Notice it is not the shortest code to print that. "^^"^^ can be replaced by ^"^^.
`"^^"^^^^"^^'"^^"^^'"^^"^^'"^^"^^"'"^^"^^`"^^"^^^^"^^"^^"^^"^^"^^'"^^"^^"'"^^"^^ `"^^'^^'"^^"^^'"^^"^^'"^^"^^'"^^"^^"'"^^"^^`'"^^"^^^^'"^^^'"^^"^^'"^^"^^'"^^"^^` "^^"^^^^^^'"^^"^^'"^^"^^'"^^"^^`"^^"^^"^^'"^^^'"^^"^^'"^^"^^'"^^"^^^`'"^^"^^'"^^ "^^'"^^"^^'"^^"^^'"^^"^^'"^^"^^`"^^"^^^^"^^"^^'"^^"^^'"^^"^^'"^^"^^`"^^"^^^^'"^^ ^'"^^"^^'"^^"^^'"^^^`"^^"^^^^'"^^"^^'"^^"^^'"^^"^^'"^^"^^`'"^^''^^'"^^"^^^'"^^"^ ^'"^^"^^'"^^"^^`"^^"^^^^"^^"^^"^^^'"^^^'"^^"^^`"^^"^^^^"^^"^^"^^"^^''"^^^^'"^^"' `'"^^"^^'"^^"^^'"^^"^^^^'"^^"^^'"^^"^^"'`"^^"^^^^"^^"^^'"^^"^^'"^^"^^'"^^"^^'"^^ "^^`"^^"^^^^"^^"^^"^^"^^"^^'"^^"^^"'"^^"^^`"^^'^^'"^^"^^'"^^"^^'"^^"^^'"^^"^^"'" ^^"^^`'"^^''^^'"^^"^^^'"^^"^^'"^^"^^'"^^"^^`"^^"^^^^"^^"^^"^^^'"^^^'"^^"^^`"^^"^ ^^^'"^^"^^'"^^"^^'"^^"^^'"^^"^^`"^^"^^^^'"^^^'"^^"^^'"^^"^^'"^^^`^^'"^^"^^'"^^"^ ^'"^^"^^'"^^"^^'"^^"^^`"^^"^^^^"^^"^^'"^^"^^'"^^"^^'"^^"^^`"^^"^^^^"^^"^^"^^^'"^ ^^'"^^"^^`"^^"^^^^"^^"^^'"^^"^^^'"^^"^^^`'"^^"^^'"^^"^^'"^^^'"^^^^'"^^''`"^^"^^^ ^"^^"^^^^^'"^^"^^'"^^"^^"'^"^^|
KEMURI is a Stack machine. You can push byte values (from 0 to 255) into stack. Each letter in KEMURI code is a command. There are only 6 commands in KEMURI syntax. The ^ pops two value from the stack and calculates XOR and pushes the result. The " duplicate the top value of the stack, that is, it pops a value and pushes itself twice. The ' pops three values x, y, z and pushes x, z, y. In other word, it rotates the top three values of the stack from xyz to yzx. The ~ pops a value and calculate NOT and pushes the result. The only command to push constant values into the stack is the `. It pushes 13 values 33, 100, 108, 114, 111, 119, 32, 44, 111, 108, 108, 101, 72 in this order. The | prints all values in the stack to standard output. It is strongly recommended to use it only once at the tail of your code.
To print "Hello, world!", you just type two keys as below. It is the shortest code to print "Hello, world!" all over the world, except for HQ9+.
`|
KEMURI has many advantages. It can print any character, which HQ9+ can't. It has only 6 commands so it is easier to learn Brainf*ck.
"l"(small L) and "*"(asterisk) are reserved for possibility to use as a command "Execute the stack as Brainf*ck" in future.
I wrote a KEMURI interpreter in Python.
class Kemuri(list):
def push(self, x):
self.append(x)
def do(self, com):
if com == "~":
self.push(~self.pop())
elif com == "^":
x = self.pop()
y = self.pop()
self.push(x ^ y)
elif com == '"':
x = self.pop()
self.push(x)
self.push(x)
elif com == "'": # xyz => yzx
x = self.pop()
y = self.pop()
z = self.pop()
self.push(x)
self.push(z)
self.push(y)
elif com == "`":
s = list("Hello, world!")
s.reverse()
for c in s:
self.push(ord(c))
elif com == "|":
result = ""
while len(self) > 0:
result += chr(self.pop() % 256)
print result
elif len(com) > 1:
for c in com:
self.do(c)
return self
def inter(self):
while True:
code = raw_input("KEMURI> ")
if code == "":
break
self.do(code)
if __name__ == "__main__":
Kemuri().inter()