Beispiel #1
0
            } elseif ($buffer == self::OP_JMP && $char != 'a') {
                $buffer = $char;
                $this->level += 1;
                $this->stack[$this->level] = [];
            } elseif ($buffer == self::OP_RET && $char != 'a') {
                $buffer = $char;
                $this->_loop();
                $this->level -= 1;
            } elseif ($instruction == self::OP_OUT) {
                $buffer = '';
                if ($this->level > 0) {
                    $this->_push($instruction);
                } else {
                    print chr($this->cells[$this->cellptr]);
                }
            } else {
                $buffer .= $char;
            }
        }
    }
}
if (count($argv) == 2) {
    try {
        $interpreter = new Interpreter();
        $interpreter->evaluate(file_get_contents($argv[1]));
    } catch (Exception $e) {
        print $e;
    }
} else {
    printf("\n    USAGE: php %s /path/to/file.koko\r\n", $argv[0]);
}