예제 #1
0
 /**
  * Constructs a new missing value exception.
  *
  * @param PHP_Depend_TokenizerI $tokenizer The context tokenizer instance.
  */
 public function __construct(PHP_Depend_TokenizerI $tokenizer)
 {
     // Get wrong token
     $token = $tokenizer->next();
     // The parser must take care for this
     assert($token instanceof PHP_Depend_Token);
     $message = sprintf('Missing default value on line: %d, col: %d, file: %s.', $token->startLine, $token->startColumn, $tokenizer->getSourceFile());
     parent::__construct($message);
 }
 /**
  * Parses a function name from the given tokenizer and returns the string
  * literal representing the function name. If no valid token exists in the
  * token stream, this method will throw an exception.
  *
  * @return string
  * @throws PHP_Depend_Parser_UnexpectedTokenException When the next available
  *         token does not represent a valid php function name.
  * @throws PHP_Depend_Parser_TokenStreamEndException When there is no next
  *         token available in the given token stream.
  */
 public function parse()
 {
     switch ($this->_tokenizer->peek()) {
         case PHP_Depend_TokenizerI::T_STRING:
         case PHP_Depend_TokenizerI::T_USE:
         case PHP_Depend_TokenizerI::T_GOTO:
         case PHP_Depend_TokenizerI::T_NULL:
         case PHP_Depend_TokenizerI::T_SELF:
         case PHP_Depend_TokenizerI::T_TRUE:
         case PHP_Depend_TokenizerI::T_FALSE:
         case PHP_Depend_TokenizerI::T_NAMESPACE:
         case PHP_Depend_TokenizerI::T_DIR:
         case PHP_Depend_TokenizerI::T_NS_C:
         case PHP_Depend_TokenizerI::T_PARENT:
             $token = $this->_tokenizer->next();
             $this->_tokenStack->add($token);
             return $token->image;
         case PHP_Depend_TokenizerI::T_EOF:
             throw new PHP_Depend_Parser_TokenStreamEndException($this->_tokenizer);
     }
     throw new PHP_Depend_Parser_UnexpectedTokenException($this->_tokenizer->next(), $this->_tokenizer->getSourceFile());
 }
예제 #3
0
 /**
  * This method will consume all comment tokens from the token stream.
  *
  * @return void
  */
 private function _consumeComments()
 {
     $type = $this->_tokenizer->peek();
     while ($type == self::T_COMMENT || $type == self::T_DOC_COMMENT) {
         $this->_tokenStack->add($this->_tokenizer->next());
         $type = $this->_tokenizer->peek();
     }
 }