/** * Parse a class from token reader * * @param \vc\Tokens\Access $access The token access * @return \vc\Data\Routine\Func */ public function parseClass(\vc\Tokens\Access $access) { $token = $access->findRequired(array(Token::T_CLASS, Token::T_ABSTRACT)); $class = new \vc\Data\Type\Cls($token->getLine(), $access->getComment()); // Extract the abstract flag from the class definition if ($token->is(Token::T_ABSTRACT)) { $class->setAbstract(TRUE); $access->findRequired(array(Token::T_CLASS)); } // Searches for the name of the class $token = $access->findRequired(array(Token::T_STRING)); // Set the name of the class $class->setName($token->getContent()); // Look for parent classes and interfaces $token = $access->findRequired(array(Token::T_EXTENDS, Token::T_IMPLEMENTS, Token::T_CURLY_OPEN)); // Add the parent class if ($token->is(Token::T_EXTENDS)) { $class->setExtends($this->path->parsePath($access)); // Look for any interfaces $token = $access->findRequired(array(Token::T_IMPLEMENTS, Token::T_CURLY_OPEN)); } // Add any interface implementations if ($token->is(Token::T_IMPLEMENTS)) { $class->setIFaces($this->pathList->parsePathList($access)); $access->findRequired(array(Token::T_CURLY_OPEN)); } // Finally, parse out the content of the class $this->members->parseMembers($class, $access); return $class; }
/** * Parse an interface from token reader * * @param \vc\Tokens\Access $access The token access * @return \vc\Data\Routine\Func */ public function parseIFace(\vc\Tokens\Access $access) { $token = $access->findRequired(array(Token::T_INTERFACE)); $iface = new \vc\Data\Type\IFace($token->getLine(), $access->getComment()); // Searches for the name of the interface $token = $access->findRequired(array(Token::T_STRING)); $iface->setName($token->getContent()); // Look for any interfaces that this one extends $token = $access->findRequired(array(Token::T_EXTENDS, Token::T_CURLY_OPEN)); if ($token->is(Token::T_EXTENDS)) { $iface->setExtends($this->pathList->parsePathList($access)); $access->findRequired(array(Token::T_CURLY_OPEN)); } // Finally, parse out the content of the class $this->members->parseMembers($iface, $access); return $iface; }