x-D
x-D is a programming language based on smileys, created by tejeez in 2007.
Syntax and specification
Every command consists of eyes, mouth and if needed, a nose and another eyes. The eyes determine the pointer to use, the nose the number of repetitions and the mouth the actual command. Some commands, such as adding of two numbers, take two pointers and thus have four eyes. The eyes can be 8
, x
, ;
, :
, or %
.
The number of repetitions or the number to be subtracted or added is determined by the nose. Without any nose, it's 1 and any letter in the nose adds something to it. .
means 38416, ^
2744, _
196, ~
14 and -
1.
I'm currently so lazy that I just copy the list of different commands from a comment in the source of the interpreter:
# begin and end a comment > increase (without nose, increase by 1 - longer nose increases more) < decrease ) begin loop (if 0, jump to the instruction after the end of the loop) ( end loop (if not 0, jump to the instruction after the beginning of the loop) } begin loop (if 0 or less, jump to the instruction after the end of the loo) { end loop (if over 0, jump to the instruction after the beginning of the loop) D move the pointer forward in the memory | move the pointer backward P output to stdout (or file) E read from stdin N zero * end the program Four-eyed instructions taking two pointers: @ second pointer = first pointer (second pointer to the same place with the first) $ *second = *first (copy the number) O *second = *first + *second (add) C *second = *first - *second (subtract) S *second = *first * *second (multiply) F *second = *first / *second; *first = *first % *second (divide with remainder) B second pointer = second pointer + *first (move the pointer) for example, :8O sums the numbers pointed by : and 8 and puts the result at 8
Any other character (such as a space or newline) is simply ignored, but comments should be begun and ended with #
to prevent them from being mistaken as commands.
Hello World!
;-~~~~~> ;P ;~~> ;P ;------> ;-P ;--> ;P ;D ;~~---> ;P ;| ;~~< ;----> ;P ;~---------> ;P ;--> ;P ;-----< ;P ;-------< ;P ;D ;> ;P ;~< ;-------< ;P
Or shorter:
;-~~~~~>;P;~~>;P;------>;-P;-->;P;D;~~--->;P;|;~~<;---->;P;~--------->;P;-->;P;-----<;P;-------<;P;D;>;P;~<;-------< ;P