public static function instance() { if (!isset(self::$_instance)) { self::$_instance = new WhirlParser(); } return self::$_instance; }
public function moveby($count) { $this->_position += $count; if ($this->_position < 0) { die("Error in instruction " . WhirlParser::instance()->getInstructionNumber() . ": Memory index out of bounds. The memory index was decreased beyond zero."); } if (!isset($this->_values[$this->_position])) { $this->_values[$this->_position] = 0; } }
<?php /** * Parses and runs the keymaker.wr program using * the php Whirl parser, made by Jakob Westhoff * <*****@*****.**> */ include_once "phpWhirl/classes/WhirlParser.php"; $filename = "test/subjects/benchmarks/php-benchmarks/benchcli/tests/phpWhirl/keymaker.wr"; $whirl = new WhirlParser(); $whirl->loadfile($filename); $whirl->parse();
protected function RINGFUNC_AscIO() { if ($this->_getValue() === 0) { WhirlMemory::instance()->setValue((int) ord(WhirlParser::instance()->input())); } else { WhirlParser::instance()->output(chr(WhirlMemory::instance()->getValue())); } }