ドリランド言語作った.

brainfuckファミリ.

ドリランド言語 brainfuck
>
ドッ +
-
.
! ,
[
]

実行例

% python dolifuck.py "ドッドッドッドッドッドッドッドッドッリラドッドッドッドッドッドッドッドッラドッドッドッドッドッドッドッドッドッドッドッラドッドッ ドッドッドッンンンド♪ラ!ラドッドッ!ドッドッドッドッドッドッドッ!!ドッドッドッ!ラド!ドドドドドドドドドドドド!ンドッドッドッドッドッドッドッドッ!ドドドドドドドド!ドッドッ ドッ!ドドドドドド!ドドドドドドドド!ラドッ!"
Hello, world!
%

dorifuck.py

# coding: utf-8
import sys

def dori2bf(dolilang_string) :
  program = []
  for ch in dolilang_string :
    if ch == u'ラ' :
      program += '>'
    elif ch == u'ン' :
      program += '<'
    elif ch == u'ド' :
      program += '-'
    elif ch == u'ッ' :
      if program[len(program)-1] == '-' :
        program[len(program)-1] = '+'
    elif ch == u'!' :
      program += '.'
    elif ch == '!' :
      program += ','
    elif ch == u'リ' :
      program += '['
    elif ch == u'♪' :
      program += ']'
    else :
      pass
  return ''.join(program)

if len(sys.argv) < 2 :
  print "Usage: python dolifuck.py DOLILANG_STRING"
  sys.exit(1)

dolilang_string = sys.argv[1].decode('utf-8')
program = dori2bf(dolilang_string)
program_counter = 0
stack = []
memory = {}
pointer = 0

while True :
  if pointer not in memory :
    memory[pointer] = 0

  if program[program_counter] == '>' :
    pointer += 1
  elif program[program_counter] == '<' :
    pointer -= 1
  elif program[program_counter] == '+' :
    memory[pointer] += 1
  elif program[program_counter] == '-' :
    memory[pointer] -= 1
  elif program[program_counter] == '.' :
    sys.stdout.write('%c' % memory[pointer])
  elif program[program_counter] == ',' :
    memory[pointer] = sys.stdout.read(1)
  elif program[program_counter] == '[' :
    if memory[pointer] :
      stack.append(program_counter)
    else :
      bracket_count = 0
      while True :
        if program[program_counter] == '[' :
          bracket_count += 1
        elif program[program_counter] == ']' :
          bracket_count -= 1
          if bracket_count == 0 :
            break
        program_counter += 1
  elif program[program_counter] == ']' :
      program_counter = stack.pop() - 1
  else :
    pass
  program_counter += 1

  if program_counter == len(program) :
    break