Сделал простенький интерпретатор brainfuck'а. А теперь думаю: «Зачем?».
Может кто поможет потестить:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
def execute(program):
    if re.search("(?![\+\-\[\]><\.]).*", program).group(0) != "":
        print "Syntax error!"
        return
    index = 0
    cell = list()
    cell.append(0)
    back = list()
    i = -1
    while (i+1) < len(program):
        i += 1
        c = program[i]
        if c == "+":
            cell[index] += 1
            continue
        elif c == "-":
            cell[index] -= 1
            continue
        elif c == "[":
            if cell[index] <= 0:
                i += 1
                new = 0
                while (program[i] != ']' or new != 0) and i < len(program):
                    if program[i] == '[':
                        new += 1
                    if program[i] == ']':
                        new -= 1
                    i +=1
                continue
            back.append(i-1)
            continue
        elif c == "]":
            if len(back) == 0:
                continue
            i = back.pop()
            continue
        elif c == ".":
            sys.stdout.write(chr(cell[index]))
            continue
        elif c == ",":
            cell[index] = int(raw_input(",: "))
            continue
        elif c == ">":
            if (index+1) == len(cell):
                cell.insert(index+1,0)
            index += 1
            continue
        elif c == "<":
            if index == 0:
                cell.insert(index,0)
            index -= 1
            continue
            
if __name__ == '__main__':
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
        try:
            for line in f:
                execute(line)
                print("")
        finally:
            f.close()
    else:
        print("brainguck.py <file>")
На вход подается файл, каждая строчка отдельная программа. С википедии хеловорд работает. Такие дела.







