Unbabtized

Bored, I spent the past few hours writing a small, 100% useless language. It doesn't have a name, so I call it UNBABTIZED (as in: has not been given a name yet), which is, right there, a self-contradiction. And, its even a wrong spelling of UNBAPTIZED! What a good start!

Having said that, its a procedural language in that its not a functional one, and is probably best thought of as one very elaborate excursion away from brainfuck.

DOWNLOAD

You can download the whole UNBABTIZED distribution here.

TUTORIAL

You can write integer literals: 0, 1, and so on.

UNBABTIZED has an array of 1000 memory cells. You can refer to memory cells: °0 is the first memory cell, °1 is the second memory cell, and °999 is the last memory cell.

You can assign data to memory cells:

!x,y will assign the value y (either literal or memory cell) to the memory cell of index x. Obviously, you cannot assign values to literals.

Instructions are separated by ., so A.B.C means three consecutive instructions A, B and C.

You can do basic arithmetic:

~x,y
will set memory[x] to memory[x]+memory[y]
(x,y
will set memory[x] to memory[x]-memory[y]
)x,y
will set memory[x] to memory[x]*memory[y]
[x,y
will set memory[x] to memory[x]/memory[y]

and evaluation

Ax,y
will set memory[x] to memory[x]<memory[y]
§x,y
will set memory[x] to memory[x]<=memory[y]
$x,y
will set memory[x] to memory[x]==memory[y]
%x,y
will set memory[x] to memory[x]>memory[y]
&x,y
will set memory[x] to memory[x]>=memory[y]
/x,y
will set memory[x] to memory[x]<>memory[y]

If you need logic functions, write wrapper code using arithmetic functions and evaluation. You can do output

:x
will write x as char,
@x
will write x as integer.

There is no input. There is a philosophy behind this, you know! To my view, there are two kinds of input, user input and hardcoded input. User input sucks, and hardcoded input rules, so there.

You can do a DO-WHILE-NOT style loop better expressed as a computed goto. This c-code

loop_begin:
	...
	if( memory[x] ) goto loop

is written as

,
(instructions go here)
-x

Loops can be nested (at least in theory, but I haven't tested this ;).

There are no comments. Comments are for wimps! Note that Newlines, Tabs, Spaces etc. are considered comments, too, so they are not allowed either. Get an editor that can handle long lines, if you want to mess with UNBABTIZED.

Examples? This

:72.:101.:108.:108.:111.:32.:87.:111.:114.:108.:100

will print "Hello, World", and this

!0,1.!1,1.!2,1.!3,1.,.@&deg;0.!4,&deg;0.!0,&deg;1.~4,&deg;0.!1,&deg;4.~2,&deg;3.!5,&deg;2.A5,10.-5

will print the first ten fibonacci numbers.

The interpreter reqiures Python 2.2 (or higher ;) because of the changes in lambda-scope. I'm using some of my lambda tricks here. The code looks very pythonesque, IMHO:

import sys

f = sys.argv[1]

o = [0,[],[0]*1000,lambda x:o[4]("o[2]")+"x,o[2][x]%sy)" %x,
     lambda x:x+".__setitem__(",open(f).read().split("."),0,
     1,None,lambda x,y:o.__setitem__(x,y),lambda:o[9](7,o[6]
     .find("&deg;")),lambda:len(o[6][o[8]:o[8]+1]) and o[6][o[8]
     :o[8]+1] in "0123456789",lambda:o[9](6,o[6][:o[7]]+"o["\
     "2]["+o[6][o[7]+1:o[8]]+"]"+o[6][o[8]:]),lambda:(o[11](
     )and(o[9](8,o[8]+1),o[13]())or 0),lambda:o[7]>=0 and(o[
     9](8,o[7]+1),o[13](),o[12]()),lambda:"(lambda x=None,y"\
     "=None:%s)(%s)"%({'!':o[4]("o[2]")+"x,y)",'@':"sys.std"\
     "out.write(str(x)+chr(10))",':':"sys.stdout.write(chr("\
     "x))",'~':o[3]("+"),'(':o[3]("-"),')':o[3]("*"),'[':o[3
     ]("/"),"A":o[3]("<"),"&sect;":o[3]("<="),"$":o[3]("=="),"%":
     o[3](">"),"&":o[3](">="),"/":o[3]("<>"),',':"o[1].appe"\
     "nd(o[0])",'-':"o[2][x] and ("+o[4]("o")+"0,o[1][0]-1)"\
     ",o[1].__setslice__(1,len(o[1]),o[1][1:]))or 0",}[o[6][
     0]],o[6][1:]),lambda:(o[9](6,o[5][o[0]]),o[10](),o[14](
     ),eval(o[15]()),o[9](0,o[0]+1)),lambda:o[0] < len(o[5])
     and(o[16](),o[17]())]

o[17]()