public function parseReturn(Tokenizer $tokens) { if ($tokens->valid()) { $return = $this->parseExpression($tokens->next()); dump("{$return}"); if ($return->isScalar()) { switch ($return->type) { case Types::BOOLEAN: return $return->value ? "RETURN_TRUE;" : "RETURN_FALSE;"; case Types::DOUBLE: return "RETURN_DOUBLE({$return->value});"; case Types::INT: return "RETURN_LONG({$return->value});"; case Types::NIL: return "RETURN_NULL();"; case Types::STRING: return "RETURN_STRINGL(\"" . addslashes($return->value) . "\", " . strlen($return->value) . ");"; default: drop("unknown type " . Types::getTypeCode($return->type)); } } else { return "RETURN_ZVAL({$return}, 1);"; } } else { return "return;"; } }
private function _parseName(Tokenizer $tokens) { $tokens->skipIf(T_NS_SEPARATOR); $name = $tokens->get(T_STRING); while ($tokens->next()->is(T_NS_SEPARATOR)) { $name .= '\\' . $tokens->next()->get(T_STRING); } return ltrim($name, '\\'); }